path
stringlengths
5
195
repo_name
stringlengths
5
79
content
stringlengths
25
1.01M
docs/src/app/components/pages/components/DropDownMenu/ExampleSimple.js
ArcanisCz/material-ui
import React from 'react'; import DropDownMenu from 'material-ui/DropDownMenu'; import MenuItem from 'material-ui/MenuItem'; const styles = { customWidth: { width: 200, }, }; export default class DropDownMenuSimpleExample extends React.Component { constructor(props) { super(props); this.state = {value: 1}; } handleChange = (event, index, value) => this.setState({value}); render() { return ( <div> <DropDownMenu value={this.state.value} onChange={this.handleChange}> <MenuItem value={1} primaryText="Never" /> <MenuItem value={2} primaryText="Every Night" /> <MenuItem value={3} primaryText="Weeknights" /> <MenuItem value={4} primaryText="Weekends" /> <MenuItem value={5} primaryText="Weekly" /> </DropDownMenu> <br /> <DropDownMenu value={this.state.value} onChange={this.handleChange} style={styles.customWidth} autoWidth={false} > <MenuItem value={1} primaryText="Custom width" /> <MenuItem value={2} primaryText="Every Night" /> <MenuItem value={3} primaryText="Weeknights" /> <MenuItem value={4} primaryText="Weekends" /> <MenuItem value={5} primaryText="Weekly" /> </DropDownMenu> </div> ); } }
src/img/GrommetHero.js
grommet/grommet-docs
import React from 'react'; export default () => ( <svg className='logo grommet-hero' version="1.1" width="848" height="172" viewBox="0 0 848 172"> <g fill="none"> <path className='logo' stroke="#865CD6" strokeWidth="11" d="M185,79 C185,52.490332 206.490332,31 233,31 C259.509668,31 281,52.490332 281,79 C281,105.509668 259.509668,127 233,127 C206.490332,127 185,105.509668 185,79 Z"/> <path className='text' fill="#333333" d="M63.126,117.416 L37.842,117.416 C23.534,117.416 17.066,112.32 17.066,104.676 C17.066,97.62 22.946,92.328 33.726,91.152 C37.842,91.936 42.35,92.524 47.054,92.524 C71.162,92.524 87.038,79.784 87.038,60.38 C87.038,50.58 82.922,42.348 75.866,36.664 C77.042,26.864 84.49,21.768 96.642,21.768 L94.094,11.968 C80.766,11.968 70.77,19.612 68.81,32.352 C62.734,29.608 55.482,28.04 47.054,28.04 C22.946,28.04 7.07,40.78 7.07,60.38 C7.07,72.336 12.95,81.548 23.142,87.036 C13.342,89.78 6.482,96.64 6.482,106.244 C6.482,113.888 11.774,119.768 18.83,123.296 C8.246,126.628 1.778,134.076 1.778,144.072 C1.778,159.164 16.674,170.14 47.446,170.14 C74.886,170.14 94.682,158.38 94.682,139.956 C94.682,126.432 82.922,117.416 63.126,117.416 Z M47.054,37.448 C64.89,37.448 75.67,46.268 75.67,60.38 C75.67,74.492 64.89,83.116 47.054,83.116 C29.414,83.116 18.438,74.492 18.438,60.38 C18.438,46.268 29.414,37.448 47.054,37.448 Z M48.818,160.732 C24.71,160.732 11.97,153.676 11.97,142.308 C11.97,133.292 20.986,127.02 35.49,127.02 L60.774,127.02 C77.238,127.02 84.49,132.704 84.49,141.328 C84.49,152.108 71.162,160.732 48.818,160.732 Z M154.618,28.04 C139.134,28.04 128.158,35.684 123.062,49.012 L121.69,30 L112.282,30 L112.282,128 L123.454,128 L123.454,73.512 C123.454,52.148 137.37,38.428 151.482,38.428 C157.362,38.428 161.086,39.8 163.83,41.564 L166.574,30.98 C163.634,29.02 159.322,28.04 154.618,28.04 Z M427.214,27.844 C412.318,27.844 396.442,35.684 390.758,49.992 C385.466,35.292 371.746,28.04 356.066,28.04 C341.562,28.04 328.038,35.096 321.374,48.424 L320.786,30 L310.79,30 L310.79,128 L321.962,128 L321.962,73.316 C321.962,50.384 338.426,37.84 355.086,37.84 C370.766,37.84 381.938,46.856 381.938,65.868 L381.938,128 L393.11,128 L393.11,72.336 C393.11,51.56 408.202,37.644 426.234,37.644 C441.914,37.644 453.282,46.66 453.282,65.672 L453.282,127.804 L464.454,127.804 L464.454,64.496 C464.454,39.8 447.402,27.844 427.214,27.844 Z M612.982,27.844 C598.086,27.844 582.21,35.684 576.526,49.992 C571.234,35.292 557.514,28.04 541.834,28.04 C527.33,28.04 513.806,35.096 507.142,48.424 L506.554,30 L496.558,30 L496.558,128 L507.73,128 L507.73,73.316 C507.73,50.384 524.194,37.84 540.854,37.84 C556.534,37.84 567.706,46.856 567.706,65.868 L567.706,128 L578.878,128 L578.878,72.336 C578.878,51.56 593.97,37.644 612.002,37.644 C627.682,37.644 639.05,46.66 639.05,65.672 L639.05,127.804 L650.222,127.804 L650.222,64.496 C650.222,39.8 633.17,27.844 612.982,27.844 Z M764.45,76.06 C764.45,48.228 748.966,28.04 721.526,28.04 C692.714,28.04 676.054,47.248 676.054,79 C676.054,110.752 693.498,129.96 722.506,129.96 C742.498,129.96 755.63,121.728 762.882,107.812 L753.67,102.912 C748.966,113.888 737.598,120.16 722.506,120.16 C701.73,120.16 688.598,106.636 687.226,83.508 L764.058,83.508 C764.254,81.548 764.45,79 764.45,76.06 Z M721.526,37.84 C740.93,37.84 752.298,51.364 753.866,73.512 L687.226,73.512 C688.794,50.972 701.142,37.84 721.526,37.84 Z M842.222,112.32 C837.714,117.024 832.422,119.572 825.366,119.572 C814.782,119.572 808.706,113.496 808.706,101.736 L808.706,39.604 L845.554,39.604 L845.554,30 L808.706,30 L808.706,2.756 L797.534,5.696 L797.534,30 L777.934,30 L777.934,39.604 L797.534,39.604 L797.534,103.5 C797.534,121.924 808.314,129.96 823.406,129.96 C833.206,129.96 841.046,126.628 846.338,121.728 L842.222,112.32 Z"/> </g> </svg> );
src/routes.js
mikeyhogarth/nasteroids
import React from 'react'; import { Router, Route, IndexRoute, hashHistory } from 'react-router'; import App from './components/app/app.component'; import Asteroids from './components/asteroids/asteroids.component'; import Asteroid from './components/asteroid/asteroid.component'; import About from './components/about/about.component'; import NotFound from './components/not-found/not-found.component'; const Routes = (props) => ( <Router history={hashHistory}> <Route path="/" component={App}> <IndexRoute component={Asteroids} /> <Route path="/asteroids" component={Asteroids} /> <Route path="/asteroid/:neo_reference_id" component={Asteroid} /> <Route path="/about" component={About} /> </Route> <Route path="*" component={NotFound} /> </Router> ); export default Routes;
react/react-hn2/src/index.js
weaponhe/weaponhe.github.io
import React from 'react' import ReactDOM from 'react-dom' import { BrowserRouter as Router } from 'react-router-dom' import App from './App' ReactDOM.render(( <Router> <App/> </Router> ), document.getElementById('root'))
src/components/previewTest/PreviewTest-View.js
nikolay-is/jsappproject
import React from 'react'; class PreviewQuestion extends React.Component { render() { if (!this.props.isLoggedIn) this.context.router.push('/'); const correctIdx = Number(this.props.correctAnswer && this.props.correctAnswer.slice(-1) - 1); const givenIdx = Number(this.props.givenAnswer && this.props.givenAnswer.slice(-1) - 1); return ( <fieldset className='user-test-result-question'> <legend>Question { Number(this.props.id) + 1}</legend> <p className='user-test-result-question'>{this.props.question}</p> <div className='user-test-result-answers col-sm-10'> { this.props.answers.filter(a => a) .map((a, idx) => <p key={idx} className={'user-test-result-answer col-sm-5 ' + (idx===correctIdx ? 'correct' : idx===givenIdx ? 'wrong' : 'blank')} > {(Number(idx) + 1) + ': ' + a} </p>) }<br /> </div><br /> <div className='user-test-result-correct col-sm-10'> The correct answer is {this.props.correctAnswer} </div> <div className='user-test-result-given col-sm-10'> {this.props.givenAnswer ? 'Your answer is: ' + this.props.givenAnswer : null} </div> </fieldset> ); } } PreviewQuestion.contextTypes = { router: React.PropTypes.object }; PreviewQuestion.propTypes = { isLoggedIn: React.PropTypes.bool.isRequired, question: React.PropTypes.string.isRequired, answers: React.PropTypes.array.isRequired, correctAnswer: React.PropTypes.string.isRequired, givenAnswer: React.PropTypes.string } PreviewQuestion.defaultProps = {} export default PreviewQuestion;
src/components/WordCloudChart.js
uooo/webpack-echarts-starter-kit
import React from 'react'; import echarts from 'echarts/echarts'; import 'echarts/chart/wordCloud'; function createRandomItemStyle() { return { normal: { color: 'rgb(' + [ Math.round(Math.random() * 160), Math.round(Math.random() * 160), Math.round(Math.random() * 160) ].join(',') + ')' } }; } let charCloudOption = { title: { text: 'Google Trends', link: 'http://www.google.com/trends/hottrends' }, tooltip: { show: true }, series: [{ name: 'Google Trends', type: 'wordCloud', size: ['80%', '80%'], textRotation: [0, 45, 90, -45], textPadding: 0, autoSize: { enable: true, minSize: 14 }, data: [ { name: "Sam S Club", value: 10000, itemStyle: { normal: { color: 'black' } } }, { name: "Macys", value: 6181, itemStyle: createRandomItemStyle() }, { name: "Amy Schumer", value: 4386, itemStyle: createRandomItemStyle() }, { name: "Jurassic World", value: 4055, itemStyle: createRandomItemStyle() }, { name: "Charter Communications", value: 2467, itemStyle: createRandomItemStyle() }, { name: "Chick Fil A", value: 2244, itemStyle: createRandomItemStyle() }, { name: "Planet Fitness", value: 1898, itemStyle: createRandomItemStyle() }, { name: "Pitch Perfect", value: 1484, itemStyle: createRandomItemStyle() }, { name: "Express", value: 1112, itemStyle: createRandomItemStyle() }, { name: "Home", value: 965, itemStyle: createRandomItemStyle() }, { name: "Johnny Depp", value: 847, itemStyle: createRandomItemStyle() }, { name: "Lena Dunham", value: 582, itemStyle: createRandomItemStyle() }, { name: "Lewis Hamilton", value: 555, itemStyle: createRandomItemStyle() }, { name: "KXAN", value: 550, itemStyle: createRandomItemStyle() }, { name: "Mary Ellen Mark", value: 462, itemStyle: createRandomItemStyle() }, { name: "Farrah Abraham", value: 366, itemStyle: createRandomItemStyle() }, { name: "Rita Ora", value: 360, itemStyle: createRandomItemStyle() }, { name: "Serena Williams", value: 282, itemStyle: createRandomItemStyle() }, { name: "NCAA baseball tournament", value: 273, itemStyle: createRandomItemStyle() }, { name: "Point Break", value: 265, itemStyle: createRandomItemStyle() } ] }] }; var WordCloudChart = React.createClass({ componentDidMount() { let mychart = echarts.init(document.getElementById('chart')); mychart.setOption(charCloudOption); }, render() { return ( <div id="chart" style={{width: '80%', height: '600px'}}> </div> ); } }); export default WordCloudChart;
src/routes.js
Cheapass/cheapass
/*! React Starter Kit | MIT License | http://www.reactstarterkit.com/ */ import React from 'react'; import Router from 'react-routing/src/Router'; import http from './core/HttpClient'; import App from './components/App'; import ContentPage from './components/ContentPage'; import ContactPage from './components/ContactPage'; import LoginPage from './components/LoginPage'; import RegisterPage from './components/RegisterPage'; import NotFoundPage from './components/NotFoundPage'; import ErrorPage from './components/ErrorPage'; const router = new Router(on => { on('*', async (state, next) => { const component = await next(); return component && <App context={state.context}>{component}</App>; }); on('/contact', async () => <ContactPage />); on('/login', async () => <LoginPage />); on('/register', async () => <RegisterPage />); on('*', async (state) => { const content = await http.get(`/api/content?path=${state.path}`); return content && <ContentPage {...content} />; }); on('error', (state, error) => state.statusCode === 404 ? <App context={state.context} error={error}><NotFoundPage /></App> : <App context={state.context} error={error}><ErrorPage /></App> ); }); export default router;
client/modules/App/components/Footer/Footer.js
SwanCourses/example-app
import React from 'react'; import { FormattedMessage } from 'react-intl'; // Import Style import styles from './Footer.css'; // Import Images import bg from '../../header-bk.png'; export function Footer() { return ( <div style={{ background: `#FFF url(${bg}) center` }} className={styles.footer}> <p>&copy; 2016 &middot; Hashnode &middot; LinearBytes Inc.</p> <p><FormattedMessage id="twitterMessage" /> : <a href="https://twitter.com/@mern_io" target="_Blank">@mern_io</a></p> </div> ); } export default Footer;
node_modules/react-bootstrap/es/MediaBody.js
Technaesthetic/ua-tools
import _extends from 'babel-runtime/helpers/extends'; import _objectWithoutProperties from 'babel-runtime/helpers/objectWithoutProperties'; import _classCallCheck from 'babel-runtime/helpers/classCallCheck'; import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn'; import _inherits from 'babel-runtime/helpers/inherits'; import classNames from 'classnames'; import React from 'react'; import elementType from 'react-prop-types/lib/elementType'; import { bsClass, getClassSet, splitBsProps } from './utils/bootstrapUtils'; var propTypes = { componentClass: elementType }; var defaultProps = { componentClass: 'div' }; var MediaBody = function (_React$Component) { _inherits(MediaBody, _React$Component); function MediaBody() { _classCallCheck(this, MediaBody); return _possibleConstructorReturn(this, _React$Component.apply(this, arguments)); } MediaBody.prototype.render = function render() { var _props = this.props, Component = _props.componentClass, className = _props.className, props = _objectWithoutProperties(_props, ['componentClass', 'className']); var _splitBsProps = splitBsProps(props), bsProps = _splitBsProps[0], elementProps = _splitBsProps[1]; var classes = getClassSet(bsProps); return React.createElement(Component, _extends({}, elementProps, { className: classNames(className, classes) })); }; return MediaBody; }(React.Component); MediaBody.propTypes = propTypes; MediaBody.defaultProps = defaultProps; export default bsClass('media-body', MediaBody);
src/framework/common/router/create-routes.js
foobarhq/reworkjs
// @flow import React from 'react'; import { Route } from 'react-router-dom'; import { getDefault } from '../../../shared/util/ModuleUtil'; import logger from '../../../shared/logger'; // eslint-disable-next-line import/no-unresolved import routeModules from 'val-loader!./_find-routes'; // TODO: expose @withQueryParams which provides an URLSearchParam instance const SourceFileName = Symbol('sourceFileName'); export default function createRoutes() { const fileNames = routeModules.__debugFileNames || []; if (routeModules.length === 0) { logger.warn('Your framework does not contain any route. Create a file matching your "route" glob as defined in your configuration file.'); } const routes = routeModules .map((routeModule, i) => { let route = getDefault(routeModule); if (route == null || typeof route !== 'object') { return null; } if (typeof route.toJSON === 'function') { route = route.toJSON() || route; } route = Object.assign({}, route); route[SourceFileName] = fileNames[i]; if (route.status === 404) { route.priority = route.priority || Number.MIN_SAFE_INTEGER + 2; route.path = route.path || '*'; } if (route.status && Math.floor(route.status / 100) !== 2) { route.priority = route.priority || Number.MIN_SAFE_INTEGER + 1; route.path = route.path || '*'; } return route; }); if (process.env.NODE_ENV === 'development') { // dev 404 route routes.push({ path: '*', priority: Number.MIN_SAFE_INTEGER, status: 404, component: require('./dev-404.js').default, }); } return routes .filter(route => route !== null) .sort((a, b) => (b.priority || 0) - (a.priority || 0)) .map(route => sanitizeRoute(route, route[SourceFileName])); } function sanitizeRoute(routeData /* , fileName */) { delete routeData.priority; // TODO: add support for status & getComponent in EnhancedRoute component & use EnhancedRoute // by default here. // const { getComponent, status, ...passDownRoute } = routeData; // let routeElement = <Route {...passDownRoute} />; return <Route {...routeData} key={routeData.path} />; }
src/icons/StrokeIdea.js
ipfs/webui
import React from 'react' const StrokeIdea = props => ( <svg viewBox='0 0 100 100' {...props}> <path d='M69.9 32.2A23 23 0 0 0 57.44 18a23.62 23.62 0 0 0-19.69 0 23 23 0 0 0-12.48 14.22 20.63 20.63 0 0 0 2.4 17.23l.45.71c1.24 1.94 2.52 3.94 3.73 5.94a21.3 21.3 0 0 1 3.32 10c.11 1.77.1 3.59.08 5.45a8.43 8.43 0 0 0 2.65 6.31l1.72 1.71c.7.71 1.4 1.42 2.12 2.11a8.43 8.43 0 0 0 5.87 2.47 8.74 8.74 0 0 0 5.82-2.47c.7-.67 1.37-1.36 2-2s1.15-1.19 1.74-1.77a8.43 8.43 0 0 0 2.65-6.31c0-1.85 0-3.65.08-5.45a21.47 21.47 0 0 1 3.33-10c1.08-1.77 2.21-3.55 3.32-5.27l.88-1.38a20.65 20.65 0 0 0 2.47-17.3zM38.25 71.59v-4h18.7c0 1.34-.05 2.67 0 4a5.62 5.62 0 0 1 0 .59H38.28a5.49 5.49 0 0 1-.03-.59zm16.88 4.14c-.61.6-1.2 1.21-1.79 1.82s-1.3 1.33-2 2a5.84 5.84 0 0 1-3.75 1.62 5.42 5.42 0 0 1-3.79-1.62c-.7-.68-1.39-1.38-2.07-2.07S40.59 76.3 40 75.73a6 6 0 0 1-1.16-1.56H56.3a6 6 0 0 1-1.17 1.56zM65 47.84l-.88 1.37c-1.12 1.79-2.3 3.53-3.39 5.33a24.45 24.45 0 0 0-3.73 11h-8.46v-13c.78-.74 6.59-6.26 9.46-9a1 1 0 1 0-1.4-1.43c-2.56 2.48-7.47 7.15-9 8.64l-8.36-8.55a1 1 0 0 0-1.43 1.4l8.76 8.95v13h-8.44a24.34 24.34 0 0 0-3.71-11c-1.23-2-2.52-4-3.77-6l-.45-.7a17.68 17.68 0 0 1-2.06-14.76A20 20 0 0 1 39 20.73a20.58 20.58 0 0 1 17.23 0A20 20 0 0 1 67 33.06a17.69 17.69 0 0 1-2 14.78z' /> </svg> ) export default StrokeIdea
src/frontend/components/Dashboard.js
al3x/ground-control
import React from 'react'; import Relay from 'react-relay'; import {Styles} from 'material-ui'; import TopNav from './TopNav'; import {BernieTheme} from './styles/bernie-theme'; import {BernieColors} from './styles/bernie-css'; @Styles.ThemeDecorator(Styles.ThemeManager.getMuiTheme(BernieTheme)) class Dashboard extends React.Component { tabs = [{ value:'/call-assignments', label: 'Make Calls', }, { value: '/events', label: 'Events' }, { value: 'https://go.berniesanders.com/page/share/share-for-bernie?source=homepage_organize', label: 'Share' }, { value: 'https://go.berniesanders.com/page/share/share-for-bernie?source=homepage_organize', label: 'Resources' }, { value: 'https://organize.berniesanders.com/slack/berniebuilders', label: 'Gather Online' }, ] renderTopNav() { return ( <TopNav zDepth={0} barColor={BernieColors.lightGray} tabColor={BernieColors.darkGray} selectedTabColor={BernieColors.gray} logoColors={{ primary: BernieColors.blue, swoosh: BernieColors.red }} tabs={this.tabs} history={this.props.history} location={this.props.location} /> ) } render() { // No volunteer navigation for now. return ( <div> {this.props.children} </div> ) } } // We only do this to auth protect this component. Otherwise it is unnecessary. export default Relay.createContainer(Dashboard, { fragments: { currentUser: () => Relay.QL` fragment on User { id } ` } })
client/components/Projectlist.js
greenfox-academy/lufthansa_project
'use strict'; import React from 'react'; import {Link} from 'react-router'; var ProjectList = React.createClass({ renderName: 'ProjectList', render: function(response) { var createRows = function (project) { return (<tr key={project.lastBuild.buildId}> <td className="projectName"><Link to={"project/" + project.projectId}>{project.projectName}</Link></td> <td>{project.lastBuild.status === true ? <div className="greenBuild"></div> : <div className="redBuild"></div>}</td> <td className="buildDate">{project.lastBuild.time}</td> </tr>); }; return ( <table className="fullTable"> <tbody> {this.props.projectBuildList.map(createRows)} </tbody> </table> ) } }); module.exports = ProjectList;
app/components/ToggleOption/index.js
belongapp/belong
/** * * ToggleOption * */ import React from 'react'; import { injectIntl, intlShape } from 'react-intl'; const ToggleOption = ({ value, message, intl }) => ( <option value={value}> {intl.formatMessage(message)} </option> ); ToggleOption.propTypes = { value: React.PropTypes.string.isRequired, message: React.PropTypes.object.isRequired, intl: intlShape.isRequired, }; export default injectIntl(ToggleOption);
src/PaginationButton.js
nickuraltsev/react-bootstrap
import React from 'react'; import classNames from 'classnames'; import BootstrapMixin from './BootstrapMixin'; import createSelectedEvent from './utils/createSelectedEvent'; import CustomPropTypes from './utils/CustomPropTypes'; const PaginationButton = React.createClass({ mixins: [BootstrapMixin], propTypes: { className: React.PropTypes.string, eventKey: React.PropTypes.oneOfType([ React.PropTypes.string, React.PropTypes.number ]), onSelect: React.PropTypes.func, disabled: React.PropTypes.bool, active: React.PropTypes.bool, /** * You can use a custom element for this component */ buttonComponentClass: CustomPropTypes.elementType }, getDefaultProps() { return { active: false, disabled: false }; }, handleClick(event) { if (this.props.disabled) { return; } if (this.props.onSelect) { let selectedEvent = createSelectedEvent(this.props.eventKey); this.props.onSelect(event, selectedEvent); } }, render() { let classes = { active: this.props.active, disabled: this.props.disabled, ...this.getBsClassSet() }; let { className, ...anchorProps } = this.props; let ButtonComponentClass = this.props.buttonComponentClass; return ( <li className={classNames(className, classes)}> <ButtonComponentClass {...anchorProps} onClick={this.handleClick} /> </li> ); } }); export default PaginationButton;
src/templates/not-found-template.js
wpioneer/gatsby-starter-lumen
// @flow strict import React from 'react'; import Sidebar from '../components/Sidebar'; import Layout from '../components/Layout'; import Page from '../components/Page'; import { useSiteMetadata } from '../hooks'; const NotFoundTemplate = () => { const { title, subtitle } = useSiteMetadata(); return ( <Layout title={`Not Found - ${title}`} description={subtitle}> <Sidebar /> <Page title="NOT FOUND"> <p>You just hit a route that doesn&#39;t exist... the sadness.</p> </Page> </Layout> ); }; export default NotFoundTemplate;
Libraries/Components/WebView/WebView.ios.js
esauter5/react-native
/** * Copyright (c) 2015-present, Facebook, Inc. * All rights reserved. * * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. * * @providesModule WebView * @noflow */ 'use strict'; var ActivityIndicator = require('ActivityIndicator'); var EdgeInsetsPropType = require('EdgeInsetsPropType'); var React = require('React'); var ReactNative = require('ReactNative'); var StyleSheet = require('StyleSheet'); var Text = require('Text'); var UIManager = require('UIManager'); var View = require('View'); var ScrollView = require('ScrollView'); var deprecatedPropType = require('deprecatedPropType'); var invariant = require('fbjs/lib/invariant'); var keyMirror = require('fbjs/lib/keyMirror'); var processDecelerationRate = require('processDecelerationRate'); var requireNativeComponent = require('requireNativeComponent'); var resolveAssetSource = require('resolveAssetSource'); var PropTypes = React.PropTypes; var RCTWebViewManager = require('NativeModules').WebViewManager; var BGWASH = 'rgba(255,255,255,0.8)'; var RCT_WEBVIEW_REF = 'webview'; var WebViewState = keyMirror({ IDLE: null, LOADING: null, ERROR: null, }); const NavigationType = keyMirror({ click: true, formsubmit: true, backforward: true, reload: true, formresubmit: true, other: true, }); const JSNavigationScheme = 'react-js-navigation'; type ErrorEvent = { domain: any, code: any, description: any, } type Event = Object; const DataDetectorTypes = [ 'phoneNumber', 'link', 'address', 'calendarEvent', 'none', 'all', ]; var defaultRenderLoading = () => ( <View style={styles.loadingView}> <ActivityIndicator /> </View> ); var defaultRenderError = (errorDomain, errorCode, errorDesc) => ( <View style={styles.errorContainer}> <Text style={styles.errorTextTitle}> Error loading page </Text> <Text style={styles.errorText}> {'Domain: ' + errorDomain} </Text> <Text style={styles.errorText}> {'Error Code: ' + errorCode} </Text> <Text style={styles.errorText}> {'Description: ' + errorDesc} </Text> </View> ); /** * `WebView` renders web content in a native view. * *``` * import React, { Component } from 'react'; * import { WebView } from 'react-native'; * * class MyWeb extends Component { * render() { * return ( * <WebView * source={{uri: 'https://github.com/facebook/react-native'}} * style={{marginTop: 20}} * /> * ); * } * } *``` * * You can use this component to navigate back and forth in the web view's * history and configure various properties for the web content. */ class WebView extends React.Component { static JSNavigationScheme = JSNavigationScheme; static NavigationType = NavigationType; static propTypes = { ...View.propTypes, html: deprecatedPropType( PropTypes.string, 'Use the `source` prop instead.' ), url: deprecatedPropType( PropTypes.string, 'Use the `source` prop instead.' ), /** * Loads static html or a uri (with optional headers) in the WebView. */ source: PropTypes.oneOfType([ PropTypes.shape({ /* * The URI to load in the `WebView`. Can be a local or remote file. */ uri: PropTypes.string, /* * The HTTP Method to use. Defaults to GET if not specified. * NOTE: On Android, only GET and POST are supported. */ method: PropTypes.string, /* * Additional HTTP headers to send with the request. * NOTE: On Android, this can only be used with GET requests. */ headers: PropTypes.object, /* * The HTTP body to send with the request. This must be a valid * UTF-8 string, and will be sent exactly as specified, with no * additional encoding (e.g. URL-escaping or base64) applied. * NOTE: On Android, this can only be used with POST requests. */ body: PropTypes.string, }), PropTypes.shape({ /* * A static HTML page to display in the WebView. */ html: PropTypes.string, /* * The base URL to be used for any relative links in the HTML. */ baseUrl: PropTypes.string, }), /* * Used internally by packager. */ PropTypes.number, ]), /** * Function that returns a view to show if there's an error. */ renderError: PropTypes.func, // view to show if there's an error /** * Function that returns a loading indicator. */ renderLoading: PropTypes.func, /** * Function that is invoked when the `WebView` has finished loading. */ onLoad: PropTypes.func, /** * Function that is invoked when the `WebView` load succeeds or fails. */ onLoadEnd: PropTypes.func, /** * Function that is invoked when the `WebView` starts loading. */ onLoadStart: PropTypes.func, /** * Function that is invoked when the `WebView` load fails. */ onError: PropTypes.func, /** * Boolean value that determines whether the web view bounces * when it reaches the edge of the content. The default value is `true`. * @platform ios */ bounces: PropTypes.bool, /** * A floating-point number that determines how quickly the scroll view * decelerates after the user lifts their finger. You may also use the * string shortcuts `"normal"` and `"fast"` which match the underlying iOS * settings for `UIScrollViewDecelerationRateNormal` and * `UIScrollViewDecelerationRateFast` respectively: * * - normal: 0.998 * - fast: 0.99 (the default for iOS web view) * @platform ios */ decelerationRate: ScrollView.propTypes.decelerationRate, /** * Boolean value that determines whether scrolling is enabled in the * `WebView`. The default value is `true`. * @platform ios */ scrollEnabled: PropTypes.bool, /** * Controls whether to adjust the content inset for web views that are * placed behind a navigation bar, tab bar, or toolbar. The default value * is `true`. */ automaticallyAdjustContentInsets: PropTypes.bool, /** * The amount by which the web view content is inset from the edges of * the scroll view. Defaults to {top: 0, left: 0, bottom: 0, right: 0}. */ contentInset: EdgeInsetsPropType, /** * Function that is invoked when the `WebView` loading starts or ends. */ onNavigationStateChange: PropTypes.func, /** * A function that is invoked when the webview calls `window.postMessage`. * Setting this property will inject a `postMessage` global into your * webview, but will still call pre-existing values of `postMessage`. * * `window.postMessage` accepts one argument, `data`, which will be * available on the event object, `event.nativeEvent.data`. `data` * must be a string. */ onMessage: PropTypes.func, /** * Boolean value that forces the `WebView` to show the loading view * on the first load. */ startInLoadingState: PropTypes.bool, /** * The style to apply to the `WebView`. */ style: View.propTypes.style, /** * Determines the types of data converted to clickable URLs in the web view’s content. * By default only phone numbers are detected. * * You can provide one type or an array of many types. * * Possible values for `dataDetectorTypes` are: * * - `'phoneNumber'` * - `'link'` * - `'address'` * - `'calendarEvent'` * - `'none'` * - `'all'` * * @platform ios */ dataDetectorTypes: PropTypes.oneOfType([ PropTypes.oneOf(DataDetectorTypes), PropTypes.arrayOf(PropTypes.oneOf(DataDetectorTypes)), ]), /** * Boolean value to enable JavaScript in the `WebView`. Used on Android only * as JavaScript is enabled by default on iOS. The default value is `true`. * @platform android */ javaScriptEnabled: PropTypes.bool, /** * Boolean value to control whether DOM Storage is enabled. Used only in * Android. * @platform android */ domStorageEnabled: PropTypes.bool, /** * Set this to provide JavaScript that will be injected into the web page * when the view loads. */ injectedJavaScript: PropTypes.string, /** * Sets the user-agent for the `WebView`. * @platform android */ userAgent: PropTypes.string, /** * Boolean that controls whether the web content is scaled to fit * the view and enables the user to change the scale. The default value * is `true`. */ scalesPageToFit: PropTypes.bool, /** * Function that allows custom handling of any web view requests. Return * `true` from the function to continue loading the request and `false` * to stop loading. * @platform ios */ onShouldStartLoadWithRequest: PropTypes.func, /** * Boolean that determines whether HTML5 videos play inline or use the * native full-screen controller. The default value is `false`. * * **NOTE** : In order for video to play inline, not only does this * property need to be set to `true`, but the video element in the HTML * document must also include the `webkit-playsinline` attribute. * @platform ios */ allowsInlineMediaPlayback: PropTypes.bool, /** * Boolean that determines whether HTML5 audio and video requires the user * to tap them before they start playing. The default value is `true`. */ mediaPlaybackRequiresUserAction: PropTypes.bool, }; state = { viewState: WebViewState.IDLE, lastErrorEvent: (null: ?ErrorEvent), startInLoadingState: true, }; componentWillMount() { if (this.props.startInLoadingState) { this.setState({viewState: WebViewState.LOADING}); } } render() { var otherView = null; if (this.state.viewState === WebViewState.LOADING) { otherView = (this.props.renderLoading || defaultRenderLoading)(); } else if (this.state.viewState === WebViewState.ERROR) { var errorEvent = this.state.lastErrorEvent; invariant( errorEvent != null, 'lastErrorEvent expected to be non-null' ); otherView = (this.props.renderError || defaultRenderError)( errorEvent.domain, errorEvent.code, errorEvent.description ); } else if (this.state.viewState !== WebViewState.IDLE) { console.error( 'RCTWebView invalid state encountered: ' + this.state.loading ); } var webViewStyles = [styles.container, styles.webView, this.props.style]; if (this.state.viewState === WebViewState.LOADING || this.state.viewState === WebViewState.ERROR) { // if we're in either LOADING or ERROR states, don't show the webView webViewStyles.push(styles.hidden); } var onShouldStartLoadWithRequest = this.props.onShouldStartLoadWithRequest && ((event: Event) => { var shouldStart = this.props.onShouldStartLoadWithRequest && this.props.onShouldStartLoadWithRequest(event.nativeEvent); RCTWebViewManager.startLoadWithResult(!!shouldStart, event.nativeEvent.lockIdentifier); }); var decelerationRate = processDecelerationRate(this.props.decelerationRate); var source = this.props.source || {}; if (this.props.html) { source.html = this.props.html; } else if (this.props.url) { source.uri = this.props.url; } const messagingEnabled = typeof this.props.onMessage === 'function'; var webView = <RCTWebView ref={RCT_WEBVIEW_REF} key="webViewKey" style={webViewStyles} source={resolveAssetSource(source)} injectedJavaScript={this.props.injectedJavaScript} bounces={this.props.bounces} scrollEnabled={this.props.scrollEnabled} decelerationRate={decelerationRate} contentInset={this.props.contentInset} automaticallyAdjustContentInsets={this.props.automaticallyAdjustContentInsets} onLoadingStart={this._onLoadingStart} onLoadingFinish={this._onLoadingFinish} onLoadingError={this._onLoadingError} messagingEnabled={messagingEnabled} onMessage={this._onMessage} onShouldStartLoadWithRequest={onShouldStartLoadWithRequest} scalesPageToFit={this.props.scalesPageToFit} allowsInlineMediaPlayback={this.props.allowsInlineMediaPlayback} mediaPlaybackRequiresUserAction={this.props.mediaPlaybackRequiresUserAction} dataDetectorTypes={this.props.dataDetectorTypes} />; return ( <View style={styles.container}> {webView} {otherView} </View> ); } /** * Go forward one page in the web view's history. */ goForward = () => { UIManager.dispatchViewManagerCommand( this.getWebViewHandle(), UIManager.RCTWebView.Commands.goForward, null ); }; /** * Go back one page in the web view's history. */ goBack = () => { UIManager.dispatchViewManagerCommand( this.getWebViewHandle(), UIManager.RCTWebView.Commands.goBack, null ); }; /** * Reloads the current page. */ reload = () => { this.setState({viewState: WebViewState.LOADING}); UIManager.dispatchViewManagerCommand( this.getWebViewHandle(), UIManager.RCTWebView.Commands.reload, null ); }; /** * Stop loading the current page. */ stopLoading = () => { UIManager.dispatchViewManagerCommand( this.getWebViewHandle(), UIManager.RCTWebView.Commands.stopLoading, null ); }; /** * Posts a message to the web view, which will emit a `message` event. * Accepts one argument, `data`, which must be a string. * * In your webview, you'll need to something like the following. * * ```js * document.addEventListener('message', e => { document.title = e.data; }); * ``` */ postMessage = (data) => { UIManager.dispatchViewManagerCommand( this.getWebViewHandle(), UIManager.RCTWebView.Commands.postMessage, [String(data)] ); }; /** * We return an event with a bunch of fields including: * url, title, loading, canGoBack, canGoForward */ _updateNavigationState = (event: Event) => { if (this.props.onNavigationStateChange) { this.props.onNavigationStateChange(event.nativeEvent); } }; /** * Returns the native `WebView` node. */ getWebViewHandle = (): any => { return ReactNative.findNodeHandle(this.refs[RCT_WEBVIEW_REF]); }; _onLoadingStart = (event: Event) => { var onLoadStart = this.props.onLoadStart; onLoadStart && onLoadStart(event); this._updateNavigationState(event); }; _onLoadingError = (event: Event) => { event.persist(); // persist this event because we need to store it var {onError, onLoadEnd} = this.props; onError && onError(event); onLoadEnd && onLoadEnd(event); console.warn('Encountered an error loading page', event.nativeEvent); this.setState({ lastErrorEvent: event.nativeEvent, viewState: WebViewState.ERROR }); }; _onLoadingFinish = (event: Event) => { var {onLoad, onLoadEnd} = this.props; onLoad && onLoad(event); onLoadEnd && onLoadEnd(event); this.setState({ viewState: WebViewState.IDLE, }); this._updateNavigationState(event); }; _onMessage = (event: Event) => { var {onMessage} = this.props; onMessage && onMessage(event); } } var RCTWebView = requireNativeComponent('RCTWebView', WebView, { nativeOnly: { onLoadingStart: true, onLoadingError: true, onLoadingFinish: true, onMessage: true, messagingEnabled: PropTypes.bool, }, }); var styles = StyleSheet.create({ container: { flex: 1, }, errorContainer: { flex: 1, justifyContent: 'center', alignItems: 'center', backgroundColor: BGWASH, }, errorText: { fontSize: 14, textAlign: 'center', marginBottom: 2, }, errorTextTitle: { fontSize: 15, fontWeight: '500', marginBottom: 10, }, hidden: { height: 0, flex: 0, // disable 'flex:1' when hiding a View }, loadingView: { backgroundColor: BGWASH, flex: 1, justifyContent: 'center', alignItems: 'center', height: 100, }, webView: { backgroundColor: '#ffffff', } }); module.exports = WebView;
sub-packs/themes/zealder-default-theme/src/components/BurgerMenu.js
Zealder/zealder-cms
// @flow import React from 'react'; // we really want to use "elastic" but it didn't work in IE11 // we could allow caller to pass Menu format as prop in future import { slide as Menu } from 'react-burger-menu'; export default class BurgerMenu extends React.Component { render() { return ( <div className="hidden-xl hidden-lg hidden-md" style={{zIndex: 10}}> <Menu right pageWrapId="page-wrap" isOpen={ false } customBurgerIcon={<div><i className="icon icon-fontello-menu-1"/></div>} outerContainerId="outer-container" > {this.props.children} </Menu> </div> ) } }
src/entypo/AlignLeft.js
cox-auto-kc/react-entypo
import React from 'react'; import EntypoIcon from '../EntypoIcon'; const iconClass = 'entypo-svgicon entypo--AlignLeft'; let EntypoAlignLeft = (props) => ( <EntypoIcon propClass={iconClass} {...props}> <path d="M6,10l3,3v-2h8V9H9V7L6,10z M4,2C3.447,2,3,2.047,3,2.6V17.4C3,17.951,3.447,18,4,18c0.552,0,1-0.049,1-0.6V2.6C5,2.047,4.552,2,4,2z"/> </EntypoIcon> ); export default EntypoAlignLeft;
src/components/header.js
psatyajeet/personal-site
import { Link } from 'gatsby' import PropTypes from 'prop-types' import React from 'react' const Header = ({ siteTitle }) => ( <div style={{ background: `rebeccapurple`, marginBottom: `1.45rem`, }} > <div style={{ margin: `0 auto`, maxWidth: 960, padding: `1.45rem 1.0875rem`, }} > <h1 style={{ margin: 0 }}> <Link to="/" style={{ color: `white`, textDecoration: `none`, }} > {siteTitle} </Link> </h1> </div> </div> ) Header.propTypes = { siteTitle: PropTypes.string, } Header.defaultProps = { siteTitle: ``, } export default Header
app/components/InputComponent.js
tjinauyeung/customization-requests-app
import React from 'react'; import ReactDOM from 'react-dom'; import _ from 'lodash'; class InputComponent extends React.Component { shouldComponentUpdate() { return false; } handleKeyPress(event) { this.props.minimizeForm(); let inputValue = ReactDOM.findDOMNode(this.refs.input).value.toLowerCase(); if (inputValue === 'all') { return this.props.fetchClientList(); } else { return this.props.searchClientList(inputValue); } } render() { return ( <input ref='input' onKeyPress={event => event.key === 'Enter' && event.preventDefault()} onKeyUp={_.debounce(event => this.handleKeyPress(event), 200)} /> ); } } export default InputComponent;
packages/react-scripts/fixtures/kitchensink/src/features/syntax/ArraySpread.js
Clearcover/web-build
/** * Copyright (c) 2015-present, Facebook, Inc. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ import React, { Component } from 'react'; import PropTypes from 'prop-types'; function load(users) { return [ { id: 1, name: '1' }, { id: 2, name: '2' }, { id: 3, name: '3' }, ...users, ]; } export default class extends Component { static propTypes = { onReady: PropTypes.func.isRequired, }; constructor(props) { super(props); this.state = { users: [] }; } async componentDidMount() { const users = load([{ id: 42, name: '42' }]); this.setState({ users }); } componentDidUpdate() { this.props.onReady(); } render() { return ( <div id="feature-array-spread"> {this.state.users.map(user => <div key={user.id}>{user.name}</div>)} </div> ); } }
src/parser/druid/restoration/modules/talents/Photosynthesis.js
sMteX/WoWAnalyzer
import React from 'react'; import StatisticBox from 'interface/others/StatisticBox'; import SPELLS from 'common/SPELLS'; import SpellIcon from 'common/SpellIcon'; import { formatPercentage } from 'common/format'; import Analyzer from 'parser/core/Analyzer'; import Combatants from 'parser/shared/modules/Combatants'; import calculateEffectiveHealing from 'parser/core/calculateEffectiveHealing'; import { HOTS_AFFECTED_BY_ESSENCE_OF_GHANIR } from '../../constants'; const PHOTOSYNTHESIS_HOT_INCREASE = 0.2; // Spring blossoms double dips, confirmed by Bastas const PHOTOSYNTHESIS_SB_INCREASE = 0.44; const BLOOM_BUFFER_MS = 100; /* While your Lifebloom is on yourself, your periodic heals heal 20% faster. While your Lifebloom is on an ally, your periodic heals on them have a 5% chance to cause it to bloom. */ class Photosynthesis extends Analyzer { static dependencies = { combatants: Combatants, }; lifebloomIncrease = 0; lastRealBloomTimestamp = null; // Counters for increased ticking rate of hots increasedRateRejuvenationHealing = 0; increasedRateWildGrowthHealing = 0; increasedRateCenarionWardHealing = 0; increasedRateCultivationHealing = 0; increasedRateLifebloomHealing = 0; increasedRateRegrowthHealing = 0; increasedRateTranqHealing = 0; increasedRateSpringBlossomsHealing = 0; increasedRateEffloHealing = 0; increasedRateGroveTendingHealing = 0; constructor(...args) { super(...args); this.active = this.selectedCombatant.hasTalent(SPELLS.PHOTOSYNTHESIS_TALENT.id); } on_byPlayer_cast(event) { if (event.ability.guid === SPELLS.LIFEBLOOM_HOT_HEAL.id) { this.lastRealBloomTimestamp = event.timestamp; } } on_byPlayer_removebuff(event){ if(event.ability.guid === SPELLS.LIFEBLOOM_HOT_HEAL.id) { this.lastRealBloomTimestamp = event.timestamp; } } randomProccs = 0; naturalProccs = 0; on_byPlayer_heal(event) { const spellId = event.ability.guid; // Lifebloom random bloom procc if(spellId === SPELLS.LIFEBLOOM_BLOOM_HEAL.id){ if(this.lastRealBloomTimestamp === null || (event.timestamp - this.lastRealBloomTimestamp) > BLOOM_BUFFER_MS) { this.lifebloomIncrease += event.amount; this.randomProccs++; } else { this.naturalProccs++; } } // Yes it actually buffs efflorescence, confirmed by Voulk and Bastas if(this.selectedCombatant.hasBuff(SPELLS.LIFEBLOOM_HOT_HEAL.id, null, 0, 0, this.selectedCombatant.sourceID) && (HOTS_AFFECTED_BY_ESSENCE_OF_GHANIR.includes(spellId) || spellId === SPELLS.EFFLORESCENCE_HEAL.id || spellId === SPELLS.SPRING_BLOSSOMS.id)) { switch (spellId) { case SPELLS.REJUVENATION.id: this.increasedRateRejuvenationHealing += calculateEffectiveHealing(event, PHOTOSYNTHESIS_HOT_INCREASE); break; case SPELLS.REJUVENATION_GERMINATION.id: this.increasedRateRejuvenationHealing += calculateEffectiveHealing(event, PHOTOSYNTHESIS_HOT_INCREASE); break; case SPELLS.WILD_GROWTH.id: this.increasedRateWildGrowthHealing += calculateEffectiveHealing(event, PHOTOSYNTHESIS_HOT_INCREASE); break; case SPELLS.CENARION_WARD_HEAL.id: this.increasedRateCenarionWardHealing += calculateEffectiveHealing(event, PHOTOSYNTHESIS_HOT_INCREASE); break; case SPELLS.CULTIVATION.id: this.increasedRateCultivationHealing += calculateEffectiveHealing(event, PHOTOSYNTHESIS_HOT_INCREASE); break; case SPELLS.LIFEBLOOM_HOT_HEAL.id: this.increasedRateLifebloomHealing += calculateEffectiveHealing(event, PHOTOSYNTHESIS_HOT_INCREASE); break; case SPELLS.SPRING_BLOSSOMS.id: this.increasedRateSpringBlossomsHealing += calculateEffectiveHealing(event, PHOTOSYNTHESIS_SB_INCREASE); break; case SPELLS.EFFLORESCENCE_HEAL.id: this.increasedRateEffloHealing += calculateEffectiveHealing(event, PHOTOSYNTHESIS_HOT_INCREASE); break; case SPELLS.GROVE_TENDING.id: this.increasedRateGroveTendingHealing += calculateEffectiveHealing(event, PHOTOSYNTHESIS_HOT_INCREASE); break; case SPELLS.REGROWTH.id: if (event.tick === true) { this.increasedRateRegrowthHealing += calculateEffectiveHealing(event, PHOTOSYNTHESIS_HOT_INCREASE); } break; case SPELLS.TRANQUILITY_HEAL.id: if (event.tick === true) { this.increasedRateTranqHealing += calculateEffectiveHealing(event, PHOTOSYNTHESIS_HOT_INCREASE); } break; default: console.error('Photosynthesis: Error, could not identify this object as a HoT: %o', event); } } } statistic() { const totalPercent = this.owner.getPercentageOfTotalHealingDone( this.increasedRateRejuvenationHealing + this.increasedRateWildGrowthHealing + this.increasedRateCenarionWardHealing + this.increasedRateCultivationHealing + this.increasedRateLifebloomHealing + this.increasedRateRegrowthHealing + this.increasedRateTranqHealing + this.increasedRateSpringBlossomsHealing + this.increasedRateEffloHealing + this.increasedRateGroveTendingHealing + this.lifebloomIncrease); const sourceID = this.selectedCombatant._combatantInfo.sourceID; const selfUptime = this.selectedCombatant.getBuffUptime(SPELLS.LIFEBLOOM_HOT_HEAL.id, sourceID); const totalUptime = Object.keys(this.combatants.players) .map(key => this.combatants.players[key]) .reduce((uptime, player) => uptime + player.getBuffUptime(SPELLS.LIFEBLOOM_HOT_HEAL.id), sourceID); return ( <StatisticBox icon={<SpellIcon id={SPELLS.PHOTOSYNTHESIS_TALENT.id} />} value={`${formatPercentage(totalPercent)} %`} label="Photosynthesis" tooltip={( <> Healing contribution <ul> <li>Rejuvenation: <strong>{formatPercentage(this.owner.getPercentageOfTotalHealingDone(this.increasedRateRejuvenationHealing))} %</strong></li> <li>Wild Growth: <strong>{formatPercentage(this.owner.getPercentageOfTotalHealingDone(this.increasedRateWildGrowthHealing))} %</strong></li> <li>Cenarion Ward: <strong>{formatPercentage(this.owner.getPercentageOfTotalHealingDone(this.increasedRateCenarionWardHealing))} %</strong></li> <li>Cultivation: <strong>{formatPercentage(this.owner.getPercentageOfTotalHealingDone(this.increasedRateCultivationHealing))} %</strong></li> <li>Lifebloom HoT: <strong>{formatPercentage(this.owner.getPercentageOfTotalHealingDone(this.increasedRateLifebloomHealing))} %</strong></li> <li>Regrowth HoT: <strong>{formatPercentage(this.owner.getPercentageOfTotalHealingDone(this.increasedRateRegrowthHealing))} %</strong></li> <li>Tranquility HoT: <strong>{formatPercentage(this.owner.getPercentageOfTotalHealingDone(this.increasedRateTranqHealing))} %</strong></li> <li>Spring Blossoms: <strong>{formatPercentage(this.owner.getPercentageOfTotalHealingDone(this.increasedRateSpringBlossomsHealing))} %</strong></li> <li>Efflorescence: <strong>{formatPercentage(this.owner.getPercentageOfTotalHealingDone(this.increasedRateEffloHealing))} %</strong></li> <li>Grove Tending: <strong>{formatPercentage(this.owner.getPercentageOfTotalHealingDone(this.increasedRateGroveTendingHealing))} %</strong></li> <hr /> <li>Total HoT increase part: <strong>{formatPercentage(totalPercent-this.owner.getPercentageOfTotalHealingDone(this.lifebloomIncrease))} %</strong></li> <li>Lifebloom random bloom: <strong>{formatPercentage(this.owner.getPercentageOfTotalHealingDone(this.lifebloomIncrease))} %</strong> (Random proccs: {this.randomProccs}, Natural proccs: {this.naturalProccs})</li> </ul> Lifebloom uptime <ul> <li>On Self: <strong>{formatPercentage(selfUptime/ this.owner.fightDuration)} %</strong></li> <li>On Others: <strong>{formatPercentage((totalUptime - selfUptime) / this.owner.fightDuration)} %</strong></li> </ul> </> )} /> ); } } export default Photosynthesis;
services/client/public/js/auth/register.js
cpg1111/demo-maestro-app
'use strict'; import React from 'react' export class Register extends React.Components { constructor(props){ super(props); this.state = {}; } render(){ return ( <div> <form> <input type="text" name="name" placeholder="name"/> <input type="email" name="email" placeholder="email"/> <input type="password" name="password" placeholder="password"/> <input type="password" name="confirm" placeholder="confirm password"/> <input type="submit" name="submit" value="submit"/> </form> </div> ); } }
examples/full-example/src/isomorphic/variations/bucket_D/components/dropdown.js
yahoo/mendel
/* Copyright 2015, Yahoo Inc. Copyrights licensed under the MIT License. See the accompanying LICENSE file for terms. */ import React from 'react'; class Dropdown extends React.Component { render() { return ( <ul className="dropdown bucket_D"> <li>Option D one</li> <li>Option D two</li> <li>Option D three</li> </ul> ); } } export default Dropdown;
client/src/components/formHelpers/Form.js
HKuz/FreeCodeCamp
import React from 'react'; import PropTypes from 'prop-types'; import { reduxForm } from 'redux-form'; import { FormFields, BlockSaveButton, BlockSaveWrapper } from './'; const propTypes = { buttonText: PropTypes.string, enableSubmit: PropTypes.bool, errors: PropTypes.object, fields: PropTypes.objectOf( PropTypes.shape({ name: PropTypes.string.isRequired, onChange: PropTypes.func.isRequired, value: PropTypes.string.isRequired }) ), formFields: PropTypes.arrayOf(PropTypes.string).isRequired, handleSubmit: PropTypes.func, hideButton: PropTypes.bool, id: PropTypes.string.isRequired, initialValues: PropTypes.object, options: PropTypes.shape({ ignored: PropTypes.arrayOf(PropTypes.string), required: PropTypes.arrayOf(PropTypes.string), types: PropTypes.objectOf(PropTypes.string) }), submit: PropTypes.func.isRequired }; export function DynamicForm({ // redux-form errors, fields, handleSubmit, fields: { _meta: { allPristine } }, // HOC buttonText, enableSubmit, hideButton, id, options, submit }) { return ( <form id={`dynamic-${id}`} onSubmit={handleSubmit(submit)} style={{ width: '100%' }} > <FormFields errors={errors} fields={fields} options={options} /> <BlockSaveWrapper> {hideButton ? null : ( <BlockSaveButton disabled={ (allPristine && !enableSubmit) || !!Object.keys(errors).filter(key => errors[key]).length } > {buttonText ? buttonText : null} </BlockSaveButton> )} </BlockSaveWrapper> </form> ); } DynamicForm.displayName = 'DynamicForm'; DynamicForm.propTypes = propTypes; const DynamicFormWithRedux = reduxForm()(DynamicForm); export default function Form(props) { return ( <DynamicFormWithRedux {...props} fields={props.formFields} form={props.id} /> ); } Form.propTypes = propTypes;
app/components/DownloadedGames/UserGameList.js
cdiezmoran/playgrounds-desktop
// @flow import React, { Component } from 'react'; import type { UserGame } from '../../utils/globalTypes'; import UserGameListItem from './UserGameListItem'; class UserGameList extends Component { props: { games: UserGame[] } render() { const { games } = this.props; const items = games.map((game) => <UserGameListItem game={game} key={game._id} /> ); return ( <div className="user-game-list row"> {items} </div> ); } } export default UserGameList;
src/components/Product/ProductList.js
lawenliu/ReactDemo
import React from 'react' import { Link } from 'react-router' import classes from 'styles/Product.less' const ProductList = React.createClass({ propTypes: { products: React.PropTypes.object.isRequired }, getInitialState () { return { page: 0 } }, render () { const productListMarkup = this.props.products.valueSeq().map((product, id) => { return ( <tr key={id}> <td>{product.ProductID}</td> <td><Link to={`/product/${product.ProductID}`}>{product.ProductName}</Link></td> <td>{product.TypeID}</td> <td>{product.Producer}</td> </tr> ) }) return ( <div className={classes['panel-body']}> <table className={classes.table}> <thead> <tr> <th>ID</th><th>Name</th><th>Type ID</th><th>Producer</th> </tr> </thead> <tbody> {productListMarkup} </tbody> </table> </div> ) } }) export default ProductList
modules/Navigation.js
wmyers/react-router
import React from 'react'; var { object } = React.PropTypes; /** * A mixin for components that modify the URL. * * Example: * * import { Navigation } from 'react-router'; * * var MyLink = React.createClass({ * mixins: [ Navigation ], * handleClick(event) { * event.preventDefault(); * this.transitionTo('aRoute', { the: 'params' }, { the: 'query' }); * }, * render() { * return ( * <a onClick={this.handleClick}>Click me!</a> * ); * } * }); */ var Navigation = { contextTypes: { router: object.isRequired } }; var RouterNavigationMethods = [ 'makePath', 'makeHref', 'transitionTo', 'replaceWith', 'go', 'goBack', 'goForward' ]; RouterNavigationMethods.forEach(function (method) { Navigation[method] = function () { var router = this.context.router; return router[method].apply(router, arguments); }; }); export default Navigation;
components/travelers-svg.js
WanderlandTravelers/wanderlandtravelers.github.io
import React from 'react' export default class TravelersSVG extends React.Component { render () { return ( <svg id="travelers" viewBox="0 0 154.63471 38.800361"> <path d="m 27.791579,5.3452446 c -1.666669,0 -3.28125,0.039062 -4.84375,0.1171874 -1.5625,0.078125 -3.027344,0.2213542 -4.394532,0.4296876 -1.367187,0.2083333 -2.623698,0.5013021 -3.769531,0.8789062 -1.132813,0.3645833 -2.109375,0.8333333 -2.929688,1.40625 -0.807291,0.5729167 -1.438802,1.2695314 -1.8945311,2.0898442 -0.4427083,0.807292 -0.6640625,1.757812 -0.6640625,2.851562 0.026042,0.46875 0.15625,0.885417 0.390625,1.25 0.1953125,0.3125 0.5078126,0.598959 0.9374996,0.859375 0.429688,0.260417 1.035157,0.390625 1.816407,0.390625 0.78125,0 1.380208,-0.123697 1.796875,-0.371093 0.429687,-0.260418 0.742187,-0.540365 0.9375,-0.839844 0.195314,-0.3125 0.305991,-0.598959 0.332031,-0.859375 0.03906,-0.260418 0.05859,-0.403648 0.05859,-0.429688 0,-0.494792 0.123698,-0.924479 0.371094,-1.289062 0.260416,-0.364583 0.605468,-0.677083 1.035156,-0.9375 0.442708,-0.260417 0.950521,-0.47526 1.523437,-0.644531 0.585938,-0.169271 1.210938,-0.3059895 1.875001,-0.4101575 0.677081,-0.117186 1.367187,-0.208332 2.070312,-0.2734369 0.716144,-0.065104 1.419269,-0.123698 2.109375,-0.1757813 -0.794273,2.4739597 -1.536459,4.7200527 -2.226562,6.7382817 -0.677086,2.018229 -1.308594,3.867187 -1.894532,5.546875 -0.585937,1.666666 -1.119791,3.196614 -1.601562,4.589843 -0.481771,1.39323 -0.911459,2.714844 -1.289063,3.964844 -0.377604,1.23698 -0.709635,2.428386 -0.996094,3.574219 -0.273437,1.145833 -0.494792,2.311198 -0.664062,3.496094 -0.07813,0.299479 -0.117188,0.572916 -0.117188,0.820312 0,0.78125 0.240886,1.347656 0.722657,1.699219 0.481771,0.351562 1.09375,0.527344 1.835937,0.527344 0.247396,0 0.514323,-0.07813 0.800781,-0.234375 0.28646,-0.143229 0.559897,-0.351562 0.820313,-0.625 0.273438,-0.273438 0.514322,-0.592448 0.722657,-0.957031 0.221351,-0.377604 0.384112,-0.787761 0.488281,-1.230469 0.247394,-0.963542 0.559894,-2.115885 0.9375,-3.457031 0.390625,-1.341147 0.80729,-2.79948 1.25,-4.375 0.442706,-1.588543 0.898437,-3.248698 1.367187,-4.980469 0.481769,-1.744792 0.9375,-3.489583 1.367188,-5.234375 0.442706,-1.757812 0.846353,-3.476562 1.210937,-5.15625 0.364584,-1.679688 0.664063,-3.248698 0.898438,-4.7070317 1.328125,0.065104 2.617187,0.1627608 3.867187,0.2929682 1.25,0.130208 2.460938,0.260418 3.632813,0.3906255 1.184896,0.13021 2.317706,0.247396 3.398437,0.351563 1.09375,0.104167 2.141925,0.15625 3.144531,0.15625 0.28646,0 0.559896,-0.05859 0.820313,-0.175781 0.260415,-0.130208 0.488281,-0.299479 0.683594,-0.5078135 0.195312,-0.208333 0.351562,-0.4361975 0.46875,-0.6835935 0.117187,-0.2473957 0.175781,-0.501302 0.175781,-0.7617187 0,-0.4166667 -0.13021,-0.7942708 -0.390625,-1.1328125 C 43.735594,6.9793591 43.299391,6.7449841 42.674391,6.6147758 39.979079,6.133005 37.387932,5.8009738 34.900954,5.618682 32.426994,5.4363904 30.057204,5.3452446 27.791579,5.3452446 Z M 112.32354,2.5448998 c -0.82031,0 -1.6276,0.2473958 -2.42187,0.7421875 -0.79427,0.4947917 -1.55599,1.1783854 -2.28516,2.0507813 -0.72917,0.859375 -1.42578,1.875 -2.08984,3.0468749 -0.66406,1.158854 -1.28255,2.4088535 -1.85547,3.7499995 -0.5599,1.341146 -1.06771,2.740886 -1.52343,4.199218 -0.44271,1.458335 -0.82682,2.910157 -1.15235,4.355469 -0.32552,1.445312 -0.57292,2.851562 -0.74219,4.21875 -0.16927,1.354167 -0.253901,2.610677 -0.253901,3.769531 0,1.188836 0.0987,2.325426 0.251951,3.433594 -0.24846,0.206401 -0.497866,0.412807 -0.779297,0.628906 -0.729168,0.546876 -1.503906,1.054688 -2.324219,1.523438 -0.820312,0.46875 -1.666668,0.859375 -2.539062,1.171875 -0.859375,0.3125 -1.679688,0.46875 -2.460938,0.46875 -0.247394,0 -0.481769,-0.02603 -0.703125,-0.07813 -0.208332,-0.05208 -0.410156,-0.14323 -0.605468,-0.273438 -0.195313,-0.130208 -0.390625,-0.3125 -0.585938,-0.546874 -0.182293,-0.234376 -0.371094,-0.527345 -0.566406,-0.878907 1.132812,-0.3125 2.180988,-0.748698 3.144531,-1.308593 0.976563,-0.559897 1.816406,-1.197917 2.519531,-1.914063 0.703125,-0.716145 1.25,-1.477864 1.640625,-2.285156 0.403645,-0.807292 0.605469,-1.614583 0.605469,-2.421875 0,-0.742188 -0.130208,-1.41276 -0.390625,-2.011719 -0.260418,-0.598958 -0.625,-1.106772 -1.09375,-1.523437 -0.45573,-0.429688 -0.996094,-0.761719 -1.621094,-0.996094 -0.625,-0.234375 -1.302082,-0.351563 -2.03125,-0.351563 -0.898437,0 -1.71875,0.162761 -2.460937,0.488281 -0.729169,0.3125 -1.39323,0.742188 -1.992188,1.289063 -0.585937,0.533855 -1.100262,1.158855 -1.542968,1.875 -0.442709,0.703125 -0.813802,1.445312 -1.113282,2.226563 -0.286457,0.78125 -0.501301,1.582031 -0.644531,2.402343 -0.14323,0.807292 -0.214844,1.575521 -0.214844,2.304688 0,0.02103 0.0018,0.0415 0.002,0.0625 -0.390019,0.210641 -0.796875,0.407812 -1.232422,0.582031 -0.507813,0.195313 -0.957032,0.292969 -1.347657,0.292969 -0.533855,0 -0.970052,-0.07162 -1.308593,-0.214844 -0.338544,-0.143229 -0.605469,-0.332031 -0.800782,-0.566406 -0.195312,-0.247396 -0.332031,-0.520834 -0.410156,-0.820313 -0.07813,-0.299479 -0.117187,-0.605469 -0.117187,-0.917968 0,-0.29948 0.01953,-0.585937 0.05859,-0.859376 0.05208,-0.286457 0.110675,-0.540364 0.175782,-0.761718 0.0651,-0.247396 0.143229,-0.488283 0.234375,-0.722656 0.286456,-0.638021 0.546875,-1.191407 0.78125,-1.660157 0.247394,-0.46875 0.455729,-0.891926 0.625,-1.269531 0.182291,-0.390625 0.31901,-0.748698 0.410156,-1.074219 0.104167,-0.325521 0.15625,-0.670573 0.15625,-1.035156 0,-0.481771 -0.227864,-0.872396 -0.683594,-1.171875 -0.45573,-0.3125 -1.061199,-0.46875 -1.816406,-0.46875 -0.286458,0 -0.559895,0.03906 -0.820313,0.117188 -0.247394,0.07812 -0.475262,0.18229 -0.683593,0.3125 -0.208333,0.117187 -0.377606,0.260416 -0.507813,0.429687 -0.130212,0.169271 -0.214846,0.345052 -0.253906,0.527344 l -5.136719,12.246093 -0.273437,0.01953 0.761718,-12.363282 c -0.01302,-0.338542 -0.14323,-0.63802 -0.390625,-0.898437 -0.234375,-0.260417 -0.572917,-0.390625 -1.015625,-0.390625 -0.0651,0 -0.130206,0.0065 -0.195312,0.01953 -0.05208,0 -0.110675,0.0065 -0.175781,0.01953 l -2.34375,0.371094 c -0.416669,0.0651 -0.690106,0.475261 -0.820313,1.230469 -0.117187,0.742188 -0.175781,1.783855 -0.175781,3.125 0,0.520833 0.0065,1.028645 0.01953,1.523437 0.01302,0.494793 0.03255,1.035156 0.05859,1.621094 0.03906,0.585938 0.07813,1.24349 0.117187,1.972656 0.02341,0.429139 0.0469,0.998837 0.07031,1.521485 -0.173467,0.203444 -0.34702,0.417305 -0.519531,0.607422 -0.273438,0.299479 -0.566407,0.592448 -0.878907,0.878906 -0.29948,0.273438 -0.605468,0.520834 -0.917968,0.742187 -0.299481,0.221354 -0.59896,0.403645 -0.898438,0.546876 -0.29948,0.130208 -0.585937,0.195312 -0.859375,0.195312 -0.364584,0 -0.605469,-0.169271 -0.722656,-0.507812 -0.104167,-0.351563 -0.15625,-0.833334 -0.15625,-1.445313 0,-0.716145 0.0651,-1.471354 0.195312,-2.265625 0.13021,-0.807291 0.273438,-1.608073 0.429688,-2.402344 0.15625,-0.807292 0.299478,-1.588542 0.429687,-2.34375 0.13021,-0.768229 0.195313,-1.464844 0.195313,-2.089844 0,-0.403645 -0.03906,-0.722656 -0.117188,-0.957031 -0.0651,-0.234375 -0.16276,-0.416667 -0.292968,-0.546875 -0.13021,-0.130211 -0.279948,-0.214846 -0.449219,-0.253906 -0.169272,-0.03906 -0.351563,-0.05859 -0.546875,-0.05859 -0.143229,0 -0.292969,0.0065 -0.449219,0.01953 l -0.429687,0 c -0.169272,-2e-6 -0.338541,-0.0065 -0.507813,-0.01953 -0.15625,-0.02604 -0.3125,-0.07161 -0.46875,-0.136718 -0.15625,-0.0651 -0.286459,-0.169271 -0.390625,-0.3125 -0.104166,-0.14323 -0.214844,-0.286459 -0.332031,-0.429688 -0.104167,-0.15625 -0.240885,-0.292969 -0.410156,-0.410156 -0.169272,-0.117188 -0.403647,-0.175781 -0.703125,-0.175782 -0.898438,0 -1.783854,0.195313 -2.65625,0.585938 -0.859375,0.377605 -1.679688,0.891927 -2.460938,1.542969 -0.78125,0.651042 -1.503906,1.412761 -2.167969,2.285156 -0.65104,0.872396 -1.217447,1.803385 -1.699218,2.792969 -0.107158,0.217212 -0.190258,0.440367 -0.28711,0.660156 -0.306857,0.159437 -0.625717,0.312636 -0.96289,0.453125 -0.625,0.260417 -1.230469,0.390625 -1.816407,0.390625 -0.208334,0 -0.410156,-0.03906 -0.605468,-0.117188 -0.182292,-0.07813 -0.351563,-0.208334 -0.507813,-0.390624 -0.143228,-0.195313 -0.260416,-0.449219 -0.351562,-0.761719 -0.09115,-0.3125 -0.136719,-0.703125 -0.136719,-1.171875 0,-0.273438 0.03254,-0.611979 0.09766,-1.015625 0.0651,-0.416667 0.136719,-0.839844 0.214844,-1.269531 0.07812,-0.44271 0.149737,-0.859377 0.214844,-1.25 0.06511,-0.403647 0.09766,-0.716146 0.09766,-0.9375 0,-0.28646 -0.05208,-0.540365 -0.15625,-0.761719 -0.104167,-0.234375 -0.247397,-0.429688 -0.429688,-0.585938 -0.169271,-0.15625 -0.371093,-0.273437 -0.605468,-0.351562 -0.234375,-0.09115 -0.47526,-0.136719 -0.722657,-0.136719 -0.716146,0 -1.347656,0.195312 -1.894531,0.585938 -0.546875,0.377603 -1.035156,0.846354 -1.464844,1.40625 -0.429687,0.559895 -0.807291,1.165364 -1.132812,1.816406 -0.325522,0.63802 -0.618491,1.217448 -0.878906,1.738281 l -0.214844,0 C 38.09833,26.177707 38.08531,25.507134 38.08531,24.83005 l 0,-1.757812 c 0,-0.403646 -0.01302,-0.722656 -0.03906,-0.957032 -0.01302,-0.234374 -0.0651,-0.410156 -0.15625,-0.527343 -0.09115,-0.13021 -0.234375,-0.208335 -0.429688,-0.234375 -0.18229,-0.03906 -0.442709,-0.05859 -0.78125,-0.05859 -0.29948,0 -0.553387,0.01953 -0.761718,0.05859 -0.195313,0.02604 -0.364585,0.09115 -0.507813,0.195312 -0.130209,0.09115 -0.247397,0.221354 -0.351562,0.390625 -0.104169,0.169271 -0.208335,0.397136 -0.3125,0.683594 -0.169272,0.429688 -0.338541,0.976563 -0.507813,1.640625 -0.169272,0.664063 -0.338541,1.393229 -0.507812,2.1875 -0.169272,0.794271 -0.332032,1.634115 -0.488282,2.519531 -0.14323,0.872396 -0.273437,1.731771 -0.390625,2.578125 -0.104165,0.846354 -0.1888,1.653646 -0.253906,2.421875 -0.06511,0.755208 -0.09766,1.419271 -0.09766,1.992188 0,0.520833 0.02604,1.028645 0.07813,1.523437 0.0651,0.481771 0.182291,0.917969 0.351562,1.308594 0.182291,0.377605 0.436197,0.683594 0.761719,0.917969 0.325522,0.221354 0.755209,0.332031 1.289063,0.332031 0.234375,0 0.449218,-0.03906 0.644531,-0.117188 0.195312,-0.09115 0.377603,-0.240885 0.546875,-0.449218 0.169269,-0.208334 0.332031,-0.475261 0.488281,-0.800782 0.169272,-0.33854 0.345053,-0.761719 0.527344,-1.269531 l 3.496094,-9.746093 0.3125,0 c 0.104165,0.820312 0.240884,1.634114 0.410156,2.441406 0.169271,0.79427 0.429687,1.516927 0.78125,2.167968 0.351562,0.638022 0.826822,1.158856 1.425781,1.5625 0.598959,0.390626 1.386719,0.585938 2.363281,0.585938 0.546875,0 1.080729,-0.07813 1.601563,-0.234375 0.193533,-0.06136 0.379719,-0.131252 0.566406,-0.201172 -0.01027,0.191196 -0.01953,0.383026 -0.01953,0.572266 0,0.859375 0.136719,1.634115 0.410156,2.324219 0.273438,0.677083 0.638022,1.25651 1.09375,1.738281 0.455728,0.46875 0.976563,0.833333 1.5625,1.09375 0.598959,0.247396 1.210938,0.371093 1.835938,0.371093 0.585937,0 1.171875,-0.09766 1.757812,-0.292968 0.585938,-0.195313 1.145834,-0.442709 1.679688,-0.742188 0.546875,-0.3125 1.048177,-0.657551 1.503906,-1.035156 0.455728,-0.377604 0.839844,-0.748698 1.152344,-1.113281 0.416665,1.054687 0.911458,1.861979 1.484375,2.421875 0.572915,0.546875 1.289062,0.820312 2.148437,0.820312 0.716146,0 1.43229,-0.175781 2.148438,-0.527344 0.716144,-0.351562 1.386718,-0.781249 2.011718,-1.289062 0.337877,-0.274525 0.653301,-0.55791 0.953125,-0.847656 0.05805,0.256722 0.119439,0.510658 0.199219,0.75 0.208332,0.585937 0.520832,1.074218 0.9375,1.464844 0.416667,0.377603 1.002604,0.566406 1.757813,0.566406 0.455729,0 0.9375,-0.208334 1.445312,-0.625 0.520832,-0.429688 1.035156,-0.976563 1.542969,-1.640625 0.520831,-0.664063 1.022136,-1.406251 1.503906,-2.226563 0.48177,-0.820312 0.911457,-1.621094 1.289063,-2.402344 0.01302,0.494792 0.123698,0.970052 0.332031,1.425782 0.221354,0.455729 0.520832,0.865885 0.898437,1.230468 0.390625,0.364585 0.859375,0.657553 1.40625,0.878907 0.559895,0.208333 1.191407,0.3125 1.894532,0.3125 0.833331,0 1.705729,-0.162762 2.617187,-0.488281 0.561701,-0.197782 1.106865,-0.449019 1.644531,-0.728516 0.270364,0.580247 0.596845,1.119552 0.992188,1.607422 0.611979,0.742187 1.373698,1.334634 2.285156,1.777344 0.92448,0.442708 1.998699,0.664062 3.222656,0.664062 0.78125,0 1.54948,-0.08464 2.304688,-0.253906 0.768229,-0.182292 1.503906,-0.416667 2.207031,-0.703125 0.716144,-0.29948 1.39323,-0.638021 2.03125,-1.015625 0.651042,-0.377604 1.256512,-0.761719 1.816407,-1.152344 0.35288,-0.249514 0.69886,-0.511245 1.04102,-0.78125 0.0624,0.163905 0.12291,0.331729 0.18945,0.488281 0.45573,1.041667 0.98308,1.875 1.58203,2.5 0.61198,0.611979 1.26954,0.917969 1.97265,0.917969 0.44271,0 0.91797,-0.05859 1.42578,-0.175781 0.50782,-0.130208 1.02865,-0.299479 1.5625,-0.507813 0.53386,-0.208333 1.0612,-0.442708 1.58203,-0.703125 0.53386,-0.273438 1.04818,-0.546875 1.54297,-0.820312 0.46952,-0.269836 0.94203,-0.566038 1.41602,-0.867188 0.1425,0.218291 0.29497,0.43042 0.45898,0.632813 0.61198,0.742187 1.3737,1.334634 2.28516,1.777344 0.92448,0.442708 1.9987,0.664062 3.22266,0.664062 0.78125,0 1.54948,-0.08464 2.30468,-0.253906 0.76823,-0.182292 1.50391,-0.416667 2.20703,-0.703125 0.71615,-0.29948 1.39323,-0.638021 2.03125,-1.015625 0.65104,-0.377604 1.25651,-0.761719 1.81641,-1.152344 0.15599,-0.110298 0.30704,-0.229448 0.46094,-0.34375 0.0125,0.304905 0.0158,0.614546 0.0469,0.910156 0.0651,0.481771 0.1823,0.917969 0.35157,1.308594 0.18229,0.377605 0.43619,0.683594 0.76171,0.917969 0.32552,0.221354 0.75521,0.332031 1.28907,0.332031 0.23438,0 0.44921,-0.03906 0.64453,-0.117188 0.1953,-0.09115 0.3776,-0.240885 0.54687,-0.449218 0.16928,-0.208334 0.33204,-0.475261 0.48828,-0.800782 0.16928,-0.33854 0.34505,-0.761719 0.52735,-1.269531 l 3.49609,-9.746093 0.3125,0 c 0.10417,0.820312 0.24088,1.634114 0.41016,2.441406 0.16926,0.79427 0.42968,1.516927 0.78125,2.167968 0.35156,0.638022 0.82682,1.158856 1.42578,1.5625 0.59895,0.390626 1.38671,0.585938 2.36328,0.585938 0.36794,0 0.72782,-0.04841 1.08399,-0.119141 -0.1155,0.230178 -0.18555,0.475463 -0.18555,0.744141 0,0.351563 0.0391,0.625 0.11719,0.820312 0.0781,0.182292 0.18229,0.319011 0.3125,0.410157 0.13021,0.07813 0.28646,0.123699 0.46875,0.136719 0.18229,0.01302 0.3776,0.01953 0.58593,0.01953 0.16928,0 0.33855,-0.0065 0.50782,-0.01953 0.18229,-0.01303 0.36458,-0.03907 0.54687,-0.07813 0.0651,0.703126 0.25391,1.302083 0.56641,1.796876 0.3125,0.49479 0.71614,0.898437 1.21093,1.210937 0.50782,0.299479 1.09376,0.520832 1.75782,0.664063 0.66406,0.143228 1.38021,0.214843 2.14843,0.214843 1.06771,0 2.19401,-0.117187 3.37891,-0.351562 1.19791,-0.247396 2.3763,-0.579427 3.53516,-0.996094 1.17188,-0.416667 2.28515,-0.898437 3.33984,-1.445313 1.06771,-0.546874 2.00521,-1.132812 2.8125,-1.757812 l -0.0195,-4.375 c -0.625,0.46875 -1.25,0.872395 -1.875,1.210938 -0.61198,0.325519 -1.21094,0.625 -1.79688,0.898437 -0.58593,0.273438 -1.15233,0.540365 -1.69921,0.800781 -0.53386,0.247396 -1.03516,0.527344 -1.50391,0.839844 0,-0.833333 -0.0325,-1.55599 -0.0977,-2.167969 -0.0521,-0.611979 -0.13021,-1.152344 -0.23437,-1.621093 -0.0911,-0.46875 -0.1888,-0.878907 -0.29297,-1.230469 -0.10417,-0.364584 -0.20833,-0.703125 -0.3125,-1.015625 -0.0911,-0.325521 -0.16924,-0.651042 -0.23438,-0.976563 -0.0521,-0.338542 -0.0781,-0.709635 -0.0781,-1.113281 0.0391,-0.143229 0.1888,-0.358073 0.44922,-0.644531 0.27343,-0.29948 0.55989,-0.625001 0.85937,-0.976563 0.29948,-0.351562 0.57292,-0.716146 0.82032,-1.09375 0.2474,-0.377604 0.37109,-0.722656 0.37109,-1.035156 0,-0.15625 -0.013,-0.338542 -0.0391,-0.546875 -0.026,-0.221354 -0.11719,-0.429687 -0.27344,-0.625 -0.15625,-0.195312 -0.40365,-0.358073 -0.74219,-0.488281 -0.33854,-0.14323 -0.82031,-0.214844 -1.44531,-0.214844 -0.37761,0 -0.72266,0.05859 -1.03516,0.175781 -0.29948,0.104167 -0.57943,0.247396 -0.83984,0.429688 -0.2474,0.16927 -0.47526,0.364583 -0.68359,0.585937 -0.20834,0.221354 -0.39714,0.449219 -0.56641,0.683594 -0.83333,1.041667 -1.51042,1.914062 -2.03125,2.617188 -0.52083,0.690103 -0.96354,1.276041 -1.32813,1.757812 -0.36458,0.481771 -0.68359,0.898438 -0.95703,1.25 -0.23385,0.315702 -0.5027,0.631564 -0.78906,0.947266 l 0.14453,-2.25586 c -0.58594,0.481771 -1.18489,0.911459 -1.79687,1.289063 -0.52084,0.32552 -1.09375,0.618489 -1.71875,0.878906 -0.625,0.260417 -1.23048,0.390625 -1.81641,0.390625 -0.20833,0 -0.41015,-0.03906 -0.60547,-0.117188 -0.18229,-0.07813 -0.35156,-0.208334 -0.50781,-0.390624 -0.14323,-0.195313 -0.26042,-0.449219 -0.35156,-0.761719 -0.0911,-0.3125 -0.13672,-0.703125 -0.13672,-1.171875 0,-0.273438 0.0326,-0.611979 0.0976,-1.015625 0.0651,-0.416667 0.13672,-0.839844 0.21485,-1.269531 0.0781,-0.44271 0.14971,-0.859376 0.21484,-1.25 0.0651,-0.403647 0.0977,-0.716146 0.0977,-0.9375 0,-0.28646 -0.0521,-0.540365 -0.15625,-0.761719 -0.10417,-0.234375 -0.2474,-0.429688 -0.42969,-0.585938 -0.16927,-0.15625 -0.37109,-0.273437 -0.60547,-0.351562 -0.23437,-0.09115 -0.47525,-0.136719 -0.72265,-0.136719 -0.71615,0 -1.34766,0.195312 -1.89454,0.585938 -0.54687,0.377603 -1.03515,0.846354 -1.46484,1.40625 -0.42969,0.559895 -0.80729,1.165364 -1.13281,1.816406 -0.32553,0.63802 -0.61849,1.217448 -0.87891,1.738281 l -0.21484,0 c -0.0261,-0.664062 -0.0391,-1.334635 -0.0391,-2.011719 l 0,-1.757812 c 0,-0.403646 -0.013,-0.722656 -0.0391,-0.957032 -0.013,-0.234374 -0.0651,-0.410156 -0.15625,-0.527343 -0.0911,-0.13021 -0.23437,-0.208335 -0.42968,-0.234375 -0.18229,-0.03906 -0.44271,-0.05859 -0.78125,-0.05859 -0.29948,0 -0.55339,0.01953 -0.76172,0.05859 -0.19531,0.02604 -0.36458,0.09115 -0.50782,0.195312 -0.1302,0.09115 -0.24739,0.221354 -0.35156,0.390625 -0.10416,0.169271 -0.20833,0.397136 -0.3125,0.683594 -0.16927,0.429688 -0.33854,0.976563 -0.50781,1.640625 -0.16927,0.664063 -0.33854,1.393229 -0.50781,2.1875 -0.16927,0.794271 -0.33203,1.634115 -0.48828,2.519531 -0.13868,0.844673 -0.26465,1.675833 -0.37891,2.496094 -0.44131,0.405809 -0.933,0.826062 -1.51563,1.273437 -0.72916,0.546876 -1.5039,1.054688 -2.32421,1.523438 -0.82032,0.46875 -1.66667,0.859375 -2.53907,1.171875 -0.85937,0.3125 -1.67968,0.46875 -2.46093,0.46875 -0.2474,0 -0.48178,-0.02603 -0.70313,-0.07813 -0.20833,-0.05208 -0.41015,-0.14323 -0.60547,-0.273438 -0.19531,-0.130208 -0.39062,-0.3125 -0.58594,-0.546874 -0.18229,-0.234376 -0.3711,-0.527345 -0.5664,-0.878907 1.1328,-0.3125 2.18098,-0.748698 3.14453,-1.308593 0.97656,-0.559897 1.8164,-1.197917 2.51953,-1.914063 0.70313,-0.716145 1.25001,-1.477864 1.64063,-2.285156 0.40364,-0.807292 0.60546,-1.614583 0.60546,-2.421875 0,-0.742188 -0.13021,-1.41276 -0.39062,-2.011719 -0.26042,-0.598958 -0.625,-1.106772 -1.09375,-1.523437 -0.45573,-0.429688 -0.99609,-0.761719 -1.62109,-0.996094 -0.625,-0.234375 -1.30209,-0.351563 -2.03125,-0.351563 -0.89844,0 -1.71876,0.162761 -2.46094,0.488281 -0.72917,0.3125 -1.39323,0.742188 -1.99219,1.289063 -0.58594,0.533855 -1.10026,1.158855 -1.54297,1.875 -0.4427,0.703125 -0.8138,1.445313 -1.11328,2.226563 -0.28646,0.78125 -0.5013,1.582031 -0.64453,2.402343 -0.14323,0.807292 -0.21484,1.575521 -0.21484,2.304688 0,0.313207 0.0159,0.622182 0.041,0.927734 -0.27603,0.196499 -0.55456,0.397701 -0.82226,0.576172 -0.35156,0.234375 -0.71615,0.46875 -1.09375,0.703125 -0.3776,0.221355 -0.7487,0.423177 -1.11329,0.605469 -0.35156,0.16927 -0.6901,0.305989 -1.01562,0.410156 -0.3125,0.104167 -0.59244,0.15625 -0.83984,0.15625 -0.10417,0 -0.21485,-0.07161 -0.33204,-0.214844 -0.11718,-0.15625 -0.22786,-0.358072 -0.33203,-0.605469 -0.10416,-0.260415 -0.19531,-0.546874 -0.27343,-0.859374 -0.0651,-0.325522 -0.0977,-0.657552 -0.0977,-0.996094 l 0,-0.273438 c 0.039,-0.260416 0.0911,-0.527343 0.15625,-0.800781 0.0651,-0.273437 0.13018,-0.527344 0.19531,-0.761719 0.0651,-0.247396 0.13018,-0.475259 0.19531,-0.683594 0.0781,-0.208332 0.14971,-0.377603 0.21485,-0.507812 0.59895,-1.171875 1.23697,-2.369791 1.91406,-3.59375 0.6901,-1.236979 1.3737,-2.486979 2.05078,-3.75 0.67708,-1.276041 1.32813,-2.558594 1.95313,-3.847656 0.625,-1.289063 1.17187,-2.571615 1.64062,-3.847656 0.48178,-1.289064 0.85938,-2.565104 1.13281,-3.828125 0.28646,-1.2760415 0.42969,-2.5260414 0.42969,-3.7499997 0,-0.546875 -0.0456,-1.0807292 -0.13672,-1.6015625 -0.0781,-0.5338542 -0.22135,-1.0091146 -0.42968,-1.4257812 -0.20834,-0.4166667 -0.4948,-0.748698 -0.85938,-0.9960938 -0.36459,-0.2604167 -0.82682,-0.390625 -1.38672,-0.390625 z" /> <path className="small" d="m 110.93108,7.2907753 c 0.10418,0 0.16278,0.1367188 0.17578,0.4101562 0.0261,0.2604167 0.0391,0.5794271 0.0391,0.9570313 -0.11718,1.1848961 -0.39062,2.4674482 -0.82031,3.8476562 -0.42969,1.367187 -0.9375,2.740885 -1.52344,4.121094 -0.58594,1.380208 -1.21094,2.721354 -1.875,4.023437 -0.65104,1.302083 -1.26953,2.473958 -1.85547,3.515625 0,-1.25 0.0911,-2.532552 0.27344,-3.847656 0.18229,-1.328125 0.42969,-2.617188 0.74219,-3.867188 0.3125,-1.25 0.66407,-2.428385 1.05469,-3.535156 0.40364,-1.10677 0.82031,-2.076823 1.25,-2.910156 0.44271,-0.8333333 0.8789,-1.4908854 1.30859,-1.9726562 0.44271,-0.4947917 0.85286,-0.7421875 1.23047,-0.7421875 z" /> <path className="small" d="m 59.270927,24.790775 -1.191407,5.742188 c -0.05208,0.416666 -0.169271,0.9375 -0.351562,1.5625 -0.169272,0.625 -0.397135,1.230468 -0.683594,1.816406 -0.286459,0.585937 -0.625,1.087239 -1.015625,1.503906 -0.390625,0.416667 -0.826823,0.625 -1.308594,0.625 -0.299479,0 -0.546875,-0.07161 -0.742187,-0.214844 -0.195313,-0.15625 -0.351563,-0.351562 -0.46875,-0.585937 -0.117185,-0.247396 -0.201819,-0.520834 -0.253906,-0.820313 -0.03906,-0.3125 -0.05859,-0.63151 -0.05859,-0.957031 0,-0.572917 0.07162,-1.184896 0.214844,-1.835937 0.15625,-0.651042 0.371093,-1.295574 0.644531,-1.933594 0.273437,-0.651042 0.598958,-1.269531 0.976562,-1.855469 0.377604,-0.585937 0.78776,-1.106771 1.230469,-1.5625 0.455729,-0.455729 0.9375,-0.813802 1.445313,-1.074219 0.507812,-0.273438 1.028646,-0.410156 1.5625,-0.410156 z" /> <path className="small" d="m 92.962333,24.790775 c 0.3125,0 0.572917,0.188802 0.78125,0.566406 0.221354,0.377604 0.332031,0.859375 0.332031,1.445313 0,0.416666 -0.162761,0.846354 -0.488281,1.289062 -0.325521,0.442708 -0.729168,0.852865 -1.210938,1.230469 -0.46875,0.377605 -0.983073,0.690105 -1.542968,0.9375 -0.546875,0.234375 -1.054688,0.351562 -1.523438,0.351562 0,-0.286458 0.01302,-0.63151 0.03906,-1.035156 0.02604,-0.403646 0.07813,-0.820312 0.15625,-1.25 0.09114,-0.429688 0.214843,-0.852864 0.371093,-1.269531 0.16927,-0.429687 0.384114,-0.807292 0.644532,-1.132813 0.273437,-0.338541 0.605468,-0.611979 0.996093,-0.820312 0.403645,-0.208333 0.885417,-0.3125 1.445313,-0.3125 z" /> <path className="small" d="m 119.60295,24.790775 c 0.3125,0 0.57292,0.188802 0.78125,0.566406 0.22136,0.377604 0.33203,0.859375 0.33203,1.445313 0,0.416666 -0.16276,0.846354 -0.48828,1.289062 -0.32552,0.442708 -0.72916,0.852865 -1.21093,1.230469 -0.46875,0.377605 -0.98307,0.690105 -1.54297,0.9375 -0.54688,0.234375 -1.05469,0.351562 -1.52344,0.351562 0,-0.286458 0.013,-0.63151 0.0391,-1.035156 0.026,-0.403646 0.0781,-0.820312 0.15625,-1.25 0.0911,-0.429688 0.21485,-0.852864 0.3711,-1.269531 0.16927,-0.429687 0.38411,-0.807292 0.64453,-1.132813 0.27344,-0.338542 0.60546,-0.611979 0.99609,-0.820312 0.40365,-0.208333 0.88542,-0.3125 1.44531,-0.3125 z" /> <path className="small" d="m 151.10686,29.790775 c 0.0651,0.208333 0.13672,0.462239 0.21484,0.761719 0.0911,0.286458 0.16924,0.598958 0.23438,0.9375 0.0781,0.32552 0.13671,0.670573 0.17578,1.035156 0.0521,0.364583 0.0781,0.722656 0.0781,1.074219 0,0.403646 -0.0391,0.794271 -0.11718,1.171875 -0.0781,0.364583 -0.21485,0.690104 -0.41016,0.976562 -0.19531,0.273438 -0.46224,0.494792 -0.80078,0.664063 -0.32552,0.16927 -0.74219,0.253906 -1.25,0.253906 -0.41667,0 -0.78776,-0.09766 -1.11328,-0.292969 -0.32553,-0.195312 -0.61198,-0.410156 -0.85938,-0.644531 -0.24739,-0.234375 -0.46875,-0.449219 -0.66406,-0.644531 -0.18229,-0.195313 -0.35157,-0.292969 -0.50781,-0.292969 l 5.01953,-5 z" /> </svg> ) } }
react-flux-mui/js/material-ui/src/svg-icons/av/replay-10.js
pbogdan/react-flux-mui
import React from 'react'; import pure from 'recompose/pure'; import SvgIcon from '../../SvgIcon'; let AvReplay10 = (props) => ( <SvgIcon {...props}> <path d="M12 5V1L7 6l5 5V7c3.3 0 6 2.7 6 6s-2.7 6-6 6-6-2.7-6-6H4c0 4.4 3.6 8 8 8s8-3.6 8-8-3.6-8-8-8zm-1.1 11H10v-3.3L9 13v-.7l1.8-.6h.1V16zm4.3-1.8c0 .3 0 .6-.1.8l-.3.6s-.3.3-.5.3-.4.1-.6.1-.4 0-.6-.1-.3-.2-.5-.3-.2-.3-.3-.6-.1-.5-.1-.8v-.7c0-.3 0-.6.1-.8l.3-.6s.3-.3.5-.3.4-.1.6-.1.4 0 .6.1c.2.1.3.2.5.3s.2.3.3.6.1.5.1.8v.7zm-.9-.8v-.5s-.1-.2-.1-.3-.1-.1-.2-.2-.2-.1-.3-.1-.2 0-.3.1l-.2.2s-.1.2-.1.3v2s.1.2.1.3.1.1.2.2.2.1.3.1.2 0 .3-.1l.2-.2s.1-.2.1-.3v-1.5z"/> </SvgIcon> ); AvReplay10 = pure(AvReplay10); AvReplay10.displayName = 'AvReplay10'; AvReplay10.muiName = 'SvgIcon'; export default AvReplay10;
docs-ui/components/confirmDelete.stories.js
mvaled/sentry
import React from 'react'; import {storiesOf} from '@storybook/react'; import {withInfo} from '@storybook/addon-info'; import {action} from '@storybook/addon-actions'; import ConfirmDelete from 'app/components/confirmDelete'; import Button from 'app/components/button'; storiesOf('UI|Confirm', module).add( 'ConfirmDelete', withInfo({ text: 'A Confirm Modal that requires a user to enter a confirmation string.', propTablesExclude: [Button], })(() => ( <div> <ConfirmDelete onConfirm={action('confirmed')} confirmInput="Type this out" message="Are you sure you want to do this?" > <Button priority="primary">Confirm on Button click</Button> </ConfirmDelete> </div> )) );
src/website/app/demos/Flex/common/DemoFlex.js
mineral-ui/mineral-ui
/* @flow */ import styled from '@emotion/styled'; import React from 'react'; import _Flex from '../../../../../library/Flex'; import type { StyledComponent } from '@emotion/styled-base/src/utils'; type Props = { gutterWidth?: number | string, theme: Object }; export const containerStyles = ({ theme }: Props) => ({ outline: `1px dotted ${theme.color_theme_30}`, outlineOffset: 4 }); const Root: StyledComponent<{ [key: string]: any }> = styled(_Flex)((props) => containerStyles(props) ); const DemoFlex = (props: Props) => <Root {...props} />; export default DemoFlex;
client/modules/App/__tests__/Components/Footer.spec.js
leranf/hotwireCarRentalSearch
import React from 'react'; import test from 'ava'; import { shallow } from 'enzyme'; import { Footer } from '../../components/Footer/Footer'; test('renders the footer properly', t => { const wrapper = shallow( <Footer /> ); t.is(wrapper.find('p').length, 2); t.is(wrapper.find('p').first().text(), '© 2016 · Hashnode · LinearBytes Inc.'); });
app/components/ListItem/index.js
c-dagostino/react-boilerplate-example
import React from 'react'; import Item from './Item'; import Wrapper from './Wrapper'; function ListItem(props) { return ( <Wrapper> <Item> {props.item} </Item> </Wrapper> ); } ListItem.propTypes = { item: React.PropTypes.any, }; export default ListItem;
frontend/app/js/components/login/index.js
serverboards/serverboards
import React from 'react'; import ResetPassword from './reset_password' import SetPassword from './set_password' import rpc from 'app/rpc' import 'sass/login.sass' import {i18n} from 'app/utils/i18n' import {merge} from 'app/utils' import PropTypes from 'prop-types' import Flash from 'app/flash' const white_logo=require('../../../imgs/white-horizontal-logo.svg') class LoginView extends React.Component{ constructor(props){ super(props) this.state = { modal: undefined, email: undefined, } } handleSubmit(ev){ ev && ev.preventDefault() let $form = $(this.refs.el) if ($form.form('validate form')){ let fields = $form.form('get values') this.props._onSubmit( merge({type: 'basic'}, fields) ) } } componentDidMount( ){ $(this.refs.el).form({ on: 'blur', fields: { email: 'minLength[1]', password: 'minLength[6]' } }).on('submit', this.handleSubmit.bind(this)) $(this.refs.el).find('[name=email]').focus() const token_match=window.location.hash.match(/pr=([-0-9a-fA-F]*)/) if (token_match){ window.location.hash='' this.setState({modal: 'set_password', token: token_match[1]}) } let maybe_error = $('meta[name=error]').attr('value') || "" if (maybe_error && maybe_error.indexOf("{{")<0){ if (maybe_error == 'not_allowed') maybe_error = i18n("Access not allowed.") if (maybe_error == 'invalid_params') maybe_error = i18n("Access params are not valid. Contact the plugin developer or check the Serverboards API.") Flash.error(maybe_error) window.history.replaceState({}, document.title, "/"); } } resetPassword(email){ this.setState({modal: 'reset_password', email}) } setPassword(pw){ this.setState({modal: 'set_password', pw}) } render(){ if (this.state.modal=='reset_password') return( <ResetPassword closeReset={() => this.setState({modal:undefined})} setPassword={this.setPassword.bind(this)} email={this.state.email}/> ) if (this.state.modal=='set_password') return( <SetPassword closeReset={() => this.setState({modal:undefined})} email={this.state.email} token={this.state.token}/> ) const logging = this.props.logging return ( <div className="ui login serverboards background diagonal"> <form ref="el" className="ui form" method="POST"> <img src={white_logo} className="ui serverboards logo"/> <div className="ui small modal active" id="login"> <h1 className="ui huge header"> {i18n("Login")} </h1> <div className="content"> <div className="field"> <label>{i18n("Email")}</label> <input type="text" name="email" placeholder="user@company.com" onChange={(ev) => {this.setState({email: ev.target.value})}} /> </div> <div className="field"> <label>{i18n("Password")}</label> <input type="password" name="password" placeholder="*******" /> </div> <a href="#" onClick={(ev) => { ev.preventDefault(); this.resetPassword(this.state.email)}}> {i18n("Reset your password")}&nbsp; <i className="ui circle icon arrow right"/> </a> <div className="ui error message"></div> </div> <div className="ui centered actions"> <button type="button" className={`ui wide login teal right labeled icon button ${logging ? "disabled" : ""}`} onClick={this.handleSubmit.bind(this)}> {i18n("Log In")} {logging ? ( <i className="loading spinner icon"></i> ) : ( <i className="caret right icon"></i> )} </button> </div> </div> </form> </div> ) } } LoginView.propTypes = { _onSubmit: PropTypes.func.isRequired } LoginView.contextTypes = { router: PropTypes.object } export default LoginView
app/javascript/components/table/TableActions.js
Vizzuality/forest-atlas-landscape-cms
import React from 'react'; import PropTypes from 'prop-types'; const TableActions = ({ data, action, onClickAction }) => { if (action === 'toggle' && 'enable' in data && 'enabled' in data && data.enable.value !== null) { return ( <td key={action}> <span className="row-content"> <button type="button" className={`c-table-action-button -${data.enabled.value ? 'disable' : 'enable'}`} title={data.enabled.value ? 'Disable' : 'Enable'} onClick={() => onClickAction(action, data)} > {data.enabled.value ? 'Disable' : 'Enable'} </button> </span> </td>); } if (action === 'edit' && data && data.edit && data.edit.value) { return ( <td key={action}> <span className="row-content"> <button type="button" className="c-table-action-button -edit" title="Edit" onClick={() => onClickAction(action, data)} > Edit </button> </span> </td> ); } if (action === 'delete' && data && data.delete && data.delete.value) { return ( <td key={action}> <span className="row-content"> <button type="button" className="c-table-action-button -delete" title="Delete" onClick={() => onClickAction(action, data)} > Delete </button> </span> </td> ); } if (action === 'info') { return ( <td key={action}> <button type="button" className="c-table-action-button -info js-metadata-info" onClick={e => onClickAction(action, data, e)} > Info </button> </td> ); } return <td key={action}>-</td>; }; TableActions.propTypes = { data: PropTypes.object.isRequired, action: PropTypes.string.isRequired, onClickAction: PropTypes.func.isRequired }; export default TableActions;
app/components/CustomInput.js
dancon/react-usage
import React from 'react'; // React refs class CustomInput extends React.Component{ constructor(props){ super(props); this.focus = this.focus.bind(this); } focus(){ this.textInput.focus(); } render(){ return ( <div> <input type="text" ref={(input) => { console.log('CustomInput:', input); this.textInput = input; }} /> <input type="button" value="Focus the text input" onClick={this.focus} /> </div> ); } } export default CustomInput;
app/components/TriggerHttpForm/item.js
fission/fission-ui
/** * * TriggerHttpItemForm * */ import React from 'react'; import ReactTooltip from 'react-tooltip'; import { FormattedMessage } from 'react-intl'; import commonMessages from 'messages'; // import styled from 'styled-components'; class Item extends React.Component { // eslint-disable-line react/prefer-stateless-function makeCopy(endpoint) { return () => { window.prompt('Copy to clipboard: Ctrl+C, Enter', endpoint); }; } render() { const { trigger, onRemove } = this.props; const endpoint = `${window.location.origin}/proxy/router${trigger.urlpattern}`; return ( <tr> <td>{trigger.method}</td> <td>{trigger.urlpattern}</td> <td> <a className="btn btn-danger" onClick={onRemove}><FormattedMessage {...commonMessages.delete} /></a> { ' ' } <a className="btn btn-default" data-tip={endpoint} onClick={this.makeCopy(endpoint)}><FormattedMessage {...commonMessages.copyEndpoint} /></a> <ReactTooltip /> </td> </tr> ); } } Item.propTypes = { trigger: React.PropTypes.object, onRemove: React.PropTypes.func, }; export default Item;
src/svg-icons/image/filter-9-plus.js
manchesergit/material-ui
import React from 'react'; import pure from 'recompose/pure'; import SvgIcon from '../../SvgIcon'; let ImageFilter9Plus = (props) => ( <SvgIcon {...props}> <path d="M3 5H1v16c0 1.1.9 2 2 2h16v-2H3V5zm11 7V8c0-1.11-.9-2-2-2h-1c-1.1 0-2 .89-2 2v1c0 1.11.9 2 2 2h1v1H9v2h3c1.1 0 2-.89 2-2zm-3-3V8h1v1h-1zm10-8H7c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V3c0-1.1-.9-2-2-2zm0 8h-2V7h-2v2h-2v2h2v2h2v-2h2v6H7V3h14v6z"/> </SvgIcon> ); ImageFilter9Plus = pure(ImageFilter9Plus); ImageFilter9Plus.displayName = 'ImageFilter9Plus'; ImageFilter9Plus.muiName = 'SvgIcon'; export default ImageFilter9Plus;
app/components/Vesting/CancelPowerDownPrompt.js
soosgit/vessel
// @flow import React, { Component } from 'react'; import { bindActionCreators } from 'redux'; import { connect } from 'react-redux'; import { Message, Modal, Segment } from 'semantic-ui-react'; import { Form } from 'formsy-semantic-ui-react' import * as KeysActions from '../../actions/keys'; class CancelPowerDownPrompt extends Component { handleConfirm = (e: SyntheticEvent) => { const account = this.props.targetAccount; const permissions = this.props.keys.permissions; // console.log('cancelWithdrawVesting', { account }, permissions[account]); this.props.actions.useKey('cancelWithdrawVesting', { account }, permissions[account]); e.preventDefault(); } handleOnChange = (value) => { const vests = parseFloat(value).toFixed(6); const props = this.props.steem.props; const totalVestsSteem = parseFloat(props.total_vesting_fund_steem.split(" ")[0]) const totalVests = parseFloat(props.total_vesting_shares.split(" ")[0]) const sp = totalVestsSteem * vests / totalVests; const perWeek = Math.round(sp / 13 * 1000) / 1000; this.setState({ vests, sp, perWeek }); } handleOnChangeComplete = (value) => { const vests = parseFloat(value).toFixed(6); const props = this.props.steem.props; const totalVestsSteem = parseFloat(props.total_vesting_fund_steem.split(" ")[0]) const totalVests = parseFloat(props.total_vesting_shares.split(" ")[0]) const sp = totalVestsSteem * vests / totalVests; const perWeek = Math.round(sp / 13 * 1000) / 1000; this.setState({ vests, sp, perWeek }); } render() { const { account_vesting_withdraw_error, account_vesting_withdraw_pending, account_vesting_withdraw_resolved } = this.props.processing; return ( <Modal size="small" open header="Cancel - Power Down" content={ <Form error={account_vesting_withdraw_error} loading={account_vesting_withdraw_pending} > <Segment padded basic > <p> Cancelling this power down cannot be reversed. Any progress on your current week's credit will be reset, and if you power down again, you'll have to wait another 7 days for it to begin. </p> <Message error header="Operation Error" content={account_vesting_withdraw_error} /> </Segment> </Form> } actions={[ { key: 'no', content: 'Cancel Operation', floated: 'left', color: 'red', onClick: this.props.handleCancel, disabled: account_vesting_withdraw_pending }, { key: 'yes', type: 'submit', content: 'Cancel Power Down', color: 'blue', onClick: this.handleConfirm, disabled: account_vesting_withdraw_pending } ]} /> ); } } function mapStateToProps(state) { return { account: state.account, keys: state.keys, steem: state.steem }; } function mapDispatchToProps(dispatch) { return { actions: bindActionCreators({ ...KeysActions }, dispatch) }; } export default connect(mapStateToProps, mapDispatchToProps)(CancelPowerDownPrompt);
src/app.js
peteruithoven/cssmodules-react-jspm-experiment
import React from 'react'; import Button from './components/button.js'; import './global.css!'; export default class App extends React.Component { render () { return ( <div> <h2>JSPM, React and CSS modules experiment</h2> <Button /> <Button mode='disabled'/> </div> ); } }
app/containers/LanguageProvider/index.js
KyleAWang/react-boilerplate
/* * * LanguageProvider * * this component connects the redux state language locale to the * IntlProvider component and i18n messages (loaded from `app/translations`) */ import React from 'react'; import { connect } from 'react-redux'; import { createSelector } from 'reselect'; import { IntlProvider } from 'react-intl'; import { makeSelectLocale } from './selectors'; export class LanguageProvider extends React.PureComponent { // eslint-disable-line react/prefer-stateless-function render() { return ( <IntlProvider locale={this.props.locale} key={this.props.locale} messages={this.props.messages[this.props.locale]}> {React.Children.only(this.props.children)} </IntlProvider> ); } } LanguageProvider.propTypes = { locale: React.PropTypes.string, messages: React.PropTypes.object, children: React.PropTypes.element.isRequired, }; const mapStateToProps = createSelector( makeSelectLocale(), (locale) => ({ locale }) ); export default connect(mapStateToProps)(LanguageProvider);
blueprints/dumb/files/__root__/components/__name__/__name__.js
availabs/kauffman-atlas
import React from 'react' type Props = { }; export class <%= pascalEntityName %> extends React.Component { props: Props; render () { return ( <div></div> ) } } export default <%= pascalEntityName %>
src/components/menu.js
b33rTiger/bookshop
"use strict"; import React from 'react'; import {Nav, NavItem, Navbar, Badge} from 'react-bootstrap'; class Menu extends React.Component{ render(){ return ( <Navbar inverse fixedTop> <Navbar.Header> <Navbar.Brand> <a href="/">React-Bootstrap</a> </Navbar.Brand> <Navbar.Toggle /> </Navbar.Header> <Navbar.Collapse> <Nav> <NavItem eventKey={1} href="/about">About</NavItem> <NavItem eventKey={2} href="/contacts">Contact</NavItem> </Nav> <Nav pullRight> <NavItem eventKey={1} href="/admin">Admin</NavItem> <NavItem eventKey={2} href="/cart"> Your Cart { (this.props.cartItemsNumber > 0)?(<Badge className="badge">{this.props.cartItemsNumber}</Badge>):('')} </NavItem> </Nav> </Navbar.Collapse> </Navbar> ); } } export default Menu
docs/app/Examples/modules/Dropdown/Usage/DropdownExampleMultipleCustomLabel.js
koenvg/Semantic-UI-React
import React from 'react' import { Dropdown } from 'semantic-ui-react' const options = [ { key: 1, text: 'One', value: 1 }, { key: 2, text: 'Two', value: 2 }, { key: 3, text: 'Three', value: 3 }, ] const renderLabel = (label, index, props) => ({ color: 'blue', content: `Customized label - ${label.text}`, icon: 'check', }) const DropdownExampleMultipleCustomLabel = () => ( <Dropdown multiple selection fluid options={options} placeholder='Choose an option' renderLabel={renderLabel} /> ) export default DropdownExampleMultipleCustomLabel
src/DataViewer/index.js
Aprillion/data_viewer
import React from 'react' import Table from './Table' import {useTable} from './dataService' const DataViewer = ({data, standardize, deleteOnServer}) => { const tableProps = useTable(data, standardize, deleteOnServer) return ( <div className="DataViewer"> <Table {...tableProps} /> </div> ) } export default DataViewer
demos/forms-demo/src/components/PrettyPrint/index.js
bdjnk/cerebral
import React from 'react' import {connect} from 'cerebral/react' import {state, props} from 'cerebral/tags' import {isValidForm, getInvalidFormFields, formToJSON} from 'cerebral-forms' import {css} from 'aphrodite' import syntaxHighlight from '../../helpers/syntaxHighlight' import styles from './styles' export default connect({ form: state`${props`currentView`}.form`, showPanel: state`app.settings.showErrors` }, function PrettyPrint ({form, showPanel}) { if (!showPanel) { return null } const isValid = isValidForm(form) let invalidFormFields = getInvalidFormFields(form) let result = Object.keys(invalidFormFields).reduce((acc, field) => { const {value} = invalidFormFields[field] acc[field] = { value } return acc }, {}) if (isValid) { result = formToJSON(form) } const resultPane = css( isValid ? styles.successPane : styles.errorPane ) return ( <div className={css(styles.container)}> <div className={resultPane}> {isValid ? 'The form is valid' : 'The form is invalid. See invalid fields below'} </div> <div className={css(styles.innerContainer)}> <pre className={css(styles.pretty)} dangerouslySetInnerHTML={{__html: syntaxHighlight(JSON.stringify(result, undefined, 2))}} /> </div> </div> ) } )
src/components/Checkbox/Checkbox.js
joshblack/carbon-components-react
/** * Copyright IBM Corp. 2016, 2018 * * This source code is licensed under the Apache-2.0 license found in the * LICENSE file in the root directory of this source tree. */ import PropTypes from 'prop-types'; import React from 'react'; import classNames from 'classnames'; import { settings } from 'carbon-components'; const { prefix } = settings; const Checkbox = React.forwardRef(function Checkbox( { className, id, labelText, onChange, indeterminate, hideLabel, wrapperClassName, title = '', ...other }, ref ) { const labelClasses = classNames(`${prefix}--checkbox-label`, className); const innerLabelClasses = classNames(`${prefix}--checkbox-label-text`, { [`${prefix}--visually-hidden`]: hideLabel, }); const wrapperClasses = classNames( `${prefix}--form-item`, `${prefix}--checkbox-wrapper`, wrapperClassName ); return ( <div className={wrapperClasses}> <input {...other} type="checkbox" onChange={evt => { onChange(evt.target.checked, id, evt); }} className={`${prefix}--checkbox`} id={id} ref={el => { if (el) { el.indeterminate = indeterminate; } if (typeof ref === 'function') { ref(el); } else if (Object(ref) === ref) { ref.current = el; } }} /> <label htmlFor={id} className={labelClasses} title={title || null}> <span className={innerLabelClasses}>{labelText}</span> </label> </div> ); }); Checkbox.propTypes = { /** * Specify whether the underlying input should be checked */ checked: PropTypes.bool, /** * Specify whether the underlying input should be checked by default */ defaultChecked: PropTypes.bool, /** * Specify whether the Checkbox is in an indeterminate state */ indeterminate: PropTypes.bool, /** * Specify an optional className to be applied to the <label> node */ className: PropTypes.string, /** * Specify whether the Checkbox should be disabled */ disabled: PropTypes.bool, /** * Provide an `id` to uniquely identify the Checkbox input */ id: PropTypes.string.isRequired, /** * Provide a label to provide a description of the Checkbox input that you are * exposing to the user */ labelText: PropTypes.node.isRequired, /** * Specify whether the label should be hidden, or not */ hideLabel: PropTypes.bool, /** * Receives three arguments: true/false, the checkbox's id, and the dom event. * `(value, id, event) => console.log({value, id, event})` */ onChange: PropTypes.func, /** * Specify a title for the <label> node for the Checkbox */ title: PropTypes.string, /** * The CSS class name to be placed on the wrapping element */ wrapperClassName: PropTypes.string, }; Checkbox.defaultProps = { onChange: () => {}, indeterminate: false, }; export default Checkbox;
app/app.js
brietsparks/curr__ui-rbp-apollo-cvb
/** * app.js * * This is the entry file for the application, only setup and boilerplate * code. */ // Needed for redux-saga es6 generator support import 'babel-polyfill'; // Import all the third party stuff import React from 'react'; import ReactDOM from 'react-dom'; import { applyRouterMiddleware, Router, browserHistory } from 'react-router'; import { syncHistoryWithStore } from 'react-router-redux'; import { useScroll } from 'react-router-scroll'; import 'sanitize.css/sanitize.css'; // Import selector for `syncHistoryWithStore` import { makeSelectLocationState } from 'containers/App/selectors'; // Import Language Provider import LanguageProvider from 'containers/LanguageProvider'; // Load the favicon, the manifest.json file and the .htaccess file /* eslint-disable import/no-unresolved, import/extensions */ import '!file-loader?name=[name].[ext]!./favicon.ico'; import '!file-loader?name=[name].[ext]!./manifest.json'; import 'file-loader?name=[name].[ext]!./.htaccess'; /* eslint-enable import/no-unresolved, import/extensions */ import { ApolloProvider } from 'react-apollo'; import configureStore from './store'; import apolloClient from './graphql'; import createRootComponent from './routes'; // Import i18n messages import { translationMessages } from './i18n'; // Import CSS reset and Global Styles import './global-styles'; // Create redux store with history // this uses the singleton browserHistory provided by react-router // Optionally, this could be changed to leverage a created history // e.g. `const browserHistory = useRouterHistory(createBrowserHistory)();` const initialState = {}; const store = configureStore(initialState, apolloClient, browserHistory); // Sync history and store, as the react-router-redux reducer // is under the non-default key ("routing"), selectLocationState // must be provided for resolving how to retrieve the "route" in the state const history = syncHistoryWithStore(browserHistory, store, { selectLocationState: makeSelectLocationState(), }); const rootRoute = createRootComponent(store); const render = (messages) => { ReactDOM.render( <ApolloProvider immutable store={store} client={apolloClient} > <LanguageProvider messages={messages}> <Router history={history} routes={rootRoute} render={ // Scroll to top when going to a new page, imitating default browser // behaviour applyRouterMiddleware(useScroll()) } /> </LanguageProvider> </ApolloProvider>, document.getElementById('app') ); }; // Hot reloadable translation json files if (module.hot) { // modules.hot.accept does not accept dynamic dependencies, // have to be constants at compile-time module.hot.accept('./i18n', () => { render(translationMessages); }); } // Chunked polyfill for browsers without Intl support if (!window.Intl) { (new Promise((resolve) => { resolve(import('intl')); })) .then(() => Promise.all([ import('intl/locale-data/jsonp/en.js'), ])) .then(() => render(translationMessages)) .catch((err) => { throw err; }); } else { render(translationMessages); } // Install ServiceWorker and AppCache in the end since // it's not most important operation and if main code fails, // we do not want it installed if (process.env.NODE_ENV === 'production') { require('offline-plugin/runtime').install(); // eslint-disable-line global-require }
src/containers/Message.js
bmarshall511/twitscreen
// Import node dependencies import React, { Component } from 'react'; class Message extends Component { render() { const { messages } = this.props; return ( <div className="modal"> <h2>Something {"isn't"} right. Twitterverse {"isn't"} responding!</h2> <p><b>{"Don't"} panic!</b> {"It's"} not the end of the world &mdash; <em>probably</em>. {"Here's"} some of the common reasons Twitter might be giving you the cold shoulder.</p> <ul> <li><b>{"It's"} just a temporary hiccup</b> &mdash; hopefully a little time apart will settle thing down.</li> <li>Have you <b><button data-toggle="offCanvas" className="text-link">selected a filter</button></b>?</li> <li>The <b>gate-keeper {"isn't"} happy</b>, see below: <ul> {messages.map(( msg ) => { return ( <li key={msg}>{msg}</li> ); })} </ul> </li> <li>Worst-case scenario might be right &mdash; <b>the world is ending!</b></li> </ul> <p>If this problem persists, please <b><a href="https://benmarshall.me" target="_blank" rel="noopener noreferrer">report it</a></b>.</p> </div> ); } } export default Message;
src/chat/ui/room/MessageImage.js
elarasu/roverz-chat
import React from 'react'; import { StyleSheet, View, TouchableOpacity, Image, ActivityIndicator, Keyboard, } from 'react-native'; import { Actions } from 'react-native-router-flux'; import { CachedImage } from 'react-native-img-cache'; import { Icon } from 'react-native-elements'; import AudioPlay from './AudioPlay'; import { AppColors } from '../../../theme/'; const playCircleIconColor = AppColors.brand().mI_playCircleIconColor; const activityIndicatorColor = AppColors.brand().mI_activityIndicatorColor; const styles = StyleSheet.create({ container: { }, image: { width: 250, height: 150, borderRadius: 8, margin: 3, resizeMode: 'cover', justifyContent: 'center', alignItems: 'center', }, imageActive: { resizeMode: 'contain', }, mapView: { width: 250, height: 150, borderRadius: 13, margin: 3, backgroundColor: AppColors.brand().mI_mapViewBg, }, }); const videoThumbnail = require('../../../images/video-thumb.jpg'); export default class MessageImage extends React.Component { constructor(props) { super(props); const obj = this.props.obj; // const _network = new Network(); this.state = { obj, modalVisible: false, loaded: false, }; } componentWillMount = () => { // console.log(this.props.currentMessage.image); // Image.prefetch('this.props.currentMessage.image', id => console.log(id)); // this._network.chat.fixS3Urls( // [this.props.currentMessage.image], // (res) => { // console.log('fixS3Urls'); // console.log(res); // }, // true, // ); // Image.getSize('https://facebook.github.io/react-native/img/header_logo.png', (width, height) => { // // this.setState({width, height}) // console.log(width, height); // }); } handleLongPress = () => { // this.props.pressLong(); } render() { if (this.props.currentMessage.video) { if (this.props.currentMessage.text === 'Audio message') { return ( <View style={[styles.container]}> <AudioPlay audioFile={this.props.currentMessage.video} /> </View> ); } return ( <View style={[styles.container]}> <TouchableOpacity onPress={() => { Keyboard.dismiss(); Actions.videoPreview({ videoUrl: this.props.currentMessage.video }); }} > <CachedImage style={[styles.image]} source={videoThumbnail} > <Icon name="play-circle-filled" size={48} color={playCircleIconColor} /> </CachedImage> </TouchableOpacity> </View> ); } return ( <View style={[styles.container, this.props.containerStyle]}> <TouchableOpacity onPress={() => { Keyboard.dismiss(); Actions.imageGallery({ imgUrl: this.props.currentMessage.image, imgTitle: this.props.currentMessage.text, }); }} onLongPress={this.handleLongPress} > <CachedImage {...this.props.imageProps} style={[styles.image, this.props.imageStyle]} source={{ uri: this.props.currentMessage.image }} onLoad={() => { this.setState({ loaded: true }); }} resizeMethod={'scale'} > { !this.state.loaded && ( <View style={{ flex: 1, height: 150, alignItems: 'center', justifyContent: 'center', }} > <ActivityIndicator animating size={'large'} color={activityIndicatorColor} /> </View> ) } </CachedImage> </TouchableOpacity> </View> ); } } MessageImage.defaultProps = { currentMessage: { image: null, }, containerStyle: {}, imageStyle: {}, imageProps: {}, lightboxProps: {}, obj: {}, pressLong: null, }; MessageImage.propTypes = { currentMessage: React.PropTypes.object, // eslint-disable-line react/forbid-prop-types containerStyle: View.propTypes.style, imageStyle: Image.propTypes.style, imageProps: React.PropTypes.object, // eslint-disable-line react/forbid-prop-types lightboxProps: React.PropTypes.object, // eslint-disable-line react/forbid-prop-types obj: React.PropTypes.object, // eslint-disable-line react/forbid-prop-types pressLong: React.PropTypes.func, };
pkg/interface/chat/src/js/components/lib/channel-item.js
ngzax/urbit
import React, { Component } from 'react'; export class ChannelItem extends Component { constructor(props) { super(props); } onClick() { const { props } = this; props.history.push('/~chat/room' + props.box); } render() { const { props, state } = this; let unreadElem = !!props.unread ? "fw6" : ""; let title = props.title; let selectedCss = !!props.selected ? 'bg-gray4 bg-gray1-d gray3-d c-default' : 'bg-white bg-gray0-d gray3-d hover-bg-gray5 hover-bg-gray1-d pointer'; return ( <div className={"z1 ph4 pv1 " + selectedCss} onClick={this.onClick.bind(this)}> <div className="w-100 v-mid"> <p className={"dib f9 " + unreadElem}> {title} </p> </div> </div> ); } }
stories/progress.stories.js
isogon/styled-mdl
import React from 'react' import { storiesOf } from '@storybook/react' import wrapStory from './decorators/wrapStory' import Progress from '../src/components/progress/demos/Progress.js' import ProgressIndeterminate from '../src/components/progress/demos/ProgressIndeterminate.js' storiesOf('Progress', module) .addDecorator(wrapStory) .add('Progress', () => <Progress />) .add('Progress Indeterminate', () => <ProgressIndeterminate />)
src/InputBase.js
xuorig/react-bootstrap
import React from 'react'; import classNames from 'classnames'; import FormGroup from './FormGroup'; import Glyphicon from './Glyphicon'; class InputBase extends React.Component { getInputDOMNode() { return React.findDOMNode(this.refs.input); } getValue() { if (this.props.type === 'static') { return this.props.value; } else if (this.props.type) { if (this.props.type === 'select' && this.props.multiple) { return this.getSelectedOptions(); } else { return this.getInputDOMNode().value; } } else { throw new Error('Cannot use getValue without specifying input type.'); } } getChecked() { return this.getInputDOMNode().checked; } getSelectedOptions() { let values = []; Array.prototype.forEach.call( this.getInputDOMNode().getElementsByTagName('option'), (option) => { if (option.selected) { let value = option.getAttribute('value') || option.innerHtml; values.push(value); } }); return values; } isCheckboxOrRadio() { return this.props.type === 'checkbox' || this.props.type === 'radio'; } isFile() { return this.props.type === 'file'; } renderInputGroup(children) { let addonBefore = this.props.addonBefore ? ( <span className="input-group-addon" key="addonBefore"> {this.props.addonBefore} </span> ) : null; let addonAfter = this.props.addonAfter ? ( <span className="input-group-addon" key="addonAfter"> {this.props.addonAfter} </span> ) : null; let buttonBefore = this.props.buttonBefore ? ( <span className="input-group-btn"> {this.props.buttonBefore} </span> ) : null; let buttonAfter = this.props.buttonAfter ? ( <span className="input-group-btn"> {this.props.buttonAfter} </span> ) : null; let inputGroupClassName; switch (this.props.bsSize) { case 'small': inputGroupClassName = 'input-group-sm'; break; case 'large': inputGroupClassName = 'input-group-lg'; break; default: } return addonBefore || addonAfter || buttonBefore || buttonAfter ? ( <div className={classNames(inputGroupClassName, 'input-group')} key="input-group"> {addonBefore} {buttonBefore} {children} {addonAfter} {buttonAfter} </div> ) : children; } renderIcon() { if (this.props.hasFeedback) { if (this.props.feedbackIcon) { return React.cloneElement(this.props.feedbackIcon, { formControlFeedback: true }); } switch (this.props.bsStyle) { case 'success': return <Glyphicon formControlFeedback glyph="ok" key="icon" />; case 'warning': return <Glyphicon formControlFeedback glyph="warning-sign" key="icon" />; case 'error': return <Glyphicon formControlFeedback glyph="remove" key="icon" />; default: return <span className="form-control-feedback" key="icon" />; } } else { return null; } } renderHelp() { return this.props.help ? ( <span className="help-block" key="help"> {this.props.help} </span> ) : null; } renderCheckboxAndRadioWrapper(children) { let classes = { 'checkbox': this.props.type === 'checkbox', 'radio': this.props.type === 'radio' }; return ( <div className={classNames(classes)} key="checkboxRadioWrapper"> {children} </div> ); } renderWrapper(children) { return this.props.wrapperClassName ? ( <div className={this.props.wrapperClassName} key="wrapper"> {children} </div> ) : children; } renderLabel(children) { let classes = { 'control-label': !this.isCheckboxOrRadio() }; classes[this.props.labelClassName] = this.props.labelClassName; return this.props.label ? ( <label htmlFor={this.props.id} className={classNames(classes)} key="label"> {children} {this.props.label} </label> ) : children; } renderInput() { if (!this.props.type) { return this.props.children; } switch (this.props.type) { case 'select': return ( <select {...this.props} className={classNames(this.props.className, 'form-control')} ref="input" key="input"> {this.props.children} </select> ); case 'textarea': return <textarea {...this.props} className={classNames(this.props.className, 'form-control')} ref="input" key="input" />; case 'static': return ( <p {...this.props} className={classNames(this.props.className, 'form-control-static')} ref="input" key="input"> {this.props.value} </p> ); default: const className = this.isCheckboxOrRadio() || this.isFile() ? '' : 'form-control'; return <input {...this.props} className={classNames(this.props.className, className)} ref="input" key="input" />; } } renderFormGroup(children) { return <FormGroup {...this.props}>{children}</FormGroup>; } renderChildren() { return !this.isCheckboxOrRadio() ? [ this.renderLabel(), this.renderWrapper([ this.renderInputGroup( this.renderInput() ), this.renderIcon(), this.renderHelp() ]) ] : this.renderWrapper([ this.renderCheckboxAndRadioWrapper( this.renderLabel( this.renderInput() ) ), this.renderHelp() ]); } render() { let children = this.renderChildren(); return this.renderFormGroup(children); } } InputBase.propTypes = { type: React.PropTypes.string, label: React.PropTypes.node, help: React.PropTypes.node, addonBefore: React.PropTypes.node, addonAfter: React.PropTypes.node, buttonBefore: React.PropTypes.node, buttonAfter: React.PropTypes.node, bsSize: React.PropTypes.oneOf(['small', 'medium', 'large']), bsStyle: React.PropTypes.oneOf(['success', 'warning', 'error']), hasFeedback: React.PropTypes.bool, feedbackIcon: React.PropTypes.node, id: React.PropTypes.oneOfType([ React.PropTypes.string, React.PropTypes.number ]), groupClassName: React.PropTypes.string, wrapperClassName: React.PropTypes.string, labelClassName: React.PropTypes.string, multiple: React.PropTypes.bool, disabled: React.PropTypes.bool, value: React.PropTypes.any }; InputBase.defaultProps = { disabled: false, hasFeedback: false, multiple: false }; export default InputBase;
frontend/src/Artist/History/ArtistHistoryRow.js
lidarr/Lidarr
import PropTypes from 'prop-types'; import React, { Component } from 'react'; import HistoryDetailsConnector from 'Activity/History/Details/HistoryDetailsConnector'; import HistoryEventTypeCell from 'Activity/History/HistoryEventTypeCell'; import TrackQuality from 'Album/TrackQuality'; import Icon from 'Components/Icon'; import IconButton from 'Components/Link/IconButton'; import ConfirmModal from 'Components/Modal/ConfirmModal'; import RelativeDateCellConnector from 'Components/Table/Cells/RelativeDateCellConnector'; import TableRowCell from 'Components/Table/Cells/TableRowCell'; import TableRow from 'Components/Table/TableRow'; import Popover from 'Components/Tooltip/Popover'; import { icons, kinds, tooltipPositions } from 'Helpers/Props'; import styles from './ArtistHistoryRow.css'; function getTitle(eventType) { switch (eventType) { case 'grabbed': return 'Grabbed'; case 'downloadImported': return 'Download Completed'; case 'trackFileImported': return 'Track Imported'; case 'downloadFailed': return 'Download Failed'; case 'trackFileDeleted': return 'Track File Deleted'; case 'trackFileRenamed': return 'Track File Renamed'; case 'trackFileRetagged': return 'Track File Tags Updated'; case 'albumImportIncomplete': return 'Album Import Incomplete'; default: return 'Unknown'; } } class ArtistHistoryRow extends Component { // // Lifecycle constructor(props, context) { super(props, context); this.state = { isMarkAsFailedModalOpen: false }; } // // Listeners onMarkAsFailedPress = () => { this.setState({ isMarkAsFailedModalOpen: true }); } onConfirmMarkAsFailed = () => { this.props.onMarkAsFailedPress(this.props.id); this.setState({ isMarkAsFailedModalOpen: false }); } onMarkAsFailedModalClose = () => { this.setState({ isMarkAsFailedModalOpen: false }); } // // Render render() { const { eventType, sourceTitle, quality, qualityCutoffNotMet, date, data, album } = this.props; const { isMarkAsFailedModalOpen } = this.state; return ( <TableRow> <HistoryEventTypeCell eventType={eventType} data={data} /> <TableRowCell key={name}> {album.title} </TableRowCell> <TableRowCell className={styles.sourceTitle}> {sourceTitle} </TableRowCell> <TableRowCell> <TrackQuality quality={quality} isCutoffNotMet={qualityCutoffNotMet} /> </TableRowCell> <RelativeDateCellConnector date={date} /> <TableRowCell className={styles.details}> <Popover anchor={ <Icon name={icons.INFO} /> } title={getTitle(eventType)} body={ <HistoryDetailsConnector eventType={eventType} sourceTitle={sourceTitle} data={data} /> } position={tooltipPositions.LEFT} /> </TableRowCell> <TableRowCell className={styles.actions}> { eventType === 'grabbed' && <IconButton title="Mark as failed" name={icons.REMOVE} onPress={this.onMarkAsFailedPress} /> } </TableRowCell> <ConfirmModal isOpen={isMarkAsFailedModalOpen} kind={kinds.DANGER} title="Mark as Failed" message={`Are you sure you want to mark '${sourceTitle}' as failed?`} confirmLabel="Mark as Failed" onConfirm={this.onConfirmMarkAsFailed} onCancel={this.onMarkAsFailedModalClose} /> </TableRow> ); } } ArtistHistoryRow.propTypes = { id: PropTypes.number.isRequired, eventType: PropTypes.string.isRequired, sourceTitle: PropTypes.string.isRequired, quality: PropTypes.object.isRequired, qualityCutoffNotMet: PropTypes.bool.isRequired, date: PropTypes.string.isRequired, data: PropTypes.object.isRequired, fullArtist: PropTypes.bool.isRequired, artist: PropTypes.object.isRequired, album: PropTypes.object.isRequired, onMarkAsFailedPress: PropTypes.func.isRequired }; export default ArtistHistoryRow;
demo/snippets/demo1/00_shell.js
simonswiss/react-music
import React, { Component } from 'react'; /* ################################## */ /* ##### react-music components ##### */ /* ################################## */ import { Analyser, Song, Sequencer, Sampler, Synth } from '../src'; import Visualization from './visualization'; import './index.css'; export default class Demo extends Component { constructor(props) { super(props); this.state = {playing: true}; this.handleAudioProcess = this.handleAudioProcess.bind(this); this.handlePlayToggle = this.handlePlayToggle.bind(this); } handleAudioProcess(analyser) { this.visualization.audioProcess(analyser); } handlePlayToggle() { this.setState({ playing: !this.state.playing, }); } /* ######################### */ /* ##### render method ##### */ /* ######################### */ render() { return ( <div> <Song playing={this.state.playing} tempo={122} > <Analyser onAudioProcess={this.handleAudioProcess} > {/* ###################################### ##### Sequencers come here below ##### ###################################### */} </Analyser> </Song> <Visualization ref={(c) => { this.visualization = c; }} /> <button className="react-music-button" type="button" onClick={this.handlePlayToggle} > {this.state.playing ? 'Stop' : 'Play'} </button> </div> ); } }
example/index.js
TAPP-TV/react-cropperjs
import React from 'react'; import ReactDOM from 'react-dom'; import CropperJS from '../dist/react-cropper'; class Demo extends React.Component { constructor() { super(); this.state = { defaultSrc: 'http://i.imgur.com/n483ZwJ.jpg', src: 'http://i.imgur.com/n483ZwJ.jpg', // tapptv image (small) // src: 'http://i.imgur.com/1gpjD9I.jpg', // iphone sky photo (large) preview: null }; this._crop = this._crop.bind(this); this._onChange = this._onChange.bind(this); this._useDefaultImage = this._useDefaultImage.bind(this); } // Callback functions _build() { console.log('_build'); } _built() { console.log('_built'); } _cropstart(data) { console.log('_cropstart', data.action); } _cropmove(data) { console.log('_cropmove', data.action); } _cropend(data) { console.log('_cropend', data.action); } _zoom(data) { console.log('_zoom', data.ratio); } _crop(data) { console.log('_crop', data); this.setState({ preview: this.refs.cropper.getCroppedCanvas().toDataURL() }); } // end callback functions _onChange(e) { e.preventDefault(); let files; if (e.dataTransfer) { files = e.dataTransfer.files; } else if (e.target) { files = e.target.files; } let reader = new FileReader(); reader.onload = () => { this.setState({ src: reader.result }); }; reader.readAsDataURL(files[0]); } _useDefaultImage() { this.setState({ src: this.state.defaultSrc }); } render() { return ( <div> <div className='box' style={{ width: '70%', float: 'left'}}> <input type='file' onChange={this._onChange} /> <button onClick={this._useDefaultImage}> Use default img </button> <br/> <br/> <CropperJS style={{ height: 400, width: '100%'}} aspectRatio={16 / 9} guides={false} src={this.state.src} ref='cropper' build={this._build} built={this._built} cropstart={this._cropstart} cropmove={this._cropmove} cropend={this._cropend} zoom={this._zoom} crop={this._crop} /> </div> <div className='box' style={{ width: '30%', float: 'right'}}> <h1>Preview</h1> <img style={{ width: '100%'}} src={this.state.preview} /> </div> <br style={{ clear: 'both'}} /> </div> ); } } ReactDOM.render(<Demo />, document.getElementById('main'));
src/icons/MinusRound.js
fbfeix/react-icons
import React from 'react'; import IconBase from './../components/IconBase/IconBase'; export default class MinusRound extends React.Component { render() { if(this.props.bare) { return <g> <path d="M417.4,224H94.6C77.7,224,64,238.3,64,256c0,17.7,13.7,32,30.6,32h322.8c16.9,0,30.6-14.3,30.6-32 C448,238.3,434.3,224,417.4,224z"></path> </g>; } return <IconBase> <path d="M417.4,224H94.6C77.7,224,64,238.3,64,256c0,17.7,13.7,32,30.6,32h322.8c16.9,0,30.6-14.3,30.6-32 C448,238.3,434.3,224,417.4,224z"></path> </IconBase>; } };MinusRound.defaultProps = {bare: false}
client/routes/Items/components/ItemInForm.js
patzj/ims
import React from 'react'; import { connect } from 'react-redux'; import { itemIn } from '../../../actions/items-action'; let ItemInForm = ({currentItem, itemIn, handleInt}) => { return ( <form className="form-horizontal" method="post" action="#" onSubmit={e => itemIn(currentItem.code, e)}> <div className="row"> <label htmlFor="quantity" className="control-label col-md-3">Quantity</label> <div className="col-md-5"> <input type="number" name="quantity" min="0" max="999" className="form-control input-sm" defaultValue="0" onKeyUp={e => handleInt(e)} /> </div> <div className="col-md-4"> <button type="submit" className="btn btn-default btn-block btn-sm btn-success">Add</button> </div> </div> </form> ); }; const mapStateToProps = (state) => { return { currentItem: state.items.currentItem }; }; const mapDispatchToProps = (dispatch) => { return { itemIn: (code, e) => dispatch(itemIn(code, e)), handleInt: e => { if((e.keyCode < 58 && e.keyCode > 47)) { return e.value; } } }; }; ItemInForm = connect(mapStateToProps, mapDispatchToProps)(ItemInForm); export default ItemInForm;
src/js/components/VoteButtons.js
liveplant/liveplant.io
import React from 'react'; import VoteActions from '../actions/VoteActions'; export default class VoteButtons extends React.Component { vote(action) { VoteActions.incrementVote(action); } render() { var buttons = this.props.votes.map((option, key) => { return ( <button type="button" key={key} onClick={this.vote.bind(this, option.name)} className="btn btn-default btn-lg btn-block">{option.displayName}</button> ); }); return ( <div> <h1>Vote</h1> <div className="btn-block btn-group-vertical" role="group" aria-label="..."> {buttons} </div> </div> ); } }
src/index.js
pixel-glyph/better-reads
import React from 'react'; import { render } from 'react-dom'; import { BrowserRouter as Router, Route } from 'react-router-dom'; import App from './components/App'; import registerServiceWorker from './registerServiceWorker'; import './styles/css/style.css'; const Root = () => { return ( <Router> <div> <Route path="/" component={App}/> </div> </Router> ) }; render(<Root/>, document.getElementById('root')); registerServiceWorker();
src/app/components/content-blocks/ProjectsGrid/Item.js
honzachalupa/portfolio2017
import React, { Component } from 'react'; import { Link } from 'react-router-dom'; import logger from './../../../modules/logger'; import getClassList from './../../../modules/class-list'; export default class Item extends Component { render() { const { id, name, description, previewImage, company } = this.props; const descriptionCleaned = description.replace(/<.+?>/g, ''); const image = (typeof previewImage === 'string') ? { url: previewImage, description: null, aspectRatio: 'landscape' } : previewImage; const companyBlock = company ? <img src={company.logo} className="company-logo" alt={`${company.name} logo`} /> : null; return ( <li data-component="ContentBlock_ProjectsGridItem" role="article"> <Link to={`/projects/${id}`} title={`Show details for ${name} project`}> <div className={getClassList('image', image.aspectRatio)} style={{ backgroundImage: `url('${image.url}')` }} data-aspect-ratio="3:2" data-aspect-ratio-mobile="16:10"> {companyBlock} </div> <h3 className="headline">{name}</h3> <p className={getClassList('description', (descriptionCleaned.length > 160) ? 'fadeout' : null)}>{descriptionCleaned}</p> </Link> </li> ); } }
analysis/rogue/src/FinisherTracker.js
yajinni/WoWAnalyzer
import React from 'react'; import SPELLS from 'common/SPELLS'; import { formatPercentage } from 'common/format'; import RESOURCE_TYPES from 'game/RESOURCE_TYPES'; import Analyzer, { SELECTED_PLAYER } from 'parser/core/Analyzer'; import { t } from '@lingui/macro'; import Events from 'parser/core/Events'; import ComboPointTracker from './ComboPointTracker'; const MINOR_THRESHOLD = 0.05; const AVERAGE_THRESHOLD = 0.1; const MAJOR_THRESHOLD = 0.2; class FinisherTracker extends Analyzer { get maximumComboPoints() { return this.comboPointTracker.maxResource; } get totalFinisherCount() { return this.comboPointTracker.spendersCasts; } get finisherInefficiency() { return this.inefficientFinisherCount / this.totalFinisherCount; } get suggestionThresholds() { return { actual: this.finisherInefficiency, isGreaterThan: { minor: MINOR_THRESHOLD, average: AVERAGE_THRESHOLD, major: MAJOR_THRESHOLD, }, style: 'percentage', }; } static dependencies = { comboPointTracker: ComboPointTracker, }; inefficientFinisherCount = 0; constructor(options) { super(options); this.addEventListener(Events.SpendResource.by(SELECTED_PLAYER), this.onSpendResource); } /** * IMPLEMENTME * This is where logic is implemented for deciding how many combo points should be used for finishers. * @returns {number} The minimum number of combo points for finishers; CP spends less than this number are considered inefficient. */ recommendedFinisherPoints() { const points = this.maximumComboPoints; return points; } /** * IMPLEMENTME * Return spec specific suggestion text or JSX node here. */ extraSuggestion() { return ''; } /** * IMPLEMENTME * This can be overridden to change the suggestion icon to be something relevant to the spec. */ suggestionIcon() { return SPELLS.EVISCERATE.icon; } onSpendResource(event) { const spent = event.resourceChange; if (event.resourceChangeType !== RESOURCE_TYPES.COMBO_POINTS.id) { return; } if (spent < this.recommendedFinisherPoints()) { this.inefficientFinisherCount += 1; } } suggestions(when) { when(this.suggestionThresholds).addSuggestion((suggest, actual, recommended) => suggest(<React.Fragment>Try to use your finishers at {this.maximumComboPoints} combo points. {this.extraSuggestion()}</React.Fragment>) .icon(this.suggestionIcon()) .actual(t({ id: "rogue.shared.suggestions.finishers.efficiency", message: `${formatPercentage(actual)}% (${this.inefficientFinisherCount} out of ${this.totalFinisherCount}) inefficient casts` })) .recommended(`<${formatPercentage(recommended)}% is recommended`)); } } export default FinisherTracker;
src/components/common/SimpleEditor/Schema/Blocks/CommentNode.js
anztrax/simple-image-server-frontend
import React from 'react'; export default class CommentNode extends React.Component{ static get nodeType(){ return 'comment'; } constructor(props){ super(props); } render(){ const { data } = this.props.node; const comment = data.get('comment'); return ( <span style={{ borderBottom : '4px solid #FFCF1F', background: '#FFCF1F'}} data-comment={comment}> {this.props.children} </span> ) } }
nlyyAPP/component/药物管理/仓库/分配方案/MLZgjhqdfpQD.js
a497500306/nlyy_APP
/** * Sample React Native App * https://github.com/facebook/react-native * @flow */ import React, { Component } from 'react'; import { AppRegistry, StyleSheet, Text, View, TouchableOpacity, Navigator, TextInput, ActivityIndicator, Alert, ListView, } from 'react-native'; var Dimensions = require('Dimensions'); var {width, height} = Dimensions.get('window'); var settings = require('../../../../settings'); var MLNavigatorBar = require('../../../MLNavigatorBar/MLNavigatorBar'); var Users = require('../../../../entity/Users'); var MLActivityIndicatorView = require('../../../MLActivityIndicatorView/MLActivityIndicatorView'); var MLTableCell = require('../../../MLTableCell/MLTableCell'); var Ywqd = require('../MLYwqd'); var FPChangku = require('../保存数据/FPChangku'); var FPZhongxin = require('../保存数据/FPZhongxin'); var FPQDData = require('../保存数据/FPQDData'); var FPZgjhqdfp = require('../保存数据/FPZgjhqdfp'); var Changku = require('../../../../entity/Changku'); import Icon from 'react-native-vector-icons/FontAwesome'; var ZgjhqdfpQD = React.createClass({ //初始化设置 getInitialState() { return { //ListView设置 dataSource: null, animating: true,//是否显示菊花 title:'确 定', tableData:[], xuanzhongData:[] } }, //耗时操作,网络请求 componentDidMount(){ //发送登录网络请求 fetch(settings.fwqUrl + "/app/getAllDrug", { method: 'POST', headers: { 'Accept': 'application/json; charset=utf-8', 'Content-Type': 'application/json', }, body: JSON.stringify({ StudyID : Users.Users[0].StudyID, Users : Users.Users[0], Address : FPChangku.FPChangku == null ? FPZhongxin.FPZhongxin : FPChangku.FPChangku, Type : FPChangku.FPChangku == null ? 2 : 1, DepotGNYN : Changku.Changku == null ? 0 : Changku.Changku.DepotGNYN,//是否为主仓库:1是,0不是 DepotBrYN : Changku.Changku == null ? 0 : Changku.Changku.DepotBrYN,//是否为分仓库:1是,0不是 DepotId : Changku.Changku == null ? 0 : Changku.Changku.id, }) }) .then((response) => response.json()) .then((responseJson) => { if (responseJson.isSucceed != 400){ //移除等待 this.setState({animating:false}); }else{ //ListView设置 var tableData = []; for (var i = 0 ; i < responseJson.data.length ; i++){ var changku = responseJson.data[i]; for(var j = 0 ; j < FPZgjhqdfp.FPZgjhqdfp.length ; j++){ if (changku.id == FPZgjhqdfp.FPZgjhqdfp[j].id){ changku.isSelected = true this.state.xuanzhongData.push(changku.id) } } tableData.push(changku) } this.state.tableData = tableData; var ds = new ListView.DataSource({rowHasChanged:(r1, r2) => r1 !== r2}); this.setState({dataSource: ds.cloneWithRows(this.state.tableData)}); //移除等待 this.setState({animating:false}); } }) .catch((error) => {//错误 //移除等待,弹出错误 this.setState({animating:false}); //错误 Alert.alert( '提示:', '请检查您的网络', [ {text: '确定'} ] ) }); }, render() { if (this.state.animating == true){ return ( <View style={styles.container}> <MLNavigatorBar title={'逐个结合区段分配'} isBack={true} backFunc={() => { this.props.navigator.pop() }} leftTitle={'首页'} leftFunc={()=>{ this.props.navigator.popToRoute(this.props.navigator.getCurrentRoutes()[1]) }}/> {/*设置完了加载的菊花*/} <MLActivityIndicatorView /> </View> ); }else{ return ( <View style={styles.container}> <MLNavigatorBar title={'逐个结合区段分配'} isBack={true} backFunc={() => { this.props.navigator.pop() }} leftTitle={'首页'} leftFunc={()=>{ this.props.navigator.popToRoute(this.props.navigator.getCurrentRoutes()[1]) }}/> <ListView dataSource={this.state.dataSource}//数据源 renderRow={this.renderRow} /> <TouchableOpacity style={styles.dengluBtnStyle} onPress={this.getLogin}> <Text style={{color:'white',fontSize: 14,marginLeft:15}}> {this.state.title} </Text> <ActivityIndicator animating={this.state.animating} style={[styles.centering, {height: 30}]} size="small" color="white" /> </TouchableOpacity> </View> ); } }, //返回具体的cell renderRow(rowData,sectionID, rowID){ if (this.state.tableData[rowID].isSelected == true){ return( <TouchableOpacity onPress={()=>{ this.state.tableData[rowID].isSelected = !this.state.tableData[rowID].isSelected console.log('取消添加' + this.state.tableData[rowID].isSelected) var ds = new ListView.DataSource({rowHasChanged:(r1, r2) => r1 !== r2}); this.setState({dataSource: ds.cloneWithRows(this.state.tableData)}); //把id从数组中拿出来 console.log(this.state.tableData[rowID].id) var jj = 0; for(var i = 0 ; i < this.state.xuanzhongData.length ; i++){ if (this.state.xuanzhongData[i] == this.state.tableData[rowID].id){ this.state.xuanzhongData.splice(i,1); } } if (this.state.xuanzhongData.length == 0){ this.state.title = '确 定' }else{ this.state.title = '确 定( ' + this.state.xuanzhongData.length + ' )' } console.log(this.state.xuanzhongData) }}> <MLTableCell title={rowData.DrugNum} isArrow = {false} iconTitl='check' iconColor='rgba(0,136,212,1.0)'/> </TouchableOpacity> ) }else{ this.state.tableData[rowID].isSelected = false; return( <TouchableOpacity onPress={()=>{ this.state.tableData[rowID].isSelected = !this.state.tableData[rowID].isSelected console.log('添加进去' + this.state.tableData[rowID].isSelected) var ds = new ListView.DataSource({rowHasChanged:(r1, r2) => r1 !== r2}); this.setState({dataSource: ds.cloneWithRows(this.state.tableData)}); //把id添加到数组中 this.state.xuanzhongData.push(this.state.tableData[rowID].id) console.log(this.state.xuanzhongData) this.state.title = '确 定( ' + this.state.xuanzhongData.length + ' )' }}> <MLTableCell title={rowData.DrugNum} isArrow = {false}/> </TouchableOpacity> ) } }, //点击确定 getLogin(){ if (this.state.xuanzhongData.length != 0){ this.setState({animating:true}); //发送网络请求 fetch(settings.fwqUrl + "/app/getZgfp", { method: 'POST', headers: { 'Accept': 'application/json; charset=utf-8', 'Content-Type': 'application/json', }, body: JSON.stringify({ ids: this.state.xuanzhongData, StudyID:Users.Users[0].StudyID, Users : Users.Users[0], Address : FPChangku.FPChangku == null ? FPZhongxin.FPZhongxin : FPChangku.FPChangku, Type : FPChangku.FPChangku == null ? 2 : 1, DepotGNYN : Changku.Changku == null == null ? 0 : Changku.Changku.DepotGNYN,//是否为主仓库:1是,0不是 DepotBrYN : Changku.Changku == null == null ? 0 : Changku.Changku.DepotBrYN,//是否为分仓库:1是,0不是 DepotId : Changku.Changku == null == null ? 0 : Changku.Changku.id, }) }) .then((response) => response.json()) .then((responseJson) => { this.setState({animating:false}); if (responseJson.isSucceed != 400){ //错误 Alert.alert( '提示:', responseJson.msg, [ {text: '确定'} ] ) }else { this.setState({animating:false}); FPQDData.FPQDData = responseJson.data // 页面的切换 this.props.navigator.push({ name:'分配清单', component: Ywqd, // 具体路由的版块 }); } }) .catch((error) => {//错误 this.setState({animating:false}); console.log(error), //错误 Alert.alert( '提示:', '请检查您的网络111', [ {text: '确定'} ] ) }); }else{ //错误 Alert.alert( '提示:', '请选择最少一个药物号', [ {text: '确定'} ] ) } } }); const styles = StyleSheet.create({ container: { flex: 1, // justifyContent: 'center', // alignItems: 'center', backgroundColor: 'rgba(233,234,239,1.0)', }, dengluBtnStyle:{ // 设置主轴的方向 flexDirection:'row', // 垂直居中 ---> 设置侧轴的对齐方式 alignItems:'center', // 设置主轴的对齐方式 justifyContent:'center', width:width - 40, marginTop:10, marginLeft:20, height:40, backgroundColor:'rgba(0,136,212,1.0)', // 设置圆角 borderRadius:5, marginBottom:10 }, }); // 输出组件类 module.exports = ZgjhqdfpQD;
app/javascript/mastodon/features/ui/components/report_modal.js
imas/mastodon
import React from 'react'; import { connect } from 'react-redux'; import { changeReportComment, changeReportForward, submitReport } from '../../../actions/reports'; import { expandAccountTimeline } from '../../../actions/timelines'; import PropTypes from 'prop-types'; import ImmutablePropTypes from 'react-immutable-proptypes'; import { makeGetAccount } from '../../../selectors'; import { defineMessages, FormattedMessage, injectIntl } from 'react-intl'; import StatusCheckBox from '../../report/containers/status_check_box_container'; import { OrderedSet } from 'immutable'; import ImmutablePureComponent from 'react-immutable-pure-component'; import Button from '../../../components/button'; import Toggle from 'react-toggle'; import IconButton from '../../../components/icon_button'; const messages = defineMessages({ close: { id: 'lightbox.close', defaultMessage: 'Close' }, placeholder: { id: 'report.placeholder', defaultMessage: 'Additional comments' }, submit: { id: 'report.submit', defaultMessage: 'Submit' }, }); const makeMapStateToProps = () => { const getAccount = makeGetAccount(); const mapStateToProps = state => { const accountId = state.getIn(['reports', 'new', 'account_id']); return { isSubmitting: state.getIn(['reports', 'new', 'isSubmitting']), account: getAccount(state, accountId), comment: state.getIn(['reports', 'new', 'comment']), forward: state.getIn(['reports', 'new', 'forward']), statusIds: OrderedSet(state.getIn(['timelines', `account:${accountId}:with_replies`, 'items'])).union(state.getIn(['reports', 'new', 'status_ids'])), }; }; return mapStateToProps; }; export default @connect(makeMapStateToProps) @injectIntl class ReportModal extends ImmutablePureComponent { static propTypes = { isSubmitting: PropTypes.bool, account: ImmutablePropTypes.map, statusIds: ImmutablePropTypes.orderedSet.isRequired, comment: PropTypes.string.isRequired, forward: PropTypes.bool, dispatch: PropTypes.func.isRequired, intl: PropTypes.object.isRequired, }; handleCommentChange = e => { this.props.dispatch(changeReportComment(e.target.value)); } handleForwardChange = e => { this.props.dispatch(changeReportForward(e.target.checked)); } handleSubmit = () => { this.props.dispatch(submitReport()); } handleKeyDown = e => { if (e.keyCode === 13 && (e.ctrlKey || e.metaKey)) { this.handleSubmit(); } } componentDidMount () { this.props.dispatch(expandAccountTimeline(this.props.account.get('id'), { withReplies: true })); } componentWillReceiveProps (nextProps) { if (this.props.account !== nextProps.account && nextProps.account) { this.props.dispatch(expandAccountTimeline(nextProps.account.get('id'), { withReplies: true })); } } render () { const { account, comment, intl, statusIds, isSubmitting, forward, onClose } = this.props; if (!account) { return null; } const domain = account.get('acct').split('@')[1]; return ( <div className='modal-root__modal report-modal'> <div className='report-modal__target'> <IconButton className='report-modal__close' title={intl.formatMessage(messages.close)} icon='times' onClick={onClose} size={20} /> <FormattedMessage id='report.target' defaultMessage='Report {target}' values={{ target: <strong>{account.get('acct')}</strong> }} /> </div> <div className='report-modal__container'> <div className='report-modal__comment'> <p><FormattedMessage id='report.hint' defaultMessage='The report will be sent to your server moderators. You can provide an explanation of why you are reporting this account below:' /></p> <textarea className='setting-text light' placeholder={intl.formatMessage(messages.placeholder)} value={comment} onChange={this.handleCommentChange} onKeyDown={this.handleKeyDown} disabled={isSubmitting} autoFocus /> {domain && ( <div> <p><FormattedMessage id='report.forward_hint' defaultMessage='The account is from another server. Send an anonymized copy of the report there as well?' /></p> <div className='setting-toggle'> <Toggle id='report-forward' checked={forward} disabled={isSubmitting} onChange={this.handleForwardChange} /> <label htmlFor='report-forward' className='setting-toggle__label'><FormattedMessage id='report.forward' defaultMessage='Forward to {target}' values={{ target: domain }} /></label> </div> </div> )} <Button disabled={isSubmitting} text={intl.formatMessage(messages.submit)} onClick={this.handleSubmit} /> </div> <div className='report-modal__statuses'> <div> {statusIds.map(statusId => <StatusCheckBox id={statusId} key={statusId} disabled={isSubmitting} />)} </div> </div> </div> </div> ); } }
src/scripts/Loader.js
Ribeiro/yoda
'use strict'; import React from 'react'; import Join from 'react/lib/joinClasses'; export default React.createClass({ getDefaultProps() { return { size: 32, stroke: 6, direction: 'col', message: 'Loading...' }; }, renderSpinner(props) { let spinClass = Join('spinner-container', props.direction); return ( <div className={spinClass}> <svg className="spinner" width={props.size} height={props.size} viewBox="0 0 66 66"> <circle className="path" fill="none" strokeWidth={props.stroke} strokeLinecap="square" cx="33" cy="33" r="30"></circle> </svg> {this.renderMessage(props.mesage)} </div> ); }, renderMessage(msg) { var msg = msg || this.props.message; return (<span className="spinner-message">{msg}</span>); }, render() { var size = this.props.size + 'px'; return ( <div className="no-results"> {this.renderSpinner(this.props)} </div> ); } });
analysis/paladinprotection/src/modules/features/WordOfGloryTiming.js
yajinni/WoWAnalyzer
import React from 'react'; import SelfHealTimingGraph from 'parser/shared/modules/features/SelfHealTimingGraph'; import SPELLS from 'common/SPELLS'; class WordOfGloryTiming extends SelfHealTimingGraph { constructor(...args) { super(...args); this.selfHealSpell = SPELLS.WORD_OF_GLORY; this.tabTitle = "Selfheal Timing"; this.tabURL = "selfheal-timings"; } render() { return ( <SelfHealTimingGraph /> ); } } export default WordOfGloryTiming;
src/index.js
jperocho/webpack-react-boilerplate
import React, { Component } from 'react'; import ReactDOM from 'react-dom'; import { BrowserRouter } from 'react-router-dom'; const css = require('./app.scss'); // Components import MainNav from './components/main-nav'; import Routes from './routes'; class App extends Component { render() { return ( <BrowserRouter> <div> <MainNav /> <Routes /> </div> </BrowserRouter> ) } } ReactDOM.render( <App/>, document.querySelector('.container') );
client/extensions/woocommerce/components/list/list-item/index.js
Automattic/woocommerce-connect-client
/** @format */ /** * External dependencies */ import React from 'react'; import classNames from 'classnames'; const ListItem = ( { children, className } ) => { return <li className={ classNames( 'list-item', className ) }>{ children }</li>; }; export default ListItem;
src/components/examples/Clock.js
heartziq/Allimnee
import React, { Component } from 'react'; class Clock extends Component { constructor(props) { super(props); this.state = { date: new Date() }; this.color = [ "#ff5733", "#900C3F", "#33ceff", " #f333ff ", "#34b636", " #e24faf ", " #e24fa4 ", " #32a065 ", " #9bd32b ", " #d36d2b " ]; } tick() { this.setState({ date: new Date() }); } componentDidMount() { this.timerId = setInterval(() => this.tick(), 1000); } componentDidUpdate() { console.log(`color is updated!`) } componentWillUnmount() { clearInterval(this.timerId); } render() { return ( <div> <h1> <span style={{ color: this.color[ this.state.date.toLocaleTimeString().match(/\d\s+[P|A]M/)[0].split(" ")[0] ] }} > Hello </span> , world! </h1> <h2>It is {this.state.date.toLocaleTimeString()}.</h2> </div> ); } } export default Clock;
node_modules/@material-ui/core/es/TablePagination/TablePaginationActions.js
pcclarke/civ-techs
import _extends from "@babel/runtime/helpers/extends"; import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose"; import React from 'react'; import PropTypes from 'prop-types'; import KeyboardArrowLeft from '../internal/svg-icons/KeyboardArrowLeft'; import KeyboardArrowRight from '../internal/svg-icons/KeyboardArrowRight'; import withTheme from '../styles/withTheme'; import IconButton from '../IconButton'; /** * @ignore - internal component. */ var _ref = React.createElement(KeyboardArrowRight, null); var _ref2 = React.createElement(KeyboardArrowLeft, null); var _ref3 = React.createElement(KeyboardArrowLeft, null); var _ref4 = React.createElement(KeyboardArrowRight, null); const TablePaginationActions = React.forwardRef(function TablePaginationActions(props, ref) { const { backIconButtonProps, count, nextIconButtonProps, onChangePage, page, rowsPerPage, theme } = props, other = _objectWithoutPropertiesLoose(props, ["backIconButtonProps", "count", "nextIconButtonProps", "onChangePage", "page", "rowsPerPage", "theme"]); const handleBackButtonClick = event => { onChangePage(event, page - 1); }; const handleNextButtonClick = event => { onChangePage(event, page + 1); }; return React.createElement("div", _extends({ ref: ref }, other), React.createElement(IconButton, _extends({ onClick: handleBackButtonClick, disabled: page === 0, color: "inherit" }, backIconButtonProps), theme.direction === 'rtl' ? _ref : _ref2), React.createElement(IconButton, _extends({ onClick: handleNextButtonClick, disabled: page >= Math.ceil(count / rowsPerPage) - 1, color: "inherit" }, nextIconButtonProps), theme.direction === 'rtl' ? _ref3 : _ref4)); }); process.env.NODE_ENV !== "production" ? TablePaginationActions.propTypes = { /** * Properties applied to the back arrow [`IconButton`](/api/icon-button/) element. */ backIconButtonProps: PropTypes.object, /** * The total number of rows. */ count: PropTypes.number.isRequired, /** * Properties applied to the next arrow [`IconButton`](/api/icon-button/) element. */ nextIconButtonProps: PropTypes.object, /** * Callback fired when the page is changed. * * @param {object} event The event source of the callback * @param {number} page The page selected */ onChangePage: PropTypes.func.isRequired, /** * The zero-based index of the current page. */ page: PropTypes.number.isRequired, /** * The number of rows per page. */ rowsPerPage: PropTypes.number.isRequired, /** * @ignore */ theme: PropTypes.object.isRequired } : void 0; export default withTheme(TablePaginationActions);
react-advanced-boilerplate/app/components/twitter/Trend.js
rwachtler/react-twitstats
import React from 'react'; import {shouldPureComponentUpdate} from 'react-pure-render'; import {connect} from 'react-redux'; import cookie from 'react-cookie'; class Trend extends React.Component { shouldComponentUpdate = shouldPureComponentUpdate; constructor(props) { super(props); } componentWillMount() { } componentWillReceiveProps(nextProps) { } componentDidUpdate(prevProps, prevState) { } render() { const {trendData} = this.props; const {tweet_volume} = trendData; return ( <div key={trendData.name} className="panel trend__container"> <a href={trendData.url} target="_blank"><b>{trendData.name}</b></a> {tweet_volume ? <span className="label info">Tweet volume: {trendData.tweet_volume}</span> : null} </div> ); } } Trend.propTypes = { className: React.PropTypes.string, trendData: React.PropTypes.object }; function select(state) { return {}; } export default connect(select)(Trend);
src/components/Footer/bottom-footer.js
chanceeakin/portfolio-material
import React from 'react'; const BottomFooter = () => ( <div className="md-cell--12 footer-bottom"> <p className="md-text-center">Copyright &copy; Chance Eakin 2016</p> </div> ); export default BottomFooter;
client/src/react/weather/ForecastDay.js
charlesj/Apollo
import React from 'react' import moment from 'moment' import PropTypes from 'prop-types' import DarkSkyIconMap from './DarkSkyIconMapping' import PrecipDisplay from './PrecipDisplay' import WeatherIcon from './WeatherIcon' function ForecastDay(props) { var date = moment.unix(props.f.time) return ( <div className="forecastDay"> <div> {date.format('dddd')} {date.format('MMM Do')} </div> <div className="weatherIcon"> <WeatherIcon icon={DarkSkyIconMap[props.f.icon]} /> </div> <div> L {props.f.temperatureLow}℉ - H {props.f.temperatureHigh}℉ </div> <div className="forecastSummary">{props.f.summary}</div> <PrecipDisplay chance={props.f.precipProbability} precipType={props.f.precipType} /> <div>{Math.round(props.f.humidity * 100)}% humidity</div> </div> ) } ForecastDay.propTypes = { f: PropTypes.object.isRequired, } export default ForecastDay
016/src/components/app.js
StephenGrider/RallyCodingWeekly
import React, { Component } from 'react'; import GoogleMap from './google_map'; export default class App extends Component { constructor(props) { super(props); this.state = { lat: -34.397, lng: 150.644 }; } render() { return ( <div style={{height: '100%'}}> Map me! <button onClick={() => this.setState({ lat: 40.7128, lng: -74.0059 })}> New York </button> <GoogleMap lat={this.state.lat} lng={this.state.lng} /> </div> ); } }
src/svg-icons/action/pan-tool.js
owencm/material-ui
import React from 'react'; import pure from 'recompose/pure'; import SvgIcon from '../../SvgIcon'; let ActionPanTool = (props) => ( <SvgIcon {...props}> <path d="M23 5.5V20c0 2.2-1.8 4-4 4h-7.3c-1.08 0-2.1-.43-2.85-1.19L1 14.83s1.26-1.23 1.3-1.25c.22-.19.49-.29.79-.29.22 0 .42.06.6.16.04.01 4.31 2.46 4.31 2.46V4c0-.83.67-1.5 1.5-1.5S11 3.17 11 4v7h1V1.5c0-.83.67-1.5 1.5-1.5S15 .67 15 1.5V11h1V2.5c0-.83.67-1.5 1.5-1.5s1.5.67 1.5 1.5V11h1V5.5c0-.83.67-1.5 1.5-1.5s1.5.67 1.5 1.5z"/> </SvgIcon> ); ActionPanTool = pure(ActionPanTool); ActionPanTool.displayName = 'ActionPanTool'; ActionPanTool.muiName = 'SvgIcon'; export default ActionPanTool;
src/components/stack-selector/StackSelector.js
yuri/notality
import React from 'react'; import NewStackModal from './NewStackModal'; import StackButton from './StackButton'; import Button from '../ui/Button'; function getStackValue(stacks, id, value) { return stacks.getIn(['byId', id]).toJS()[value]; } const StackSelector = ({ stacks, handlers}) => ( <div className="collections" > <NewStackModal isVisible = { stacks.get('newStackFormIsVisible') } value = { stacks.get('newStackName') } onSubmit = { () => { /* eslint no-console: 0 */ console.log('stacks on submit:', stacks.get('newStackName')); handlers.hideNewStackForm(); handlers.addStack(stacks.get('newStackName')); handlers.setNewStackName(); }} onValue = { (value) => { handlers.setNewStackName(value); }} /> <Button className="btn-outline p0" onClick = { handlers.showNewStackForm }>New Stack</Button> <ul> {stacks.get('ordered').map((id) => ( <li><StackButton name={getStackValue(stacks, id, 'name')} key={getStackValue(stacks, id, 'id')}/></li> ))} </ul> </div> ); export default StackSelector;
client/src/components/Leagues/LeagueItem.js
BenDiuguid/fantasy-fifa
import React from 'react'; import Link from '../styles/Link'; import { compose, withHandlers } from 'recompose'; import { graphql } from 'react-apollo'; import styled from 'styled-components'; import { loader } from 'graphql.macro'; import LeagueJoinButton from './LeagueJoinButton'; import UserQuery from '../UserQuery'; const JOIN_LEAGUE_MUTATION = loader('../../graphql/JoinLeagueMutation.graphql'); const LeagueRow = styled.div` display: flex; justify-content: space-between; align-items: center; padding: ${props => props.theme.spacing}px 0; `; const getStatusText = status => { switch (status) { case 'IDLE': return 'Ready to start'; case 'IN_PROGRESS': return 'Already started'; case 'ENDED': return 'Draft has ended'; case 'PAUSED': return 'Draft is paused'; default: return ''; } }; const LeagueItem = ({ league, joinLeague }) => ( <UserQuery> {({ user }) => { return ( <LeagueRow> <Link to={`/draft/${league.id}`} color={'secondary'}> {league.name} </Link> <p> {league.members.length}/{league.maxSize} Spots </p> <p>{getStatusText(league.status)}</p> <LeagueJoinButton isAlreadyInLeague={ user && league.members.find(m => m.id === user.id) } isFull={league.members.length === league.maxSize} isLoggedIn={user} handleClick={joinLeague} /> </LeagueRow> ); }} </UserQuery> ); const enhanced = compose( graphql(JOIN_LEAGUE_MUTATION, { name: 'joinLeagueMutation' }), withHandlers({ joinLeague: ({ league, joinLeagueMutation }) => () => joinLeagueMutation({ variables: { id: league.id } }), }) )(LeagueItem); export default enhanced;
src/components/dev/DevHud.js
codeforboston/cliff-effects
import React, { Component } from 'react'; import { Menu, Checkbox, Button, Dropdown, } from 'semantic-ui-react'; // PROJECT COMPONENTS import { HeadingWithDetail } from '../details'; // Dev components import { CustomClient } from '../CustomClient'; // DATA import { getLocalizationData } from '../../localization/all'; import { LocalizationReport } from './LocalizationReport.js'; /** Contains all HUD items except 'hide' button * @todo If there are enough dev features for it, * make menu categories collapsible. */ const DevMenu = function ({ devProps, funcs, data, state }) { const langs = getLocalizationData(), // Get copy of localization data langOpts = []; for (let key in langs) { let translations = langs[ key ], lang = { text: translations.langName, key: translations.langCode, value: translations.langCode, }; langOpts.push(lang); } return ( <div className = { `dev-menu` } > <Menu.Item> <Button compact negative size = { `tiny` } className = { `off` } onClick = { funcs.turnOff }> HUD Off </Button> </Menu.Item> <Menu.Item header>Translations</Menu.Item> <Menu.Item> <Checkbox label = { `Mark English translations` } checked = { devProps.english } onChange = { funcs.english } /> </Menu.Item> <Menu.Item> <HeadingWithDetail> <Checkbox label = { `Mark non-English translations` } checked = { devProps.nonEnglish } onChange = { funcs.nonEnglish } /> <span> Note: text that doesn&apos;t have an underline (for reasons) has no translations. </span> </HeadingWithDetail> </Menu.Item> <Menu.Item> <Dropdown fluid search selection scrolling defaultValue = { state.langCode } options = { langOpts } onChange = { funcs.setLanguage } /> </Menu.Item> <Menu.Item header> Client</Menu.Item> <Menu.Item> <CustomClient load = { funcs.loadClient } toRestore = { data.default } /> </Menu.Item> <Menu.Item> <LocalizationReport /> </Menu.Item> <Menu.Item> <HeadingWithDetail> <Checkbox label = { `Disable warning modal` } checked = { devProps.warningOff } onChange = { funcs.warning } /> <span> Note: Uncheck this box to<br /> disable the predictions warning<br /> modal. The modal displays prior<br /> to allowing access to the form.<br /> </span> </HeadingWithDetail> </Menu.Item> </div> ); }; // End <DevMenu> class DevHud extends Component { toggleHiding = () => { let props = this.props, setDev = props.funcs.setDev, devProps = props.devProps; let doShow = !devProps.devHidden; setDev(`devHidden`, doShow); }; toggleEnglish = () => { let setDev = this.props.funcs.setDev, english = this.props.devProps.english; setDev(`english`, !english); }; toggleNonEnglish = () => { let setDev = this.props.funcs.setDev, nonEnglish = this.props.devProps.nonEnglish; setDev(`nonEnglish`, !nonEnglish); }; toggleWarning = () => { let setDev = this.props.funcs.setDev, warning = this.props.devProps.warningOff; setDev(`warningOff`, !warning); }; turnOff = () => { this.props.funcs.setDev(`dev`, false); }; render () { let { devProps, funcs, data, state, } = this.props, devFuncs = { ...funcs, english: this.toggleEnglish, nonEnglish: this.toggleNonEnglish, turnOff: this.turnOff, warning: this.toggleWarning, }; return ( <Menu className = { `dev-hud` } compact vertical> <DevMenu devProps = { devProps } funcs = { devFuncs } data = { data } state = { state } /> <Button className = { `hide` } onClick = { this.toggleHiding }> { devProps.devHidden ? (`Show`) : (`Hide`) } </Button> </Menu> ); } }; export { DevHud, DevMenu, };
src/svg-icons/action/flip-to-front.js
ruifortes/material-ui
import React from 'react'; import pure from 'recompose/pure'; import SvgIcon from '../../SvgIcon'; let ActionFlipToFront = (props) => ( <SvgIcon {...props}> <path d="M3 13h2v-2H3v2zm0 4h2v-2H3v2zm2 4v-2H3c0 1.1.89 2 2 2zM3 9h2V7H3v2zm12 12h2v-2h-2v2zm4-18H9c-1.11 0-2 .9-2 2v10c0 1.1.89 2 2 2h10c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 12H9V5h10v10zm-8 6h2v-2h-2v2zm-4 0h2v-2H7v2z"/> </SvgIcon> ); ActionFlipToFront = pure(ActionFlipToFront); ActionFlipToFront.displayName = 'ActionFlipToFront'; ActionFlipToFront.muiName = 'SvgIcon'; export default ActionFlipToFront;
docs/src/pages/demos/buttons/RaisedButtons.js
cherniavskii/material-ui
import React from 'react'; import PropTypes from 'prop-types'; import { withStyles } from 'material-ui/styles'; import Button from 'material-ui/Button'; const styles = theme => ({ button: { margin: theme.spacing.unit, }, input: { display: 'none', }, }); function RaisedButtons(props) { const { classes } = props; return ( <div> <Button variant="raised" className={classes.button}> Default </Button> <Button variant="raised" color="primary" className={classes.button}> Primary </Button> <Button variant="raised" color="secondary" className={classes.button}> Secondary </Button> <Button variant="raised" color="secondary" disabled className={classes.button}> Disabled </Button> <input accept="image/*" className={classes.input} id="raised-button-file" multiple type="file" /> <label htmlFor="raised-button-file"> <Button variant="raised" component="span" className={classes.button}> Upload </Button> </label> </div> ); } RaisedButtons.propTypes = { classes: PropTypes.object.isRequired, }; export default withStyles(styles)(RaisedButtons);
js/jqwidgets/demos/react/app/treegrid/datagrouping/app.js
luissancheza/sice
import React from 'react'; import ReactDOM from 'react-dom'; import JqxTreeGrid from '../../../jqwidgets-react/react_jqxtreegrid.js'; class App extends React.Component { componentDidMount() { setTimeout(() => { this.refs.myTreeGrid.expandRow(0); }) } render () { // prepare the data let source = { datatype: 'xml', datafields: [ { name: 'CompanyName', map: 'm\\:properties>d\\:CompanyName' }, { name: 'ContactName', map: 'm\\:properties>d\\:ContactName' }, { name: 'ContactTitle', map: 'm\\:properties>d\\:ContactTitle' }, { name: 'City', map: 'm\\:properties>d\\:City' }, { name: 'PostalCode', map: 'm\\:properties>d\\:PostalCode' }, { name: 'Country', map: 'm\\:properties>d\\:Country' } ], hierarchy: { groupingDataFields: [ { name: 'Country' } ] }, root: 'entry', record: 'content', id: { name: 'CustomerID', map: 'm\\:properties>d\\:CustomerID' }, url: '../sampledata/customers.xml' }; let dataAdapter = new $.jqx.dataAdapter(source); // create Tree Grid let icons = (rowKey, rowData) => { let level = rowData.level; if (level == 0) { // each group row has a label member that contains the information displayed on the group row. var country = rowData.label; return '../../images/' + $.trim(country.toLowerCase()) + '.png'; } return false; } let columns = [ { text: 'City', dataField: 'City', width: 250 }, { text: 'Company Name', dataField: 'CompanyName', minWidth: 100, width: 200 }, { text: 'Contact Name', dataField: 'ContactName', width: 150 }, { text: 'Contact Title', dataField: 'ContactTitle', width: 300 }, { text: 'Postal Code', dataField: 'PostalCode', width: 120 } ]; return ( <JqxTreeGrid ref='myTreeGrid' width={850} source={dataAdapter} pageable={true} columnsResize={true} altRows={true} icons={icons} columns={columns} /> ) } } ReactDOM.render(<App />, document.getElementById('app'));
app/components/home.js
yaolei/Samoyed
import React from 'react'; import ReactDOM from 'react-dom'; import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider'; import AppBar from 'material-ui/AppBar'; import {grey600} from 'material-ui/styles/colors'; import RaisedButton from 'material-ui/RaisedButton'; import getMuiTheme from 'material-ui/styles/getMuiTheme'; const muiTheme = getMuiTheme({ palette: { textColor: grey600, }, appBar: { height: 50, color: '#757575', }, }); export default class Home extends React.Component { constructor(props) { super(props); } componentDidMount() { $('#leftDrawerDiv').show(); $('.mainPage').show(); // when jump from admin page need to reset index style var leftNavWidth = $('.leftNavHeight').width(); $('#root2').css('margin-left', leftNavWidth + 2); $('#root3').hide(); } render() { return( <MuiThemeProvider muiTheme={muiTheme} > <AppBar title="Alpaca" style={{height: 'calc(100% - 64px)'}} /> </MuiThemeProvider> ); } }
modules/RouteContext.js
samidarko/react-router
import React from 'react' const { object } = React.PropTypes /** * The RouteContext mixin provides a convenient way for route * components to set the route in context. This is needed for * routes that render elements that want to use the Lifecycle * mixin to prevent transitions. */ const RouteContext = { propTypes: { route: object.isRequired }, childContextTypes: { route: object.isRequired }, getChildContext() { return { route: this.props.route } } } export default RouteContext
src/views/uploadview.react.js
Cron-J/CSV-REE
import React from 'react'; import Fileuploader from './fileuploader.react'; class UploadView extends React.Component { constructor(props) { super(props); } componentWillReceiveProps(nextProps) { this.props = nextProps; } onupload = (file) => { if (this.props.onDataSubmit) { this.props.onDataSubmit(file); } } render() { return ( <div className="row"> <Fileuploader fileinfo={this.props.data.fileinfo} onFileupload={this.onupload} fileFormat={this.props.data.fileFormats} /> </div> ); } } UploadView.propTypes = { data: React.PropTypes.func, onDataSubmit: React.PropTypes.func }; export default UploadView;
src/routes/Mixer/components/Mixer.js
rkram5424/BentoBeats
import React from 'react' export const HomeView = () => ( <div> <h4>Mixer!</h4> </div> ) export default HomeView
src/app/containers/ButtonBar.js
lmcjt37/kulor-reactify
import React from 'react'; import Button from '../components/Button'; import ColourHelper from '../helper/colourHelper'; import themedButton from '../theme/themedButton'; export default class ButtonBar extends React.Component { constructor(props) { super(props); } handleClick(name) { switch(name){ case "random": this.props.onStateChange(ColourHelper.randomise()); break; case "lighten": this.props.onStateChange(ColourHelper.lighten(this.props.hex, this.props.variance)); break; case "darken": this.props.onStateChange(ColourHelper.darken(this.props.hex, this.props.variance)); break; } } getButtons() { let array = []; for (var prop in this.props.features) { array.push(prop); } return array.map(name => { return ( <Button key={name} theme={themedButton} onMouseUp={() => this.handleClick(name)} {...this.props.features[name]} /> ); }); } render() { return ( <div className={this.props.buttonBarClasses}> {this.getButtons()} </div> ); } }
app/extensions/safe/auth-web-app/components/app_list_item.js
joshuef/peruse
import PropTypes from 'prop-types'; import React, { Component } from 'react'; import { Translate } from 'react-redux-i18n'; export default class ListItem extends Component { static propTypes = { data: PropTypes.shape({}), isDefault: PropTypes.bool, loading: PropTypes.bool, revokeApp: PropTypes.func }; constructor() { super(); this.toggleList = this.toggleList.bind(this); } toggleList(e) { e.preventDefault(); const toggleClassName = 'expand'; if (this.listItem.classList.contains(toggleClassName)) { return this.listItem.classList.remove(toggleClassName); } return this.listItem.classList.add(toggleClassName); } render() { const { loading, isDefault, data, revokeApp } = this.props; if (loading) { return ( <div className="app-list-i default"><Translate value="Fetching apps" />...</div> ); } if (isDefault) { return ( <div className="app-list-i default"><Translate value="No Apps Found" /></div> ); } return ( <div className="app-list-i" ref={(c) => { this.listItem = c; }} onClick={this.toggleList} > <div className="icn"> <span>{data.app_info.name[0]}</span> </div> <div className="ctn"> <div className="i-cnt"> <div className="title"> <span>{data.app_info.name}</span> </div> <div className="vendor"> <span>{data.app_info.vendor}</span> </div> </div> <div className="app-list-detail"> <div className="permission"> <span className="permission-h"><Translate value="Permissions" /></span> <ul> { data.containers ? data.containers.map((container, index) => ( <li key={index}> <span className="permission-icn">{''}</span> <span className="permission-title">{container.cont_name}</span> { (container.access && container.access.length > 0) ? ( <div className="permission-i-ls"> <ul> { container.access.map((item, i) => ( <li key={i}>{item}</li> )) } </ul> </div> ) : null } </li> ) ) : ( <li> <span className="permission-icn safe-drive">{''}</span> <span className="permission-title">No permission</span> </li> ) } </ul> </div> </div> </div> <div className="opts"> <div className="opt"> <button type="button" className="btn" onClick={(e) => { e.stopPropagation(); e.nativeEvent.stopImmediatePropagation(); revokeApp(data.app_info.id); }} ><Translate value="Revoke Access" /></button> </div> </div> </div> ); } }
docs/src/app/components/pages/components/IconMenu/ExampleScrollable.js
ArcanisCz/material-ui
import React from 'react'; import IconMenu from 'material-ui/IconMenu'; import MenuItem from 'material-ui/MenuItem'; import IconButton from 'material-ui/IconButton'; import MapsPlace from 'material-ui/svg-icons/maps/place'; /** * The `maxHeight` property limits the height of the menu, above which it will be scrollable. */ const IconMenuExampleScrollable = () => ( <IconMenu iconButtonElement={<IconButton><MapsPlace /></IconButton>} anchorOrigin={{horizontal: 'left', vertical: 'top'}} targetOrigin={{horizontal: 'left', vertical: 'top'}} maxHeight={272} > <MenuItem value="AL" primaryText="Alabama" /> <MenuItem value="AK" primaryText="Alaska" /> <MenuItem value="AZ" primaryText="Arizona" /> <MenuItem value="AR" primaryText="Arkansas" /> <MenuItem value="CA" primaryText="California" /> <MenuItem value="CO" primaryText="Colorado" /> <MenuItem value="CT" primaryText="Connecticut" /> <MenuItem value="DE" primaryText="Delaware" /> <MenuItem value="DC" primaryText="District Of Columbia" /> <MenuItem value="FL" primaryText="Florida" /> <MenuItem value="GA" primaryText="Georgia" /> <MenuItem value="HI" primaryText="Hawaii" /> <MenuItem value="ID" primaryText="Idaho" /> <MenuItem value="IL" primaryText="Illinois" /> <MenuItem value="IN" primaryText="Indiana" /> <MenuItem value="IA" primaryText="Iowa" /> <MenuItem value="KS" primaryText="Kansas" /> <MenuItem value="KY" primaryText="Kentucky" /> <MenuItem value="LA" primaryText="Louisiana" /> <MenuItem value="ME" primaryText="Maine" /> <MenuItem value="MD" primaryText="Maryland" /> <MenuItem value="MA" primaryText="Massachusetts" /> <MenuItem value="MI" primaryText="Michigan" /> <MenuItem value="MN" primaryText="Minnesota" /> <MenuItem value="MS" primaryText="Mississippi" /> <MenuItem value="MO" primaryText="Missouri" /> <MenuItem value="MT" primaryText="Montana" /> <MenuItem value="NE" primaryText="Nebraska" /> <MenuItem value="NV" primaryText="Nevada" /> <MenuItem value="NH" primaryText="New Hampshire" /> <MenuItem value="NJ" primaryText="New Jersey" /> <MenuItem value="NM" primaryText="New Mexico" /> <MenuItem value="NY" primaryText="New York" /> <MenuItem value="NC" primaryText="North Carolina" /> <MenuItem value="ND" primaryText="North Dakota" /> <MenuItem value="OH" primaryText="Ohio" /> <MenuItem value="OK" primaryText="Oklahoma" /> <MenuItem value="OR" primaryText="Oregon" /> <MenuItem value="PA" primaryText="Pennsylvania" /> <MenuItem value="RI" primaryText="Rhode Island" /> <MenuItem value="SC" primaryText="South Carolina" /> <MenuItem value="SD" primaryText="South Dakota" /> <MenuItem value="TN" primaryText="Tennessee" /> <MenuItem value="TX" primaryText="Texas" /> <MenuItem value="UT" primaryText="Utah" /> <MenuItem value="VT" primaryText="Vermont" /> <MenuItem value="VA" primaryText="Virginia" /> <MenuItem value="WA" primaryText="Washington" /> <MenuItem value="WV" primaryText="West Virginia" /> <MenuItem value="WI" primaryText="Wisconsin" /> <MenuItem value="WY" primaryText="Wyoming" /> </IconMenu> ); export default IconMenuExampleScrollable;
examples/todomvc/index.js
pauldijou/redux-act
import 'babel-polyfill' import React from 'react' import { render } from 'react-dom' import { Provider } from 'react-redux' import App from './containers/App' import configureStore from './store/configureStore' import 'todomvc-app-css/index.css' const store = configureStore() render( <Provider store={store}> <App /> </Provider>, document.getElementById('root') )
src/components/polls_index.js
kaloudiyi/VotePlexClient
import _ from 'lodash'; import React, { Component } from 'react'; import { Grid, Row, Col } from 'react-bootstrap'; import PropTypes from 'prop-types'; import PollDetail from './poll_detail'; import PollList from './poll_list'; import Auth from '../Auth/Auth'; class PollsIndex extends Component { constructor() { super(); this.state = { curPoll: null }; } onChildChanged(newPoll) { this.setState({ curPoll: newPoll }); } render() { return ( <div> <Grid> <Row> <Col xs={12} md={3}> <PollList callbackParent={newPoll => this.onChildChanged(newPoll)} /> </Col> <Col xs={12} md={6}> <PollDetail poll={this.state.curPoll} auth={this.props.auth} /> </Col> </Row> </Grid> </div> ); } } PollsIndex.propTypes = { auth: PropTypes.instanceOf(Auth).isRequired }; export default PollsIndex;
src/client/app/app.react.js
jaegerpicker/GLDice
import './app.styl'; import Component from '../components/component.react'; import Footer from './footer.react'; import Header from './header.react'; import React from 'react'; import {RouteHandler} from 'react-router'; import {appState} from '../state'; import {measureRender} from '../console'; // All stores must be imported here. import '../auth/store'; import '../examples/store'; import '../todos/store'; import '../users/store'; class App extends Component { constructor(props) { super(props); this.state = this.getState(); } getState() { const viewer = appState.get().getIn(['users', 'viewer']); return appState.get().merge({ isLoggedIn: !!viewer, viewer: viewer }).toObject(); } // Why componentWillMount instead of componentDidMount. // https://github.com/este/este/issues/274 componentWillMount() { if (!process.env.IS_BROWSER) return; appState.on('change', () => { measureRender(done => this.setState(this.getState(), done)); }); } render() { return ( <div className="page"> <Header isLoggedIn={this.state.isLoggedIn} /> <RouteHandler {...this.state} /> <Footer /> </div> ); } } export default App;
examples/SSR/src/index.js
gaearon/react-hot-loader
import 'babel-polyfill'; import React from 'react'; import { hydrate } from 'react-dom'; import App from './App'; //const root = document.createElement('div') //document.body.appendChild(root) const root = document.getElementById('root'); hydrate(<App />, root);
frontend/src/components/layout/logout.js
unicef/un-partner-portal
import React, { Component } from 'react'; import { connect } from 'react-redux'; import PropTypes from 'prop-types'; import { browserHistory as history } from 'react-router'; import Paper from 'material-ui/Paper'; import { withStyles } from 'material-ui/styles'; import SignOut from 'material-ui-icons/PowerSettingsNew'; import Person from 'material-ui-icons/Person'; import IconWithTextButton from '../common/iconWithTextButton'; import { logoutUser } from '../../reducers/session'; const messages = { signOut: 'Sign out', profile: 'User Profile', }; const styleSheet = theme => ({ root: { width: '15vw', '&:hover': { backgroundColor: theme.palette.common.darkGreyBackground, }, }, }); class Logout extends Component { constructor(props) { super(props); this.state = { actionOnSubmit: {}, }; this.openProfilePage = this.openProfilePage.bind(this); } openProfilePage() { const { onClose } = this.props; history.push('/user'); onClose(); } render() { const { classes, logout } = this.props; return ( <Paper > <div className={classes.root}> <IconWithTextButton icon={<Person />} text={messages.profile} onClick={this.openProfilePage} textProps={{ type: 'body2', }} /> </div> <div className={classes.root}> <IconWithTextButton className={classes.root} icon={<SignOut />} text={messages.signOut} onClick={logout} textProps={{ type: 'body2', }} /> </div> </Paper> ); } } Logout.propTypes = { classes: PropTypes.object, logout: PropTypes.func, onClose: PropTypes.func, }; const mapDispatch = dispatch => ({ logout: () => dispatch(logoutUser()), }); const connectedLogout = connect(null, mapDispatch)(Logout); export default withStyles(styleSheet, { name: 'Logout' })(connectedLogout);
app/javascript/mastodon/features/ui/components/link_footer.js
imas/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 noreferrer' target='_blank'>{repository}</a> (v{version})</span> }} /> </p> </div> ); } };
views/components/AppointmentsViewUi.js
gvaldambrini/madam
import React from 'react'; import { Link } from 'react-router'; import AppointmentsTableUi from './AppointmentsTableUi'; // The main appointments presentational component, which includes the related table. export default React.createClass({ propTypes: { name: React.PropTypes.string, surname: React.PropTypes.string, loaded: React.PropTypes.bool.isRequired, appointments: React.PropTypes.array.isRequired, editAppointment: React.PropTypes.func.isRequired, deleteAppointment: React.PropTypes.func.isRequired, newAppointmentPath: React.PropTypes.string.isRequired }, render: function() { if (!this.props.loaded) { return <div></div>; } let appointments; if (this.props.appointments.length > 0) { appointments = ( <AppointmentsTableUi {...this.props} /> ); } else { appointments = ( <div className="alert alert-info" role="alert"> {i18n.appointments.emptyTableMsg} </div> ); } return ( <div className="content-body"> <Link to={this.props.newAppointmentPath} className='btn btn-primary'> {i18n.appointments.createNew} </Link> <p className="hidden-xs pull-right"> {this.props.name} {this.props.surname} </p> <div className="appointment-table-container"> {appointments} </div> </div> ); } });
app/assets/javascripts/react/decorators/WorkflowCommonPermissions.js
Madek/madek-webapp
import React from 'react' import f from 'lodash' import cx from 'classnames' import TagCloud from '../ui-components/TagCloud.cjsx' import t from '../../lib/i18n-translate' import labelize from '../../lib/labelize' export default class WorkflowCommonPermissions extends React.Component { render() { const { responsible, write, read, read_public } = this.props.permissions const { showHeader } = this.props const supHeadStyle = { textTransform: 'uppercase', fontSize: '85%', letterSpacing: '0.15em' } return ( <div> {showHeader && <span style={supHeadStyle}>{t('workflow_common_settings_permissions_title')}</span> } <ul> <li> <span className="title-s">{t('workflow_common_settings_permissions_responsible')}: </span> {!!responsible && ( <TagCloud mod="person" mods="small inline" list={labelize([responsible])} /> )} </li> <li> <span className="title-s"> {t('workflow_common_settings_permissions_write')} {': '} </span> <TagCloud mod="person" mods="small inline" list={labelize(write)} /> </li> <li> <span className="title-s"> {t('workflow_common_settings_permissions_read')} {': '} </span> <TagCloud mod="person" mods="small inline" list={labelize(read)} /> </li> <li> <span className="title-s"> {t('workflow_common_settings_permissions_read_public')} {': '} </span> {read_public ? ( <i className="icon-checkmark" title="Ja" /> ) : ( <i className="icon-close" title="Nein" /> )} </li> </ul> </div> ) } } WorkflowCommonPermissions.defaultProps = { showHeader: false }
app/javascript/mastodon/components/dropdown_menu.js
koba-lab/mastodon
import React from 'react'; import PropTypes from 'prop-types'; import ImmutablePropTypes from 'react-immutable-proptypes'; import IconButton from './icon_button'; import Overlay from 'react-overlays/lib/Overlay'; import Motion from '../features/ui/util/optional_motion'; import spring from 'react-motion/lib/spring'; import { supportsPassiveEvents } from 'detect-passive-events'; import classNames from 'classnames'; import { CircularProgress } from 'mastodon/components/loading_indicator'; const listenerOptions = supportsPassiveEvents ? { passive: true } : false; let id = 0; class DropdownMenu extends React.PureComponent { static contextTypes = { router: PropTypes.object, }; static propTypes = { items: PropTypes.oneOfType([PropTypes.array, ImmutablePropTypes.list]).isRequired, loading: PropTypes.bool, scrollable: PropTypes.bool, onClose: PropTypes.func.isRequired, style: PropTypes.object, placement: PropTypes.string, arrowOffsetLeft: PropTypes.string, arrowOffsetTop: PropTypes.string, openedViaKeyboard: PropTypes.bool, renderItem: PropTypes.func, renderHeader: PropTypes.func, onItemClick: PropTypes.func.isRequired, }; static defaultProps = { style: {}, placement: 'bottom', }; state = { mounted: false, }; handleDocumentClick = e => { if (this.node && !this.node.contains(e.target)) { this.props.onClose(); } } componentDidMount () { document.addEventListener('click', this.handleDocumentClick, false); document.addEventListener('keydown', this.handleKeyDown, false); document.addEventListener('touchend', this.handleDocumentClick, listenerOptions); if (this.focusedItem && this.props.openedViaKeyboard) { this.focusedItem.focus({ preventScroll: true }); } this.setState({ mounted: true }); } componentWillUnmount () { document.removeEventListener('click', this.handleDocumentClick, false); document.removeEventListener('keydown', this.handleKeyDown, false); document.removeEventListener('touchend', this.handleDocumentClick, listenerOptions); } setRef = c => { this.node = c; } setFocusRef = c => { this.focusedItem = c; } handleKeyDown = e => { const items = Array.from(this.node.querySelectorAll('a, button')); const index = items.indexOf(document.activeElement); let element = null; switch(e.key) { case 'ArrowDown': element = items[index+1] || items[0]; break; case 'ArrowUp': element = items[index-1] || items[items.length-1]; break; case 'Tab': if (e.shiftKey) { element = items[index-1] || items[items.length-1]; } else { element = items[index+1] || items[0]; } break; case 'Home': element = items[0]; break; case 'End': element = items[items.length-1]; break; case 'Escape': this.props.onClose(); break; } if (element) { element.focus(); e.preventDefault(); e.stopPropagation(); } } handleItemKeyPress = e => { if (e.key === 'Enter' || e.key === ' ') { this.handleClick(e); } } handleClick = e => { const { onItemClick } = this.props; onItemClick(e); } renderItem = (option, i) => { if (option === null) { return <li key={`sep-${i}`} className='dropdown-menu__separator' />; } const { text, href = '#', target = '_blank', method } = option; return ( <li className='dropdown-menu__item' key={`${text}-${i}`}> <a href={href} target={target} data-method={method} rel='noopener noreferrer' role='button' tabIndex='0' ref={i === 0 ? this.setFocusRef : null} onClick={this.handleClick} onKeyPress={this.handleItemKeyPress} data-index={i}> {text} </a> </li> ); } render () { const { items, style, placement, arrowOffsetLeft, arrowOffsetTop, scrollable, renderHeader, loading } = this.props; const { mounted } = this.state; let renderItem = this.props.renderItem || this.renderItem; return ( <Motion defaultStyle={{ opacity: 0, scaleX: 0.85, scaleY: 0.75 }} style={{ opacity: spring(1, { damping: 35, stiffness: 400 }), scaleX: spring(1, { damping: 35, stiffness: 400 }), scaleY: spring(1, { damping: 35, stiffness: 400 }) }}> {({ opacity, scaleX, scaleY }) => ( // It should not be transformed when mounting because the resulting // size will be used to determine the coordinate of the menu by // react-overlays <div className={`dropdown-menu ${placement}`} style={{ ...style, opacity: opacity, transform: mounted ? `scale(${scaleX}, ${scaleY})` : null }} ref={this.setRef}> <div className={`dropdown-menu__arrow ${placement}`} style={{ left: arrowOffsetLeft, top: arrowOffsetTop }} /> <div className={classNames('dropdown-menu__container', { 'dropdown-menu__container--loading': loading })}> {loading && ( <CircularProgress size={30} strokeWidth={3.5} /> )} {!loading && renderHeader && ( <div className='dropdown-menu__container__header'> {renderHeader(items)} </div> )} {!loading && ( <ul className={classNames('dropdown-menu__container__list', { 'dropdown-menu__container__list--scrollable': scrollable })}> {items.map((option, i) => renderItem(option, i, { onClick: this.handleClick, onKeyPress: this.handleItemKeyPress }))} </ul> )} </div> </div> )} </Motion> ); } } export default class Dropdown extends React.PureComponent { static contextTypes = { router: PropTypes.object, }; static propTypes = { children: PropTypes.node, icon: PropTypes.string, items: PropTypes.oneOfType([PropTypes.array, ImmutablePropTypes.list]).isRequired, loading: PropTypes.bool, size: PropTypes.number, title: PropTypes.string, disabled: PropTypes.bool, scrollable: PropTypes.bool, status: ImmutablePropTypes.map, isUserTouching: PropTypes.func, onOpen: PropTypes.func.isRequired, onClose: PropTypes.func.isRequired, dropdownPlacement: PropTypes.string, openDropdownId: PropTypes.number, openedViaKeyboard: PropTypes.bool, renderItem: PropTypes.func, renderHeader: PropTypes.func, onItemClick: PropTypes.func, }; static defaultProps = { title: 'Menu', }; state = { id: id++, }; handleClick = ({ target, type }) => { if (this.state.id === this.props.openDropdownId) { this.handleClose(); } else { const { top } = target.getBoundingClientRect(); const placement = top * 2 < innerHeight ? 'bottom' : 'top'; this.props.onOpen(this.state.id, this.handleItemClick, placement, type !== 'click'); } } handleClose = () => { if (this.activeElement) { this.activeElement.focus({ preventScroll: true }); this.activeElement = null; } this.props.onClose(this.state.id); } handleMouseDown = () => { if (!this.state.open) { this.activeElement = document.activeElement; } } handleButtonKeyDown = (e) => { switch(e.key) { case ' ': case 'Enter': this.handleMouseDown(); break; } } handleKeyPress = (e) => { switch(e.key) { case ' ': case 'Enter': this.handleClick(e); e.stopPropagation(); e.preventDefault(); break; } } handleItemClick = e => { const { onItemClick } = this.props; const i = Number(e.currentTarget.getAttribute('data-index')); const item = this.props.items[i]; this.handleClose(); if (typeof onItemClick === 'function') { e.preventDefault(); onItemClick(item, i); } else if (item && typeof item.action === 'function') { e.preventDefault(); item.action(); } else if (item && item.to) { e.preventDefault(); this.context.router.history.push(item.to); } } setTargetRef = c => { this.target = c; } findTarget = () => { return this.target; } componentWillUnmount = () => { if (this.state.id === this.props.openDropdownId) { this.handleClose(); } } close = () => { this.handleClose(); } render () { const { icon, items, size, title, disabled, loading, scrollable, dropdownPlacement, openDropdownId, openedViaKeyboard, children, renderItem, renderHeader, } = this.props; const open = this.state.id === openDropdownId; const button = children ? React.cloneElement(React.Children.only(children), { ref: this.setTargetRef, onClick: this.handleClick, onMouseDown: this.handleMouseDown, onKeyDown: this.handleButtonKeyDown, onKeyPress: this.handleKeyPress, }) : ( <IconButton icon={icon} title={title} active={open} disabled={disabled} size={size} ref={this.setTargetRef} onClick={this.handleClick} onMouseDown={this.handleMouseDown} onKeyDown={this.handleButtonKeyDown} onKeyPress={this.handleKeyPress} /> ); return ( <React.Fragment> {button} <Overlay show={open} placement={dropdownPlacement} target={this.findTarget}> <DropdownMenu items={items} loading={loading} scrollable={scrollable} onClose={this.handleClose} openedViaKeyboard={openedViaKeyboard} renderItem={renderItem} renderHeader={renderHeader} onItemClick={this.handleItemClick} /> </Overlay> </React.Fragment> ); } }