path
stringlengths
5
296
repo_name
stringlengths
5
85
content
stringlengths
25
1.05M
src/svg-icons/social/notifications-paused.js
w01fgang/material-ui
import React from 'react'; import pure from 'recompose/pure'; import SvgIcon from '../../SvgIcon'; let SocialNotificationsPaused = (props) => ( <SvgIcon {...props}> <path d="M12 22c1.1 0 2-.9 2-2h-4c0 1.1.89 2 2 2zm6-6v-5c0-3.07-1.64-5.64-4.5-6.32V4c0-.83-.67-1.5-1.5-1.5s-1.5.67-1.5 1.5v.68C7.63 5.36 6 7.93 6 11v5l-2 2v1h16v-1l-2-2zm-3.5-6.2l-2.8 3.4h2.8V15h-5v-1.8l2.8-3.4H9.5V8h5v1.8z"/> </SvgIcon> ); SocialNotificationsPaused = pure(SocialNotificationsPaused); SocialNotificationsPaused.displayName = 'SocialNotificationsPaused'; SocialNotificationsPaused.muiName = 'SvgIcon'; export default SocialNotificationsPaused;
src/index.js
sebastiandeutsch/react-redux-starter
import React from 'react'; import ReactDOM from 'react-dom'; import App from './containers/App'; ReactDOM.render( <App />, document.getElementById('application') );
examples/dyno/app.js
chentsulin/react-tabs
import React from 'react'; import ReactDOM from 'react-dom'; import Modal from 'react-modal'; import { Tab, Tabs, TabList, TabPanel } from '../../lib/main'; Modal.setAppElement(document.getElementById('example')); Modal.injectCSS(); const App = React.createClass({ getInitialState() { return { isModalOpen: false, selectedIndex: -1, tabs: [ {label: 'Foo', content: 'This is foo'}, {label: 'Bar', content: 'This is bar'}, {label: 'Baz', content: 'This is baz'}, {label: 'Zap', content: 'This is zap'} ] }; }, render() { return ( <div style={{padding: 50}}> <p> <button onClick={this.openModal}>+ Add</button> </p> <Tabs selectedIndex={this.state.selectedIndex}> <TabList> {this.state.tabs.map((tab, i) => { return ( <Tab key={i}> {tab.label} <a href="#" onClick={this.removeTab.bind(this, i)}>✕</a> </Tab> ); })} </TabList> {this.state.tabs.map((tab, i) => { return <TabPanel key={i}>{tab.content}</TabPanel>; })} </Tabs> <Modal isOpen={this.state.isModalOpen} onRequestClose={this.closeModal} style={{width: 400, height: 350, margin: '0 auto'}} > <h2>Add a Tab</h2> <label htmlFor="label">Label:</label><br/> <input id="label" type="text" ref="label"/><br/><br/> <label htmlFor="content">Content:</label><br/> <textarea id="content" ref="content" rows="10" cols="50"></textarea><br/><br/> <button onClick={this.addTab}>OK</button>{' '} <button onClick={this.closeModal}>Cancel</button> </Modal> </div> ); }, openModal() { this.setState({ isModalOpen: true }); }, closeModal() { this.setState({ isModalOpen: false }); }, addTab() { const label = this.refs.label.value; const content = this.refs.content.value; this.state.tabs.push({ label: label, content: content }); this.setState({ selectedIndex: this.state.tabs.length - 1 }); this.closeModal(); }, removeTab(index) { this.state.tabs.splice(index, 1); this.forceUpdate(); } }); ReactDOM.render(<App/>, document.getElementById('example'));
node_modules/react-bootstrap/es/Label.js
vitorgomateus/NotifyMe
import _Object$values from 'babel-runtime/core-js/object/values'; 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 { bsClass, bsStyles, getClassSet, splitBsProps } from './utils/bootstrapUtils'; import { State, Style } from './utils/StyleConfig'; var Label = function (_React$Component) { _inherits(Label, _React$Component); function Label() { _classCallCheck(this, Label); return _possibleConstructorReturn(this, _React$Component.apply(this, arguments)); } Label.prototype.hasContent = function hasContent(children) { var result = false; React.Children.forEach(children, function (child) { if (result) { return; } if (child || child === 0) { result = true; } }); return result; }; Label.prototype.render = function render() { var _props = this.props, className = _props.className, children = _props.children, props = _objectWithoutProperties(_props, ['className', 'children']); var _splitBsProps = splitBsProps(props), bsProps = _splitBsProps[0], elementProps = _splitBsProps[1]; var classes = _extends({}, getClassSet(bsProps), { // Hack for collapsing on IE8. hidden: !this.hasContent(children) }); return React.createElement( 'span', _extends({}, elementProps, { className: classNames(className, classes) }), children ); }; return Label; }(React.Component); export default bsClass('label', bsStyles([].concat(_Object$values(State), [Style.DEFAULT, Style.PRIMARY]), Style.DEFAULT, Label));
fields/types/color/ColorField.js
helloworld3q3q/keystone
import { SketchPicker } from 'react-color'; import { css, StyleSheet } from 'aphrodite/no-important'; import Field from '../Field'; import React from 'react'; import { Button, FormInput, InputGroup } from 'elemental'; import transparentSwatch from './transparent-swatch'; import theme from '../../../admin/client/theme'; const ColorField = Field.create({ displayName: 'ColorField', statics: { type: 'Color', }, propTypes: { onChange: React.PropTypes.func, path: React.PropTypes.string, value: React.PropTypes.string, }, getInitialState () { return { displayColorPicker: false, }; }, updateValue (value) { this.props.onChange({ path: this.props.path, value: value, }); }, handleInputChange (event) { var newValue = event.target.value; if (/^([0-9A-F]{3}){1,2}$/.test(newValue)) { newValue = '#' + newValue; } if (newValue === this.props.value) return; this.updateValue(newValue); }, handleClick () { this.setState({ displayColorPicker: !this.state.displayColorPicker }); }, handleClose () { this.setState({ displayColorPicker: false }); }, handlePickerChange (color) { var newValue = color.hex; if (newValue === this.props.value) return; this.updateValue(newValue); }, renderSwatch () { const className = `${css(classes.swatch)} e2e-type-color__swatch`; return (this.props.value) ? ( <span className={className} style={{ backgroundColor: this.props.value }} /> ) : ( <span className={className} dangerouslySetInnerHTML={{ __html: transparentSwatch }} /> ); }, renderField () { const { displayColorPicker } = this.state; const blockoutClassName = `${css(classes.blockout)} e2e-type-color__blockout`; const popoverClassName = `${css(classes.popover)} e2e-type-color__popover`; return ( <div className="e2e-type-color__wrapper" style={{ position: 'relative' }}> <InputGroup> <InputGroup.Section grow> <FormInput autoComplete="off" name={this.getInputName(this.props.path)} onChange={this.valueChanged} ref="field" value={this.props.value} /> </InputGroup.Section> <InputGroup.Section> <Button onClick={this.handleClick} className={`${css(classes.button)} e2e-type-color__button`}> {this.renderSwatch()} </Button> </InputGroup.Section> </InputGroup> {displayColorPicker && ( <div> <div className={blockoutClassName} onClick={this.handleClose} /> <div className={popoverClassName} onClick={e => e.stopPropagation()}> <SketchPicker color={this.props.value} onChangeComplete={this.handlePickerChange} onClose={this.handleClose} /> </div> </div> )} </div> ); }, }); /* eslint quote-props: ["error", "as-needed"] */ const classes = StyleSheet.create({ button: { background: 'white', padding: 4, width: theme.component.height, ':hover': { background: 'white', }, }, blockout: { bottom: 0, left: 0, position: 'fixed', right: 0, top: 0, zIndex: 1, }, popover: { marginTop: 10, position: 'absolute', right: 0, zIndex: 2, }, swatch: { borderRadius: 1, boxShadow: 'inset 0 0 0 1px rgba(0,0,0,0.1)', display: 'block', height: '100%', width: '100%', }, }); module.exports = ColorField;
src/svg-icons/action/explore.js
matthewoates/material-ui
import React from 'react'; import pure from 'recompose/pure'; import SvgIcon from '../../SvgIcon'; let ActionExplore = (props) => ( <SvgIcon {...props}> <path d="M12 10.9c-.61 0-1.1.49-1.1 1.1s.49 1.1 1.1 1.1c.61 0 1.1-.49 1.1-1.1s-.49-1.1-1.1-1.1zM12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm2.19 12.19L6 18l3.81-8.19L18 6l-3.81 8.19z"/> </SvgIcon> ); ActionExplore = pure(ActionExplore); ActionExplore.displayName = 'ActionExplore'; ActionExplore.muiName = 'SvgIcon'; export default ActionExplore;
packages/mineral-ui-icons/src/IconRemoveCircle.js
mineral-ui/mineral-ui
/* @flow */ import React from 'react'; import Icon from 'mineral-ui/Icon'; import type { IconProps } from 'mineral-ui/Icon/types'; /* eslint-disable prettier/prettier */ export default function IconRemoveCircle(props: IconProps) { const iconProps = { rtl: false, ...props }; return ( <Icon {...iconProps}> <g> <path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm5 11H7v-2h10v2z"/> </g> </Icon> ); } IconRemoveCircle.displayName = 'IconRemoveCircle'; IconRemoveCircle.category = 'content';
showcase/examples/candlestick/candlestick.js
Apercu/react-vis
// Copyright (c) 2016 - 2017 Uber Technologies, Inc. // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. import React from 'react'; import {AbstractSeries} from 'index'; const predefinedClassName = 'rv-xy-plot__series rv-xy-plot__series--candlestick'; class CandlestickSeries extends AbstractSeries { render() { const {className, data, marginLeft, marginTop} = this.props; if (!data) { return null; } const xFunctor = this._getAttributeFunctor('x'); const yFunctor = this._getAttributeFunctor('y'); const strokeFunctor = this._getAttributeFunctor('stroke') || this._getAttributeFunctor('color'); const fillFunctor = this._getAttributeFunctor('fill') || this._getAttributeFunctor('color'); const opacityFunctor = this._getAttributeFunctor('opacity'); const distance = Math.abs(xFunctor(data[1]) - xFunctor(data[0])) * 0.2; return ( <g className={`${predefinedClassName} ${className}`} ref="container" transform={`translate(${marginLeft},${marginTop})`}> {data.map((d, i) => { const xTrans = xFunctor(d); // Names of values borrowed from here https://en.wikipedia.org/wiki/Candlestick_chart const yHigh = yFunctor({...d, y: d.yHigh}); const yOpen = yFunctor({...d, y: d.yOpen}); const yClose = yFunctor({...d, y: d.yClose}); const yLow = yFunctor({...d, y: d.yLow}); const lineAttrs = { stroke: strokeFunctor && strokeFunctor(d) }; const xWidth = distance * 2; return ( <g transform={`translate(${xTrans})`} opacity={opacityFunctor ? opacityFunctor(d) : 1} key={i} onClick={e => this._valueClickHandler(d, e)} onMouseOver={e => this._valueMouseOverHandler(d, e)} onMouseOut={e => this._valueMouseOutHandler(d, e)}> <line x1={-xWidth} x2={xWidth} y1={yHigh} y2={yHigh} {...lineAttrs} /> <line x1={0} x2={0} y1={yHigh} y2={yLow} {...lineAttrs} /> <line x1={-xWidth} x2={xWidth} y1={yLow} y2={yLow} {...lineAttrs} /> <rect x={-xWidth} width={Math.max(xWidth * 2, 0)} y={yOpen} height={Math.abs(yOpen - yClose)} fill={fillFunctor && fillFunctor(d)} /> </g>); })} </g> ); } } CandlestickSeries.displayName = 'CandlestickSeries'; export default CandlestickSeries;
src/svg-icons/av/replay-30.js
rhaedes/material-ui
import React from 'react'; import pure from 'recompose/pure'; import SvgIcon from '../../SvgIcon'; let AvReplay30 = (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-2.4 8.5h.4c.2 0 .4-.1.5-.2s.2-.2.2-.4v-.2s-.1-.1-.1-.2-.1-.1-.2-.1h-.5s-.1.1-.2.1-.1.1-.1.2v.2h-1c0-.2 0-.3.1-.5s.2-.3.3-.4.3-.2.4-.2.4-.1.5-.1c.2 0 .4 0 .6.1s.3.1.5.2.2.2.3.4.1.3.1.5v.3s-.1.2-.1.3-.1.2-.2.2-.2.1-.3.2c.2.1.4.2.5.4s.2.4.2.6c0 .2 0 .4-.1.5s-.2.3-.3.4-.3.2-.5.2-.4.1-.6.1c-.2 0-.4 0-.5-.1s-.3-.1-.5-.2-.2-.2-.3-.4-.1-.4-.1-.6h.8v.2s.1.1.1.2.1.1.2.1h.5s.1-.1.2-.1.1-.1.1-.2v-.5s-.1-.1-.1-.2-.1-.1-.2-.1h-.6v-.7zm5.7.7c0 .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.1.3.2.5.3.2.3.3.6.1.5.1.8v.7zm-.8-.8v-.5c0-.1-.1-.2-.1-.3s-.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> ); AvReplay30 = pure(AvReplay30); AvReplay30.displayName = 'AvReplay30'; export default AvReplay30;
actor-apps/app-web/src/app/components/Main.react.js
allengaller/actor-platform
import React from 'react'; import requireAuth from 'utils/require-auth'; import VisibilityActionCreators from 'actions/VisibilityActionCreators'; import ActivitySection from 'components/ActivitySection.react'; import SidebarSection from 'components/SidebarSection.react'; import ToolbarSection from 'components/ToolbarSection.react'; import DialogSection from 'components/DialogSection.react'; const visibilitychange = 'visibilitychange'; var onVisibilityChange = () => { if (!document.hidden) { VisibilityActionCreators.createAppVisible(); } else { VisibilityActionCreators.createAppHidden(); } }; class Main extends React.Component { componentWillMount() { document.addEventListener(visibilitychange, onVisibilityChange); if (!document.hidden) { VisibilityActionCreators.createAppVisible(); } } constructor() { super(); } render() { return ( <div className="app row"> <SidebarSection/> <section className="main col-xs"> <ToolbarSection/> <DialogSection/> </section> <ActivitySection/> </div> ); } } export default requireAuth(Main);
app/components/ItemThumbnail/ItemThumbnail.js
zhrkian/SolarDataApp
// @flow import React, { Component } from 'react'; import { Link } from 'react-router'; import s from './ItemThumbnail.css'; export default class ItemThumbnail extends Component { static contextTypes = { router: React.PropTypes.object.isRequired } componentWillMount() { const { FITS } = window.astro const { item } = this.props new FITS(item.path, response => { console.log(response) const { hdus } = response const FIST_DATA = hdus[0] const bitpix = FIST_DATA.header.get('BITPIX') const bzero = FIST_DATA.header.get('BZERO') const bscale = FIST_DATA.header.get('BSCALE') const { buffer } = FIST_DATA.data console.log( FIST_DATA, FIST_DATA.header.get('BITPIX'), FIST_DATA.header.get('BZERO'), FIST_DATA.header.get('BSCALE'), FIST_DATA.data._getFrame(buffer, bitpix, bzero, bscale) ) }) } render() { return ( <div> <div className={s.container}> <h2>Solar Data Application</h2> </div> </div> ); } }
src/components/Header.js
teamstrobe/mancreact-client
import React, { Component } from 'react'; import { Link } from 'react-router-dom'; import { groupURI } from '../config/urls'; import apiFetch from '../apiFetch'; import LoginLink from './LoginLink'; import LogoutBtn from './LogoutBtn'; class Header extends Component { state = { group: null, }; componentWillMount() { this.fetchData(); } async fetchData() { const group = await this.getGroup(); this.setState({ group, }); } async getGroup() { return await apiFetch(groupURI()); } render() { const { group } = this.state; const { me, onLoginClick, onLogoutClick, pathname } = this.props; return ( <header className="header"> <div className="container"> <div className="row"> {group != null && <Link to="/" className="logo"> <div> <img src="/mancreact512.png" alt={group.name} width="100" /> </div> <div className="logo-title">{group.name}</div> </Link>} {group != null && <div className="members"> <strong>{group.members}</strong> members </div>} <div className="signin"> {!me ? <LoginLink onClick={onLoginClick} pathname={pathname} /> : <div> <img className="avatar" src={me.photo.thumb_link} alt={me.name} /> <span className="account-name"> Hello, {me.name}! </span> <LogoutBtn onClick={onLogoutClick} /> </div>} </div> </div> </div> </header> ); } } export default Header;
src/js/components/navigation/Navigation.js
csepreghy/VR-Cinema-Website-with-React.js
import {Entity} from 'aframe-react'; import React from 'react'; import Back from './buttons/Back'; import BookSeat from './buttons/BookSeat'; import ChangeSeat from './buttons/ChangeSeat'; export default class Navigation extends React.Component { opacity = { x: 0 }; constructor(props) { super(props); this.state = { opacity: { x: 0 }, navBackTextOpacity: { x: 0 }, navBackTextVisible: false }; this.fadeIn = this.fadeIn.bind(this); this.fadeOut = this.fadeOut.bind(this); this.tweenUpdate = this.tweenUpdate.bind(this); } fadeIn() { let newOpacity = { x: 1 }; let tween = new TWEEN.Tween(this.opacity).to(newOpacity, 300); tween.start(); tween.onUpdate(this.tweenUpdate); } fadeOut() { let newOpacity = { x: 0 }; let tween = new TWEEN.Tween(this.opacity).to(newOpacity, 300); tween.start(); tween.onUpdate(this.tweenUpdate); } tweenUpdate() { this.setState({ opacity: this.opacity }); } render() { return ( <Entity> <Back Opacity={ this.state.opacity.back } fadeIn={ this.fadeIn } fadeOut={ this.fadeOut } /> <BookSeat Opacity={ this.state.opacity.bookseat } fadeIn={ this.fadeIn } fadeOut={ this.fadeOut } handleBookSeatClick={ this.props.handleBookSeatClick }/> <ChangeSeat handleChangeSeatClick={ this.props.handleChangeSeatClick } Opacity={ this.state.opacity.x } fadeIn={ this.fadeIn } fadeOut={ this.fadeOut }/> </Entity> ); } }
src/docs/examples/MyHelloWorld/ExampleMyHelloWorld.js
Mikhail2k15/ps-react-michael
import React from 'react'; import MyHelloWorld from 'ps-react/MyHelloWorld'; export default function ExampleMyHelloWorld(){ return <MyHelloWorld message="Pluralsight viewers"/> }
client/src/app/app.layout.js
Thiht/docktor
// React import React from 'react'; // Components import NavBar from './navBar.component.js'; import Footer from './footer.component.js'; import Toasts from '../toasts/toasts.component.js'; import Modal from '../modal/modal.component.js'; // JS dependancies import 'jquery'; import form from 'semantic/dist/semantic.js'; $.form = form; // Style import 'semantic/dist/semantic.css'; import './common.scss'; import './flex.scss'; // App Component class App extends React.Component { render() { return ( <div className='layout vertical start-justified fill'> <NavBar /> <div className='flex main layout vertical'> {this.props.children} </div> <Toasts /> <Modal /> </div> ); } } App.propTypes = { children: React.PropTypes.object }; export default App;
components/GuestContainer.js
flyingant/tedxguanggu.org
/** * Created by FlyingAnt on 3/23/16. */ import React from 'react' import { Link } from 'react-router' import { connect } from 'react-redux' import styles from '../less/main.less' import cn from 'classnames'; //component import Navigator from '../components/navigator/Navigator' import ListItemBox from '../components/common/ListItemBox' import ListItemBoxWithDate from '../components/common/ListItemBoxWithDate' import ListItemDetailBox from '../components/common/ListItemDetailBox' const guest_data = [ { avatarURL: "http://flyingant.oss-cn-hangzhou.aliyuncs.com/a0fec466-96d7-41b0-8a44-c1961f74f620.png", name: "张鹏", addon: "", date: "May 8, 2015", description: "毕业于中国政法大学社会学、法学专业,获哲学、法学学士学位。现为青少年阅读推广人,忆空间阅读体验馆馆长。北京青联委员,北京博物馆学会志愿者专业委员会秘书长,四月公益博物馆志愿者协会创始人。国家博物馆、世界艺术馆义务讲解员十二年。于他,这是抗拒浮躁,传递博物之美的逆流而上。" + "<br/>“志愿者本可以也应该是一种生活方式。”" + "<br/>“即使爱好和理想在短期内不能实现,也要让它以另一种方式活着。”" }, { avatarURL: "http://flyingant.oss-cn-hangzhou.aliyuncs.com/21ed7f5f-d996-4252-aa70-94ddcf4d3793.png", name: "葛磊", addon: "", date: "May 8, 2015", description: "公益旅人,致力于青少年成长的公益服务,在清华、北大、北航、西藏大学等全国60多所高校举办过公益讲座。曾在担任中青旅社会责任总监时,策划发起国内首个系列盲人公益旅行团“听海”、“听风”、“听城”,以及面向乡村教师的“梦想旅行团”。2014年出版畅销书《台湾单车环岛笔记》。葛磊是行者,也是分享者,更是旅游与公益的嫁接者。于他,这是异想天开,又恪守本心的潇洒壮游。" + "<br/>风自磊落光明的心中来," + "<br/>自这珍贵的人间来," + "<br/>或有阻挡,或是曲折," + "<br/>但从未停歇。" + "<br/>“人生最疯狂的事情,就是相信自己。”" }, { avatarURL: "http://flyingant.oss-cn-hangzhou.aliyuncs.com/c1c045fa-a306-4ff2-8699-472a908cb700.png", name: "杜帆", addon: "", date: "May 8, 2015", description: "武汉市小动物保护协会负责人,武汉市第十三届青联委员,武汉市生命关怀人道教育幼儿公益讲师,在武汉专注动物保护工作长达九年,用自己的行动影响、感召着身边的朋友和千千万万的武汉市民,对动物给予更多的关爱和对生命的尊重。提倡人与动物,相信人与自然是相互关联,不可分割的。" + "<br/>杜帆以个人微小的坚持为开头,渐渐汇聚众人之力,细细书写了一封给流浪宠物的朴素情书。2015年,正值志愿生涯的第十年,他仍在继续,一字一句,点点心血,不敢辜负。" + "<br/>于他,这是穿行于琐杂与热忱的天真守护。" + "<br/>“救助流浪狗狗会教会我们很多事,而最重要的是,这是人类灵魂的最后良药。”" }, { avatarURL: "http://flyingant.oss-cn-hangzhou.aliyuncs.com/5c4c93a6-4285-463a-8efc-cbdb5064ec5b.png", name: "马人人", addon: "", date: "May 8, 2015", description: "上层传媒董事,副总经理,《上层》杂志主编,新媒体品牌What创始人。他文艺与毒舌齐飞,逼格共颜值一色。他是执拗专情的武汉控,他是任性诗意的生活家。在学成归汉以后的六年时间,全力以赴地与这座城市相处,更了解武汉的过程中,他慢慢发现, 武汉在他身上留下了的温度、空气、阳光和水的痕迹。" + "<br/>马人人,带你重新阅读武汉,静下心或是躁起来,都可以带你找到,与这座城市更好的,相处相知的方式。于他,这是剪烛共饮,浓谈相宜的江湖夜话。" }, { avatarURL: "http://flyingant.oss-cn-hangzhou.aliyuncs.com/47d74108-8597-4e01-9590-409f54798ec4.png", name: "刘文祥", addon: "", date: "May 8, 2015", description: "武汉大学历史学院博士研究生,数年来参与保护汉口福新第五面粉厂旧址、基督教救世堂、生活书店汉口分店旧址、汉口辅义里瞿秋白旧居、黄石下陆老火车站、宝鸡申新纱厂旧址等历史建筑。2010年拍摄纪录片《汉口,汉口》,关注武汉城市文化遗产消亡和保护问题。" + "<br/>一声来自民间的呐喊,一次追寻城市记忆的对话,一同思考,想要看到的过去与未来。于他,这是叩问工业遗产未来的素履之往。" }, { avatarURL: "http://flyingant.oss-cn-hangzhou.aliyuncs.com/e16da1ec-cba7-415e-a492-8619bd61f79e.png", name: "黄睿", addon: "", date: "May 8, 2015", description: "于2004年开始涂鸦创作,如今已是第11年,是中国涂鸦圈元老级人物,也是华中地区涂鸦代表人物。现经营一家自己的工作室,并且担任湖北美术学院涂鸦课程讲师。曾担任全国各大型涂鸦比赛评委;活动嘉宾。接受各地媒体专访、采访。作品遍布武汉三镇、全国各地(北京·上海·广州·深圳·重庆·杭州·乌鲁木齐·香港等)。" + "<br/>他思考涂鸦中的中国元素,地方特色,于是有了青铜器图腾,楚国玉器纹和疯狂的521路公交车。思考自然与城市,居民的关系,于是有了消失的松鼠,猫头鹰和江豚再现画中,隐秘批判。" + "<br/>然而,经过十一年的沉淀,反省和探索,他还想要告诉你——涂鸦不仅仅是叛逆,占领和反抗的代名词。在好的环境里,它可以是与这座城市,与这条街道的一个开诚布公的大拥抱。" + "<br/>于他,这是以创意唤醒街头的色彩交响乐。" }, ] class GuestContainer extends React.Component { constructor(props) { super(props); this.state = { overlayDisplayStatus: true, selectedGuest: null } } render() { return ( <div> <Navigator current={"guest"}/> <div className={styles.guest_container}> { guest_data.map((item, index)=> { return <ListItemBoxWithDate key={index} display={true} index={index} avatarURL={item.avatarURL} name={item.name} addon={item.addon} date={item.date} description={item.description} onSelect={this.onSelect.bind(this)}/> }) } </div> { this.state.overlayDisplayStatus && this.state.selectedGuest != null ? <div className={styles.overlay}> <div className={styles.overlay_container}> <ListItemDetailBox avatarURL={this.state.selectedGuest.avatarURL} name={this.state.selectedGuest.name} addon={this.state.selectedGuest.addon} description={this.state.selectedGuest.description}/> </div> <div className={styles.hide} onClick={this.onHideOverlay.bind(this)}> &times; </div> </div> : null } </div> ) } onSelect(index) { this.setState({ selectedGuest: guest_data[index], overlayDisplayStatus: true }) } onHideOverlay() { this.setState({ overlayDisplayStatus: false }) } } let componentState = (state) => ({ app: state.app, status: state.app.get("status") }); module.exports = connect(componentState)(GuestContainer);
example/data.js
dancormier/react-native-swipeout
import React from 'react'; import {Image} from 'react-native'; var btnsDefault = [ { text: 'Button' } ]; var btnsTypes = [ { text: 'Primary', type: 'primary', }, { text: 'Secondary', type: 'secondary', }, { text: 'Delete', type: 'delete', } ]; var rows = [ { text: "Basic Example", right: btnsDefault, }, { text: "onPress Callback", right: [ { text: 'Press Me', onPress: function(){ alert('button pressed') }, type: 'primary', } ], }, { text: "Button Types", right: btnsTypes, }, { text: "Button with custom styling", right: [ { text: 'Button', backgroundColor: '#4fba8a', color: '#17807a', underlayColor: "#006fff", } ], }, { text: "Overswipe background color (drag me far)", right: btnsDefault, backgroundColor: '#006fff', }, { text: "Swipeout autoClose={true}", right: btnsDefault, autoClose: true, }, { text: "Five buttons (full-width) + autoClose={true}", right: [ { text: 'One'}, { text: 'Two'}, { text: 'Three' }, { text: 'Four' }, { text: 'Five' } ], autoClose: true, }, { text: "Custom button component", right: [ { component: <Image style={{flex: 1}} source={{uri: 'http://facebook.github.io/react/img/logo_og.png'}} /> } ], }, { text: "Swipe me right (buttons on left side)", left: btnsDefault, }, { text: "Buttons on both sides", left: btnsTypes, right: btnsTypes, }, ]; export default rows;
example/v9.x.x/reactnative-expo/App.js
i18next/react-i18next
import React from 'react'; import { withNamespaces } from 'react-i18next'; import { createStackNavigator, createAppContainer } from 'react-navigation'; import i18n from './js/i18n'; import Home from './js/pages/Home'; import Page2 from './js/pages/Page2'; const Stack = createStackNavigator({ Home: { screen: Home }, Page2: { screen: Page2 }, }); // Wrapping a stack with translation hoc asserts we get new render on language change // the hoc is set to only trigger rerender on languageChanged class WrappedStack extends React.Component { static router = Stack.router; render() { const { t } = this.props; return <Stack screenProps={{ t }} {...this.props} />; } } const ReloadAppOnLanguageChange = withNamespaces('common', { bindI18n: 'languageChanged', bindStore: false, })(createAppContainer(WrappedStack)); // The entry point using a react navigation stack navigation // gets wrapped by the I18nextProvider enabling using translations // https://github.com/i18next/react-i18next#i18nextprovider export default class App extends React.Component { render() { return <ReloadAppOnLanguageChange />; } }
components/front/routes.js
wi2/sails-isomorphic-react-admin-example
"use strict"; import React from 'react' import {RouteHandler, Route} from 'react-router' module.exports = ( <Route handler={RouteHandler}> <Route name="home" path="/" handler={require('./pages/home')} /> </Route> );
src/svg-icons/maps/local-pizza.js
ngbrown/material-ui
import React from 'react'; import pure from 'recompose/pure'; import SvgIcon from '../../SvgIcon'; let MapsLocalPizza = (props) => ( <SvgIcon {...props}> <path d="M12 2C8.43 2 5.23 3.54 3.01 6L12 22l8.99-16C18.78 3.55 15.57 2 12 2zM7 7c0-1.1.9-2 2-2s2 .9 2 2-.9 2-2 2-2-.9-2-2zm5 8c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2z"/> </SvgIcon> ); MapsLocalPizza = pure(MapsLocalPizza); MapsLocalPizza.displayName = 'MapsLocalPizza'; MapsLocalPizza.muiName = 'SvgIcon'; export default MapsLocalPizza;
src/Dialog/DialogContent.spec.js
dsslimshaddy/material-ui
// @flow import React from 'react'; import { assert } from 'chai'; import { createShallow, getClasses } from '../test-utils'; import DialogContent from './DialogContent'; describe('<DialogContent />', () => { let shallow; let classes; before(() => { shallow = createShallow({ dive: true }); classes = getClasses(<DialogContent />); }); it('should render a div', () => { const wrapper = shallow(<DialogContent />); assert.strictEqual(wrapper.name(), 'div'); }); it('should spread custom props on the root node', () => { const wrapper = shallow(<DialogContent data-my-prop="woofDialogContent" />); assert.strictEqual( wrapper.prop('data-my-prop'), 'woofDialogContent', 'custom prop should be woofDialogContent', ); }); it('should render with the user and root classes', () => { const wrapper = shallow(<DialogContent className="woofDialogContent" />); assert.strictEqual(wrapper.hasClass('woofDialogContent'), true); assert.strictEqual(wrapper.hasClass(classes.root), true); }); it('should render children', () => { const children = <p />; const wrapper = shallow( <DialogContent> {children} </DialogContent>, ); assert.strictEqual(wrapper.children().equals(children), true); }); });
src/common/components/img/component.js
gravitron07/brentayersV6
import React from 'react'; export default class Img extends React.Component { render() { // let path = require(this.props.source); return ( <img src="" /> ); } }
modules/IndexRoute.js
davertron/react-router
import React from 'react' import invariant from 'invariant' import warning from 'warning' import { createRouteFromReactElement } from './RouteUtils' import { component, components, falsy } from './PropTypes' const { bool, func } = React.PropTypes /** * An <IndexRoute> is used to specify its parent's <Route indexRoute> in * a JSX route config. */ const IndexRoute = React.createClass({ statics: { createRouteFromReactElement(element, parentRoute) { if (parentRoute) { parentRoute.indexRoute = createRouteFromReactElement(element) } else { warning( false, 'An <IndexRoute> does not make sense at the root of your route config' ) } } }, propTypes: { path: falsy, ignoreScrollBehavior: bool, component, components, getComponents: func }, render() { invariant( false, '<IndexRoute> elements are for router configuration only and should not be rendered' ) } }) export default IndexRoute
admin-frontend/src/app.js
BarcampBangalore/hashbeam
import React from 'react'; import { Route, Switch } from 'react-router-dom'; import Login from './components/login'; import MainScreen from './components/main-screen'; import PrivateRoute from './components/private-route'; const App = () => ( <Switch> <PrivateRoute path="/" exact component={MainScreen} /> <Route path="/login" exact component={Login} /> </Switch> ); export default App;
src/app/icons/github.js
Eric-Vandenberg/react-redux-weatherapp.io
import React from 'react'; const GithubIcon = () => ( <svg viewBox="0 0 284 277"> <g> <path fill="#fff" d="M141.888675,0.0234927555 C63.5359948,0.0234927555 0,63.5477395 0,141.912168 C0,204.6023 40.6554239,257.788232 97.0321356,276.549924 C104.12328,277.86336 106.726656,273.471926 106.726656,269.724287 C106.726656,266.340838 106.595077,255.16371 106.533987,243.307542 C67.0604204,251.890693 58.7310279,226.56652 58.7310279,226.56652 C52.2766299,210.166193 42.9768456,205.805304 42.9768456,205.805304 C30.1032937,196.998939 43.9472374,197.17986 43.9472374,197.17986 C58.1953153,198.180797 65.6976425,211.801527 65.6976425,211.801527 C78.35268,233.493192 98.8906827,227.222064 106.987463,223.596605 C108.260955,214.426049 111.938106,208.166669 115.995895,204.623447 C84.4804813,201.035582 51.3508808,188.869264 51.3508808,134.501475 C51.3508808,119.01045 56.8936274,106.353063 65.9701981,96.4165325 C64.4969882,92.842765 59.6403297,78.411417 67.3447241,58.8673023 C67.3447241,58.8673023 79.2596322,55.0538738 106.374213,73.4114319 C117.692318,70.2676443 129.83044,68.6910512 141.888675,68.63701 C153.94691,68.6910512 166.09443,70.2676443 177.433682,73.4114319 C204.515368,55.0538738 216.413829,58.8673023 216.413829,58.8673023 C224.13702,78.411417 219.278012,92.842765 217.804802,96.4165325 C226.902519,106.353063 232.407672,119.01045 232.407672,134.501475 C232.407672,188.998493 199.214632,200.997988 167.619331,204.510665 C172.708602,208.913848 177.243363,217.54869 177.243363,230.786433 C177.243363,249.771339 177.078889,265.050898 177.078889,269.724287 C177.078889,273.500121 179.632923,277.92445 186.825101,276.531127 C243.171268,257.748288 283.775,204.581154 283.775,141.912168 C283.775,63.5477395 220.248404,0.0234927555 141.888675,0.0234927555" /> </g> </svg> ); export default GithubIcon;
frontend/src/containers/DevTools/DevTools.js
chriswk/repoindexer
import React from 'react'; import { createDevTools } from 'redux-devtools'; import LogMonitor from 'redux-devtools-log-monitor'; import DockMonitor from 'redux-devtools-dock-monitor'; export default createDevTools( <DockMonitor toggleVisibilityKey="H" changePositionKey="Q"> <LogMonitor /> </DockMonitor> );
node_modules/case-sensitive-paths-webpack-plugin/demo/src/init.js
Oritechnology/pubApp
import AppRoot from './AppRoot.component.js'; import React from 'react'; import ReactDOM from 'react-dom'; const app = { initialize() { ReactDOM.render(<AppRoot/>, document.getElementById('react-app-hook')); } }; app.initialize();
app/javascript/mastodon/features/standalone/public_timeline/index.js
pixiv/mastodon
import React from 'react'; import { connect } from 'react-redux'; import PropTypes from 'prop-types'; import StatusListContainer from '../../ui/containers/status_list_container'; import { expandPublicTimeline } from '../../../actions/timelines'; import Column from '../../../components/column'; import { defineMessages, injectIntl } from 'react-intl'; import { connectPublicStream } from '../../../actions/streaming'; import ColumnHeader from '../../../../pawoo/components/animated_timeline_column_header'; const messages = defineMessages({ title: { id: 'standalone.public_title', defaultMessage: 'A look inside...' }, }); @connect() @injectIntl export default class PublicTimeline extends React.PureComponent { static propTypes = { dispatch: PropTypes.func.isRequired, intl: PropTypes.object.isRequired, }; handleHeaderClick = () => { this.column.scrollTop(); } setRef = c => { this.column = c; } componentDidMount () { const { dispatch } = this.props; dispatch(expandPublicTimeline()); this.disconnect = dispatch(connectPublicStream()); } componentWillUnmount () { if (this.disconnect) { this.disconnect(); this.disconnect = null; } } handleLoadMore = maxId => { this.props.dispatch(expandPublicTimeline({ maxId })); } render () { const { intl } = this.props; return ( <Column ref={this.setRef}> <ColumnHeader icon='globe' title={intl.formatMessage(messages.title)} onClick={this.handleHeaderClick} timelineId='public' /> <StatusListContainer timelineId='public' onLoadMore={this.handleLoadMore} scrollKey='standalone_public_timeline' trackScroll={false} /> </Column> ); } }
client/components/settingsCard/index.js
DeadPackets/HackPi
import React, { Component } from 'react'; import { StyleSheet, View, Text, Dimensions, Switch, TextInput } from 'react-native' const {width, height} = Dimensions.get('window') export class SwitchSetting extends Component { constructor() { super() this.state = { value: true } } render() { return( <View style={styles.card}> <Text style={styles.setting}>{this.props.setting.title}</Text> <Switch tintColor="#094B81" onTintColor="#094B81" value={this.state.value} onChange={(e)=>{this.setState({value: !this.state.value})}}/> </View> ) } } export class TextSetting extends Component { constructor() { super() this.state = { value: '' } } render() { return( <View style={styles.card}> <Text style={styles.setting}>{this.props.setting.title}</Text> <TextInput style={styles.textInput} placeholder={this.props.setting.placeholder || ""} value={this.state.value} onChangeText={(t)=>{this.setState({value: t})}} /> </View> ) } } const styles = StyleSheet.create({ card: { paddingLeft: 15, paddingRight: 15, paddingTop: 10, paddingBottom: 15, backgroundColor: '#01223E', justifyContent: 'space-between', alignItems: 'center', flexDirection: 'row', borderBottomWidth: 1, borderBottomColor: '#00111F', width: width-30, height: 65 }, textInput: { height: 40, borderColor: '#094B81', borderWidth: 1, width: width-150, backgroundColor: '#094B81' }, setting: { fontSize: 20, color: '#094B81' }, switch: {} })
packages/icons/src/md/maps/Directions.js
suitejs/suitejs
import React from 'react'; import IconBase from '@suitejs/icon-base'; function MdDirections(props) { return ( <IconBase viewBox="0 0 48 48" {...props}> <path d="M43.405 22.585c.79.78.79 2.04.01 2.83l-18 18c-.78.78-2.05.78-2.83 0v-.01l-18-17.99c-.78-.78-.78-2.05 0-2.83l18-18c.77-.78 2.04-.78 2.82 0l18 18zm-15.41 6.41l7-7-7-7v5h-10c-1.11 0-2 .89-2 2v8h4v-6h8v5z" /> </IconBase> ); } export default MdDirections;
pnpm-cached/.pnpm-store/1/registry.npmjs.org/react-bootstrap/0.31.0/es/ModalBody.js
Akkuma/npm-cache-benchmark
import _extends from 'babel-runtime/helpers/extends'; import _objectWithoutProperties from 'babel-runtime/helpers/objectWithoutProperties'; import _classCallCheck from 'babel-runtime/helpers/classCallCheck'; import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn'; import _inherits from 'babel-runtime/helpers/inherits'; import 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 ModalBody = function (_React$Component) { _inherits(ModalBody, _React$Component); function ModalBody() { _classCallCheck(this, ModalBody); return _possibleConstructorReturn(this, _React$Component.apply(this, arguments)); } ModalBody.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 ModalBody; }(React.Component); ModalBody.propTypes = propTypes; ModalBody.defaultProps = defaultProps; export default bsClass('modal-body', ModalBody);
src/routes/system/ModifyPassword/index.js
daizhen256/i5xwxdoctor-web
import React from 'react' import PropTypes from 'prop-types' import {connect} from 'dva' import ModifyForm from './ModifyForm' import { Link } from 'dva/router' function ModifyPassword({ dispatch, systemModifyPassword, loading }) { const modifyFormProps = { loading, onOk(data) { dispatch({ type: `systemModifyPassword/update`, payload: data }) } } return ( <div> <ModifyForm {...modifyFormProps}></ModifyForm> </div> ) } ModifyPassword.propTypes = { systemModifyPwd: PropTypes.object, dispatch: PropTypes.func } function mapStateToProps({ systemModifyPassword, loading }) { return { systemModifyPassword, loading: loading.models.systemModifyPassword } } export default connect(mapStateToProps)(ModifyPassword)
src/icons/CheckBoxIcon.js
kiloe/ui
import React from 'react'; import Icon from '../Icon'; export default class CheckBoxIcon extends Icon { getSVG(){return <svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 48 48"><path d="M38 6H10c-2.21 0-4 1.79-4 4v28c0 2.21 1.79 4 4 4h28c2.21 0 4-1.79 4-4V10c0-2.21-1.79-4-4-4zM20 34L10 24l2.83-2.83L20 28.34l15.17-15.17L38 16 20 34z"/></svg>;} };
demo/react-app/src/App.js
BigFatDog/parcoords-es
import React from 'react'; import Chart from './chart'; import './App.css'; function App() { return ( <div className="App"> <Chart/> </div> ); } export default App;
app/components/Preview/Header/HeaderButton/HeaderButton.js
realgvard/telegram_theme_customizer
import React, { Component } from 'react'; import reactCSS, { hover } from 'reactcss'; import ReactDOM from 'react-dom'; class HeaderButton extends Component { // _onHintTextClick() { // const component = ReactDOM.findDOMNode(this.refs.ButtonComponent); // // console.dir(component) // // component.mouseenter(); // } // // componentDidMount() { // this.refs.container.addEventListener('mouseenter', ::this._onHintTextClick, false); // } // // componentWillUnmount() { // this.refs.container.removeEventListener('mouseenter', this._onHintTextClick); // } render() { const ButtonComponent = this.props.component; const styles = reactCSS({ 'hover': { button: { background: this.props.backgroundColor, }, }, }, this.props, this.state); const { className, style, iconStyle, ownProps } = this.props; return ( <div ref="container" className={className} style={{ transition: 'all 450ms cubic-bezier(0.23, 1, 0.32, 1)', ...style, ...styles.button }} > <ButtonComponent ref="ButtonComponent" style={iconStyle} {...ownProps} /> </div> ); } } export default hover(HeaderButton);
templates/rubix/rubix-bootstrap/src/ProgressBar.js
jeffthemaximum/Teachers-Dont-Pay-Jeff
import React from 'react'; import BProgressBar from './BProgressBar'; export default class ProgressBar extends React.Component { static propTypes = { value: React.PropTypes.number }; render() { let props = { ...this.props }; if (props.value) { props.now = props.value; delete props.value; } return <BProgressBar {...props} />; } }
packages/wix-style-react/src/AreaChart/docs/index.story.js
wix/wix-style-react
import React from 'react'; import { header, tabs, tab, description, importExample, title, divider, example, code, playground, api, testkit, } from 'wix-storybook-utils/Sections'; import { storySettings } from '../test/storySettings'; import { simpleUsage, collapsedLabelsUsage, combinedData, standardData, } from './examples'; import AreaChart from '..'; export default { category: storySettings.category, storyName: storySettings.storyName, component: AreaChart, componentPath: '..', componentProps: { data: combinedData, tooltipContent: (item, index) => [ `${item.label}`, `${item.value}$ from your orders`, ], }, exampleProps: { // Put here presets of props, for more info: // https://github.com/wix/wix-ui/blob/master/packages/wix-storybook-utils/docs/usage.md#using-list }, sections: [ header({ sourceUrl: `https://github.com/wix/wix-style-react/tree/master/src/${AreaChart.displayName}/`, component: ( <AreaChart data={standardData} tooltipContent={(item, index) => { return [`${item.label}`, `${item.value}$ from your orders`]; }} /> ), }), tabs([ tab({ title: 'Description', sections: [ description({ title: 'Description', text: 'An area chart is a way of plotting data points on a line. Often, it is used to show trend data.', }), importExample(), divider(), title('Examples'), example({ title: 'Simple Usage', text: 'A simple example with compact preview', source: simpleUsage, }), example({ title: 'Collapsed values', text: 'A simple example of collapsed values (hover on a point between some x labels)', source: collapsedLabelsUsage, }), code({ title: 'Full Interactive Preview', description: 'A non compact version of same code example as above', source: simpleUsage, }), ], }), ...[ { title: 'API', sections: [api()] }, { title: 'Testkit', sections: [testkit()] }, { title: 'Playground', sections: [playground()] }, ].map(tab), ]), ], };
src/application/App/FindSongs/FindSongs.js
AoDev/kaiku-music-player
import PropTypes from 'prop-types' import React from 'react' export default function FindSongs (props) { return ( <div className="text-center"> <h1>Your library is empty!</h1> <button className="btn-default" onClick={props.showSettings}> Start looking for songs </button> </div> ) } FindSongs.propTypes = { showSettings: PropTypes.func.isRequired }
lib/widgets/ModelEditor/views/ModelMetaArrayField.js
ExtPoint/yii2-gii
import React from 'react'; import PropTypes from 'prop-types'; import {html} from 'components'; import ModelMetaRow from './ModelMetaRow'; import './ModelMetaArrayField.less'; const bem = html.bem('ModelMetaArrayField'); class ModelMetaArrayField extends React.Component { static formId = 'ModelEditor'; static propTypes = { fields: PropTypes.object, appTypes: PropTypes.arrayOf(PropTypes.shape({ name: PropTypes.string })), isAR: PropTypes.bool, onKeyDown: PropTypes.func, }; render() { const isAR = this.props.isAR; return ( <div className={bem(bem.block(), 'form-inline')}> <div className='pull-right text-muted'> <small> Используйте&nbsp; <span className='label label-default'>Shift</span> &nbsp;+&nbsp; <span className='label label-default'>↑↓</span> &nbsp;для перехода по полям </small> </div> <h3> {isAR ? 'Attributes meta information' : 'Form fields'} </h3> <table className='table table-striped table-hover'> <thead> <tr> <th>#</th> <th>Name</th> <th>Label</th> <th>Hint</th> <th className={bem.element('th-app-types')}> Type </th> {isAR && ( <th className={bem(bem.element('th-small'), bem.element('th-default-value'))}> Default value </th> )} <th className={bem.element('th-small')}> Required </th> {isAR && ( <th className={bem(bem.element('th-small'), bem.element('th-publish'))}> Publish to frontend </th> )} <th /> </tr> </thead> <tbody> {this.props.fields.map((attribute, index) => ( <ModelMetaRow key={index} attribute={attribute} index={index} appTypes={this.props.appTypes} onKeyDown={this.props.onKeyDown} onRemove={() => this.props.fields.remove(index)} isAR={isAR} > </ModelMetaRow> ))} </tbody> </table> <div> <a className='btn btn-sm btn-default' href='javascript:void(0)' onClick={() => this.props.fields.push()} > <span className='glyphicon glyphicon-plus'/> Добавить </a> </div> </div> ); } } export default ModelMetaArrayField;
src/svg-icons/av/album.js
kasra-co/material-ui
import React from 'react'; import pure from 'recompose/pure'; import SvgIcon from '../../SvgIcon'; let AvAlbum = (props) => ( <SvgIcon {...props}> <path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 14.5c-2.49 0-4.5-2.01-4.5-4.5S9.51 7.5 12 7.5s4.5 2.01 4.5 4.5-2.01 4.5-4.5 4.5zm0-5.5c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1z"/> </SvgIcon> ); AvAlbum = pure(AvAlbum); AvAlbum.displayName = 'AvAlbum'; AvAlbum.muiName = 'SvgIcon'; export default AvAlbum;
client/src/components/Repos/ReposConfirmDeleteAll.js
vfeskov/win-a-beer
import React from 'react' import PropTypes from 'prop-types' import Button from '@material-ui/core/Button' import DialogTitle from '@material-ui/core/DialogTitle' import DialogActions from '@material-ui/core/DialogActions' import Dialog from '@material-ui/core/Dialog' import withTheme from '@material-ui/core/styles/withTheme' function ReposConfirmDeleteAll ({ open, onClose, theme }) { return <Dialog maxWidth="xs" aria-labelledby="delete-all-confirmation-dialog-title" open={open} onClose={() => onClose(false)} > <DialogTitle id="delete-all-confirmation-dialog-title">Are you sure you want to remove all repos?</DialogTitle> <DialogActions> <Button onClick={() => onClose(false)}> No </Button> <Button onClick={() => onClose(true)} style={{ color: theme.palette.error.main }}> Yes, remove </Button> </DialogActions> </Dialog> } ReposConfirmDeleteAll.propTypes = { open: PropTypes.bool.isRequired, onClose: PropTypes.func.isRequired, theme: PropTypes.object.isRequired } export default withTheme(ReposConfirmDeleteAll)
docs/src/app/components/pages/components/Dialog/Page.js
ichiohta/material-ui
import React from 'react'; import Title from 'react-title-component'; import CodeExample from '../../../CodeExample'; import PropTypeDescription from '../../../PropTypeDescription'; import MarkdownElement from '../../../MarkdownElement'; import dialogReadmeText from './README'; import DialogExampleSimple from './ExampleSimple'; import dialogExampleSimpleCode from '!raw!./ExampleSimple'; import DialogExampleModal from './ExampleModal'; import dialogExampleModalCode from '!raw!./ExampleModal'; import DialogExampleCustomWidth from './ExampleCustomWidth'; import dialogExampleCustomWidthCode from '!raw!./ExampleCustomWidth'; import DialogExampleDialogDatePicker from './ExampleDialogDatePicker'; import dialogExampleDialogDatePickerCode from '!raw!./ExampleDialogDatePicker'; import DialogExampleScrollable from './ExampleScrollable'; import DialogExampleScrollableCode from '!raw!./ExampleScrollable'; import DialogExampleAlert from './ExampleAlert'; import DialogExampleAlertCode from '!raw!./ExampleAlert'; import dialogCode from '!raw!material-ui/Dialog/Dialog'; const DialogPage = () => ( <div> <Title render={(previousTitle) => `Dialog - ${previousTitle}`} /> <MarkdownElement text={dialogReadmeText} /> <CodeExample title="Simple dialog" code={dialogExampleSimpleCode} > <DialogExampleSimple /> </CodeExample> <CodeExample title="Modal dialog" code={dialogExampleModalCode} > <DialogExampleModal /> </CodeExample> <CodeExample title="Styled dialog" code={dialogExampleCustomWidthCode} > <DialogExampleCustomWidth /> </CodeExample> <CodeExample title="Nested dialogs" code={dialogExampleDialogDatePickerCode} > <DialogExampleDialogDatePicker /> </CodeExample> <CodeExample title="Scrollable dialog" code={DialogExampleScrollableCode} > <DialogExampleScrollable /> </CodeExample> <CodeExample title="Alert dialog" code={DialogExampleAlertCode} > <DialogExampleAlert /> </CodeExample> <PropTypeDescription code={dialogCode} /> </div> ); export default DialogPage;
test/test_helper.js
RaneWallin/FCCLeaderboard
import _$ from 'jquery'; import React from 'react'; import ReactDOM from 'react-dom'; import TestUtils from 'react-addons-test-utils'; import jsdom from 'jsdom'; import chai, { expect } from 'chai'; import chaiJquery from 'chai-jquery'; import { Provider } from 'react-redux'; import { createStore } from 'redux'; import reducers from '../src/reducers'; global.document = jsdom.jsdom('<!doctype html><html><body></body></html>'); global.window = global.document.defaultView; global.navigator = global.window.navigator; const $ = _$(window); chaiJquery(chai, chai.util, $); function renderComponent(ComponentClass, props = {}, state = {}) { const componentInstance = TestUtils.renderIntoDocument( <Provider store={createStore(reducers, state)}> <ComponentClass {...props} /> </Provider> ); return $(ReactDOM.findDOMNode(componentInstance)); } $.fn.simulate = function(eventName, value) { if (value) { this.val(value); } TestUtils.Simulate[eventName](this[0]); }; export {renderComponent, expect};
frontend/src/Settings/Notifications/Notifications/AddNotificationModalContent.js
geogolem/Radarr
import PropTypes from 'prop-types'; import React, { Component } from 'react'; import Button from 'Components/Link/Button'; import LoadingIndicator from 'Components/Loading/LoadingIndicator'; import ModalBody from 'Components/Modal/ModalBody'; import ModalContent from 'Components/Modal/ModalContent'; import ModalFooter from 'Components/Modal/ModalFooter'; import ModalHeader from 'Components/Modal/ModalHeader'; import translate from 'Utilities/String/translate'; import AddNotificationItem from './AddNotificationItem'; import styles from './AddNotificationModalContent.css'; class AddNotificationModalContent extends Component { // // Render render() { const { isSchemaFetching, isSchemaPopulated, schemaError, schema, onNotificationSelect, onModalClose } = this.props; return ( <ModalContent onModalClose={onModalClose}> <ModalHeader> {translate('AddNotification')} </ModalHeader> <ModalBody> { isSchemaFetching && <LoadingIndicator /> } { !isSchemaFetching && !!schemaError && <div> {translate('UnableToAddANewNotificationPleaseTryAgain')} </div> } { isSchemaPopulated && !schemaError && <div> <div className={styles.notifications}> { schema.map((notification) => { return ( <AddNotificationItem key={notification.implementation} implementation={notification.implementation} {...notification} onNotificationSelect={onNotificationSelect} /> ); }) } </div> </div> } </ModalBody> <ModalFooter> <Button onPress={onModalClose} > {translate('Close')} </Button> </ModalFooter> </ModalContent> ); } } AddNotificationModalContent.propTypes = { isSchemaFetching: PropTypes.bool.isRequired, isSchemaPopulated: PropTypes.bool.isRequired, schemaError: PropTypes.object, schema: PropTypes.arrayOf(PropTypes.object).isRequired, onNotificationSelect: PropTypes.func.isRequired, onModalClose: PropTypes.func.isRequired }; export default AddNotificationModalContent;
node_modules/react-bootstrap/es/MediaBody.js
CallumRocks/ReduxSimpleStarter
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 'prop-types-extra/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/components/Trend/Trend.js
Zoomdata/nhtsa-dashboard
import flowRight from 'lodash.flowright'; import React, { Component } from 'react'; import TrendChart from '../TrendChart/TrendChart'; import { observer, inject } from 'mobx-react'; import { toJS } from 'mobx'; class Trend extends Component { render() { const { store } = this.props; const data = toJS(store.chartData.yearData); const filterStatus = store.chartFilters.get('filterStatus'); return ( <div id="trend"> <TrendChart data={data} filterStatus={filterStatus} onBrushEnd={this.onBrushEnd} /> </div> ); } onBrushEnd = (selectedYears, changeFilterStatus) => { const { store } = this.props; store.queries.gridDataQuery.set(['offset'], 0); const filter = { path: 'year_string', operation: 'IN', value: selectedYears, }; store.chartFilters.set('year', selectedYears); store.queries.componentDataQuery.filters.remove(filter.path); store.queries.componentDataQuery.filters.add(filter); store.queries.metricDataQuery.filters.remove(filter.path); store.queries.metricDataQuery.filters.add(filter); store.queries.stateDataQuery.filters.remove(filter.path); store.queries.stateDataQuery.filters.add(filter); store.queries.gridDataQuery.filters.remove(filter.path); store.queries.gridDataQuery.filters.add(filter); if (changeFilterStatus) { store.chartFilters.set('filterStatus', 'FILTERS_APPLIED'); } }; } export default flowRight(inject('store'), observer)(Trend);
packages/material-ui-icons/src/GetApp.js
dsslimshaddy/material-ui
import React from 'react'; import pure from 'recompose/pure'; import SvgIcon from 'material-ui/SvgIcon'; let GetApp = props => <SvgIcon {...props}> <path d="M19 9h-4V3H9v6H5l7 7 7-7zM5 18v2h14v-2H5z" /> </SvgIcon>; GetApp = pure(GetApp); GetApp.muiName = 'SvgIcon'; export default GetApp;
packages/nova-core/lib/modules/containers/withCurrentUser.js
HelloMeets/HelloMakers
import React, { Component } from 'react'; import { getFragment } from 'meteor/nova:lib'; import { graphql } from 'react-apollo'; import gql from 'graphql-tag'; const withCurrentUser = component => { return graphql( gql` query getCurrentUser { currentUser { ...UsersCurrent } } ${getFragment('UsersCurrent')} `, { alias: 'withCurrentUser', props(props) { const {data: {loading, currentUser}} = props; return { loading, currentUser, }; }, } )(component); } export default withCurrentUser;
app/javascript/mastodon/features/compose/components/upload_form.js
haleyashleypraesent/ProjectPrionosuchus
import React from 'react'; import ImmutablePropTypes from 'react-immutable-proptypes'; import PropTypes from 'prop-types'; import IconButton from '../../../components/icon_button'; import { defineMessages, injectIntl } from 'react-intl'; import UploadProgressContainer from '../containers/upload_progress_container'; import Motion from 'react-motion/lib/Motion'; import spring from 'react-motion/lib/spring'; const messages = defineMessages({ undo: { id: 'upload_form.undo', defaultMessage: 'Undo' }, }); class UploadForm extends React.PureComponent { static propTypes = { media: ImmutablePropTypes.list.isRequired, onRemoveFile: PropTypes.func.isRequired, intl: PropTypes.object.isRequired, }; onRemoveFile = (e) => { const id = Number(e.currentTarget.parentElement.getAttribute('data-id')); this.props.onRemoveFile(id); } render () { const { intl, media } = this.props; const uploads = media.map(attachment => <div className='compose-form__upload' key={attachment.get('id')}> <Motion defaultStyle={{ scale: 0.8 }} style={{ scale: spring(1, { stiffness: 180, damping: 12 }) }}> {({ scale }) => <div className='compose-form__upload-thumbnail' data-id={attachment.get('id')} style={{ transform: `translateZ(0) scale(${scale})`, backgroundImage: `url(${attachment.get('preview_url')})` }}> <IconButton icon='times' title={intl.formatMessage(messages.undo)} size={36} onClick={this.onRemoveFile} /> </div> } </Motion> </div> ); return ( <div className='compose-form__upload-wrapper'> <UploadProgressContainer /> <div className='compose-form__uploads-wrapper'>{uploads}</div> </div> ); } } export default injectIntl(UploadForm);
assets/javascripts/kitten/components/structure/tables/list-table/stories.js
KissKissBankBank/kitten
import React from 'react' import { createGlobalStyle } from 'styled-components' import { ListTable } from './index' import { ScreenConfig, VisuallyHidden, pxToRem, COLORS, TYPOGRAPHY, StatusWithBullet, Text, Checkbox, DropdownSelect, } from 'kitten' import { DocsPage } from 'storybook/docs-page' import { ToggleableStory } from './stories/toggleable' export default { title: 'Structure/Tables/ListTable', component: ListTable, parameters: { docs: { page: () => <DocsPage filepath={__filename} importString="ListTable" />, }, }, decorators: [story => <div className="story-Container">{story()}</div>], } const ListTableStyles = createGlobalStyle` #CustomListTable { ${TYPOGRAPHY.fontStyles.light} .k-ListTable__HeaderList { height: ${pxToRem(50)}; background-color: ${COLORS.background3}; color: ${COLORS.font1}; } } .customCol_1 { text-align: center; @media (max-width: ${pxToRem(ScreenConfig.S.max)}) { flex-basis: ${pxToRem(40)}; } @media (min-width: ${pxToRem(ScreenConfig.M.min)}) { flex-basis: ${pxToRem(60)}; } @media (min-width: ${pxToRem(ScreenConfig.L.min)}) { flex-basis: ${pxToRem(90)}; } } .customCol_2 { @media (max-width: ${pxToRem(ScreenConfig.S.max)}) { flex-basis: calc(90% - ${pxToRem(150)}); } @media (min-width: ${pxToRem(ScreenConfig.M.min)}) { flex-basis: calc(50% - ${pxToRem(170)}); } @media (min-width: ${pxToRem(ScreenConfig.L.min)}) { flex-basis: 15%; } } .customCol_3 { @media (max-width: ${pxToRem(ScreenConfig.M.max)}) { display: none; } @media (min-width: ${pxToRem(ScreenConfig.L.min)}) { flex-basis: 25%; } } .customCol_4 { text-align: right; @media (max-width: ${pxToRem(ScreenConfig.S.max)}) { flex-basis: 110px; } @media (min-width: ${pxToRem(ScreenConfig.M.min)}) { flex-basis: 110px; } @media (min-width: ${pxToRem(ScreenConfig.L.min)}) { flex-basis: 8%; } } .customCol_5 { @media (max-width: ${pxToRem(ScreenConfig.S.max)}) { flex-basis: 20%; } @media (min-width: ${pxToRem(ScreenConfig.M.min)}) { flex-basis: 20%; } @media (min-width: ${pxToRem(ScreenConfig.L.min)}) { flex-basis: 15%; } } .customCol_6 { @media (max-width: ${pxToRem(ScreenConfig.M.max)}) { display: none; } @media (min-width: ${pxToRem(ScreenConfig.L.min)}) { flex-basis: calc(33% - ${pxToRem(200)}); } } .customCol_7 { @media (max-width: ${pxToRem(ScreenConfig.S.max)}) { display: none; } @media (min-width: ${pxToRem(ScreenConfig.M.min)}) { flex-basis: 20%; } @media (min-width: ${pxToRem(ScreenConfig.L.min)}) { flex-basis: 12%; } } ` export const Default = () => ( <> <ListTableStyles /> <ListTable id="CustomListTable"> <ListTable.Header className="customHeaderClass k-u-weight-regular" listProps={{ className: 'customListClass' }} > <ListTable.Col className="customCol_1"> <VisuallyHidden>Sélection</VisuallyHidden> <Checkbox aria-label="Sélectionner toutes les contributions de la liste" /> </ListTable.Col> <ListTable.Col className="customCol_2"> <Text weight="regular" color="font1" size="small" className="k-u-hidden@s-down k-u-hidden@m" > Date </Text> <Text weight="regular" color="font1" size="small" className="k-u-hidden@l-up" > Contributeur </Text> </ListTable.Col> <ListTable.Col className="customCol_3"> <Text weight="regular" color="font1" size="small"> Contributeur </Text> </ListTable.Col> <ListTable.Col className="customCol_4"> <Text weight="regular" color="font1" size="small"> Montant </Text> </ListTable.Col> <ListTable.Col className="customCol_5"> <Text weight="regular" color="font1" size="small"> Statut </Text> </ListTable.Col> <ListTable.Col className="customCol_6"> <Text weight="regular" color="font1" size="small"> Mode de livraison </Text> </ListTable.Col> <ListTable.Col className="customCol_7"> <Text weight="regular" color="font1" size="small"> Statut livraison </Text> </ListTable.Col> </ListTable.Header> <ListTable.Body> <ListTable.Row isHighlighted> <ListTable.Col className="customCol_1"> <VisuallyHidden> <h2>Contribution #888888 par Prénom NOM le 12 septembre 2019</h2> <button>Voir plus d'informations sur cette contribution</button> </VisuallyHidden> <Checkbox aria-label="Sélectionner toutes les contributions de la liste" /> </ListTable.Col> <ListTable.Col className="customCol_2"> <div> <Text size="small" weight="regular"> <time dateTime="2019-09-12">12/09/2019</time> </Text> <br /> <Text size="micro" className="k-u-hidden@m-down" lineHeight="1"> #88888888 </Text> <Text size="micro" className="k-u-hidden@l-up" lineHeight="1"> Prénom NOM </Text> <br /> <Text size="micro" weight="regular" lineHeight="1" as="a" href="#" className="k-u-link k-u-link-primary1" > Détails </Text> </div> </ListTable.Col> <ListTable.Col className="customCol_3"> <div> <Text weight="bold">Prénom Nom</Text> <br /> <Text size="micro" weight="light"> Prenom-Nom </Text> </div> </ListTable.Col> <ListTable.Col className="customCol_4"> <Text size="small" weight="regular"> 72&nbsp;€ </Text> </ListTable.Col> <ListTable.Col className="customCol_5"> <StatusWithBullet statusType="success">Valid</StatusWithBullet> </ListTable.Col> <ListTable.Col className="customCol_6"> <Text size="small" weight="regular"> Livraison </Text> </ListTable.Col> <ListTable.Col className="customCol_7"> <DropdownSelect id="DropdownSelect_1" hideLabel labelText="Sélectionnez le statut de livraison" options={[ { label: 'À expédier', value: 1 }, { label: 'Expédié', value: 2 }, ]} /> </ListTable.Col> </ListTable.Row> <ListTable.Row className="customRowClass" listProps={{ className: 'customListClass' }} > <ListTable.Col className="customCol_1"> <VisuallyHidden> <h2>Contribution #44654 par Prénom NOM le 12 septembre 2019</h2> <button>Voir plus d'informations sur cette contribution</button> </VisuallyHidden> <Checkbox aria-label="Sélectionner toutes les contributions de la liste" /> </ListTable.Col> <ListTable.Col className="customCol_2"> <div> <Text size="small" weight="regular"> <time dateTime="2019-09-12">12/09/2019</time> </Text> <br /> <Text size="micro" className="k-u-hidden@m-down" lineHeight="1"> #44654 </Text> <Text size="micro" className="k-u-hidden@l-up" lineHeight="1"> Prénom NOM </Text> <br /> <Text size="micro" weight="regular" lineHeight="1" as="a" href="#" className="k-u-link k-u-link-primary1" > Détails </Text> </div> </ListTable.Col> <ListTable.Col className="customCol_3"> <div> <Text weight="bold">Prénom Nom</Text> <br /> <Text size="micro">Prenom-Nom</Text> </div> </ListTable.Col> <ListTable.Col className="customCol_4"> <Text size="small" weight="regular"> 72&nbsp;€ </Text> </ListTable.Col> <ListTable.Col className="customCol_5"> <StatusWithBullet statusType="warning">Invalid</StatusWithBullet> </ListTable.Col> <ListTable.Col className="customCol_6"> <Text size="small" weight="regular"> Livraison </Text> </ListTable.Col> <ListTable.Col className="customCol_7"> <DropdownSelect id="DropdownSelect_2" hideLabel labelText="Sélectionnez le statut de livraison" options={[ { label: 'À expédier', value: 1 }, { label: 'Expédié', value: 2 }, ]} /> </ListTable.Col> </ListTable.Row> </ListTable.Body> </ListTable> </> ) export const Toggleable = () => <ToggleableStory /> Toggleable.decorators = [ story => <div className="story-Container">{story()}</div>, ]
app/components/Footer/FooterStudio.js
dedywahyudi/lilly-contentful
import React from 'react'; import PropTypes from 'prop-types'; import { Link } from 'react-router'; class RepoContributorsItem extends React.PureComponent { // eslint-disable-line react/prefer-stateless-function render() { const item = this.props.item; const peopleLink = `/design/` + item.slug; // eslint-disable-line // console.log(item.question); // Put together the content of the repository const content = ( <li> <Link to={peopleLink}>{item.name}</Link> </li> ); // Render the content into a list item return ( <ContributorsItem key={`repo-list-item-${item.slug}`} item={content} /> ); } } RepoContributorsItem.propTypes = { item: PropTypes.any, }; class Contributors extends React.PureComponent { // eslint-disable-line render() { const items = this.props.items; const ComponentToRender = this.props.component; let content = (<div></div>); // If we have items, render them if (items) { content = items.map((item, index) => ( <ComponentToRender key={`item-${index}`} item={item} /> )); } else { // Otherwise render a single component content = (<ComponentToRender />); } // Render the content into a list item return ( <ul> {content} </ul> ); } } Contributors.propTypes = { component: PropTypes.func.isRequired, items: PropTypes.any, }; function ContributorsItem(props) { return ( (props.item) ); } ContributorsItem.propTypes = { item: PropTypes.any, }; function ContributorsList({ error, repos }) { // if (loading) { // return <Loader active />; // } if (error !== false) { const ErrorComponent = () => ( <ContributorsItem item={'Something went wrong, please try again!'} /> ); return <Contributors component={ErrorComponent} />; } if (repos !== false) { return ( <Contributors items={repos} component={RepoContributorsItem} /> ); } return null; } ContributorsList.propTypes = { error: PropTypes.any, repos: PropTypes.any, }; export default ContributorsList;
src/__tests__/react-components/test-coverage-file-table-head.js
rpl/flow-coverage-report
'use babel'; import React from 'react'; import renderer from 'react-test-renderer'; import {BASE_DIR} from './common'; const REACT_COMPONENT = `${BASE_DIR}/coverage-file-table-head`; test('<FlowCoverageFileTableHead />', () => { const FlowCoverageFileTableHead = require(REACT_COMPONENT).default; const tree = renderer.create(<FlowCoverageFileTableHead/>).toJSON(); expect(tree).toMatchSnapshot(); }); test.todo('<FlowCoverageFileTableHead /> with missing props');
app/components/Toggle/index.js
fascinating2000/productFrontend
/** * * LocaleToggle * */ import React from 'react'; import Select from './Select'; import ToggleOption from '../ToggleOption'; function Toggle(props) { let content = (<option>--</option>); // If we have items, render them if (props.values) { content = props.values.map((value) => ( <ToggleOption key={value} value={value} message={props.messages[value]} /> )); } return ( <Select value={props.value} onChange={props.onToggle}> {content} </Select> ); } Toggle.propTypes = { onToggle: React.PropTypes.func, values: React.PropTypes.array, value: React.PropTypes.string, messages: React.PropTypes.object, }; export default Toggle;
fields/types/boolean/BooleanField.js
matthewstyers/keystone
import React from 'react'; import Field from '../Field'; import Checkbox from '../../components/Checkbox'; import { FormField } from '../../../admin/client/App/elemental'; const NOOP = () => {}; module.exports = Field.create({ displayName: 'BooleanField', statics: { type: 'Boolean', }, propTypes: { indent: React.PropTypes.bool, label: React.PropTypes.string, onChange: React.PropTypes.func.isRequired, path: React.PropTypes.string.isRequired, value: React.PropTypes.bool, }, valueChanged (value) { this.props.onChange({ path: this.props.path, value: value, }); }, renderFormInput () { if (!this.shouldRenderField()) return; return ( <input name={this.getInputName(this.props.path)} type="hidden" value={!!this.props.value} /> ); }, renderUI () { const { indent, value, label, path } = this.props; return ( <div data-field-name={path} data-field-type="boolean"> <FormField offsetAbsentLabel={indent}> <label style={{ height: '2.3em' }}> {this.renderFormInput()} <Checkbox checked={value} onChange={(this.shouldRenderField() && this.valueChanged) || NOOP} readonly={!this.shouldRenderField()} /> <span style={{ marginLeft: '.75em' }}> {label} </span> </label> {this.renderNote()} </FormField> </div> ); }, });
app/MnmNewsList.js
alvaromb/mnm
import React from 'react' import { Platform, StyleSheet, View, ListView, ActivityIndicatorIOS, ProgressBarAndroid, InteractionManager, RefreshControl, Dimensions } from 'react-native' import MnmNewsRow from './MnmNewsRow' import ThumborURLBuilder from 'thumbor-url-builder' import { THUMBOR_KEY, THUMBOR_URL} from './ThumborConfig' const screen = Dimensions.get('window') var moment = require('moment') require('moment/locale/es') moment.locale('es') class MnmPublicadas extends React.Component { getPublicadas: Function; constructor(props) { super(props) const dataSource = new ListView.DataSource({ rowHasChanged: (r1, r2) => r1.id !== r2.id }) this.state = { dataSource: dataSource.cloneWithRows([]), published: [], isFetching: false, } this.getPublicadas = this._getPublicadas.bind(this) } componentDidMount () { this.getPublicadas() } _getPublicadas() { InteractionManager.runAfterInteractions(() => { this.setState({isFetching: true}) fetch(this.props.url) .then(response => response.json()) .then(response => { var thumborURL = new ThumborURLBuilder(THUMBOR_KEY, THUMBOR_URL) var entries = response.objects.map((entry) => { entry.dateFromNow = moment.unix(entry.date).fromNow() if (entry.thumb) { const imagePath = escape(entry.thumb.substr(8, entry.thumb.length)) entry.mediaPublished = thumborURL.setImagePath(imagePath).resize(screen.width * screen.scale, 310).smartCrop(true).buildUrl() } return entry }); this.setState({ dataSource: this.state.dataSource.cloneWithRows(entries), published: entries, isFetching: false, }) }) .catch(() => this.setState({isFetching: false})) }) } renderRow (rowData, sectionID, rowID, highlightRow) { return ( <MnmNewsRow key={`news${rowID}`} entry={rowData} navigator={this.props.navigator} /> ) } _renderList() { if (this.state.published.length > 0) { return ( <ListView style={styles.list} initialListSize={5} dataSource={this.state.dataSource} renderRow={this.renderRow.bind(this)} automaticallyAdjustContentInsets={false} refreshControl={ <RefreshControl refreshing={this.state.isFetching} onRefresh={this.getPublicadas} /> } /> ) } else { if (Platform.OS === 'ios') { return ( <ActivityIndicatorIOS style={styles.centering} animating={true} color="#262626" size="large" /> ) } return ( <View style={styles.centering}> <ProgressBarAndroid style={styles.progressBar} color="#d35400" /> </View> ) } } render() { return ( <View style={styles.container}> {this._renderList()} </View> ) } } const styles = StyleSheet.create({ progressBar: { width: 50, height: 50, }, centering: { flex: 1, alignItems: 'center', justifyContent: 'center', }, container: { flex: 1, backgroundColor: '#FAFAFA', }, list: { flex: 1, backgroundColor: '#FAFAFA', } }) module.exports = MnmPublicadas
frontend/src/admin/common/forms/FormHeaderWithSave.js
rabblerouser/core
import React from 'react'; import { SpacedLayout } from 'layabout'; import styled from 'styled-components'; import { Button } from '../../common'; const HeaderText = styled.span` font-size: 1.1em; font-weight: bold; `; const FormHeaderWithSave = ({ children }) => ( <SpacedLayout container="header"> <HeaderText>{children}</HeaderText> <Button type="submit">Save</Button> </SpacedLayout> ); export default FormHeaderWithSave;
step7-unittest/app/js/components/Main.js
jintoppy/react-training
import React from 'react'; import Profile from './Profile'; import {Link} from 'react-router'; class Main extends React.Component { constructor(props) { super(props); this.state = { name: "guest" }; } render() { return ( <div className="main-container"> <nav className="navbar navbar-default" role="navigation"> <div className="col-sm-7 col-sm-offset-2" style={{marginTop: 15}}> <Profile name = { this.state.name } /> <Link to="/">Home</Link> <Link to="/page1">Page1</Link> <Link to="/contact">Contact</Link> </div> </nav> <div className="container"> {this.props.children} </div> </div> ) } } export default Main;
utilities/warning/render-function-return-contents-lack-display-name.js
salesforce/design-system-react
/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */ /* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */ /* eslint-disable import/no-mutable-exports */ import React from 'react'; // This function will deliver an error message to the browser console when all of the props passed in are undefined (falsey). import warning from 'warning'; let renderFunctionReturnContentsLackDisplayName = function renderFunctionReturnContentsLackDisplayNameFunction() {}; if (process.env.NODE_ENV !== 'production') { const hasWarned = {}; renderFunctionReturnContentsLackDisplayName = function renderFunctionReturnContentsLackDisplayNameFunction( control, propName, renderFunctionReturnContents, displayNames, // array of allowed displayName strings checkChildren, // if true children of the render function return main node will be checked for displayNames matches comment ) { const additionalComment = comment ? ` ${comment}` : ''; const displayNamesJoined = displayNames.join(','); let foundDiscrepancy = false; if ( !renderFunctionReturnContents.type || !renderFunctionReturnContents.type.displayName || !displayNamesJoined.match(renderFunctionReturnContents.type.displayName) ) { if ( checkChildren && renderFunctionReturnContents.props && renderFunctionReturnContents.props.children ) { React.Children.forEach( renderFunctionReturnContents.props.children, (child) => { if ( !child || !child.type || !child.type.displayName || !displayNamesJoined.match(child.type.displayName) ) { foundDiscrepancy = true; } } ); } else { foundDiscrepancy = true; } } if (foundDiscrepancy && !hasWarned[control]) { let allowedDisplayNames = ''; displayNames.forEach((displayName, index) => { allowedDisplayNames += displayName; if (displayNames.length > index + 2) { allowedDisplayNames += ', '; } else if (displayNames.length > index + 1) { allowedDisplayNames += displayNames.length > 2 ? ', or ' : ' or '; } }); /* eslint-disable max-len */ warning( false, `[Design System React] Content provided by \`${propName}\` for ${control} must have a \`displayName\` property value of ${allowedDisplayNames}${ checkChildren ? ` or be an element/fragment with children all having the \`displayName\` property value of ${allowedDisplayNames}.` : '.' } Please review ${propName} prop documentation.${additionalComment}` ); /* eslint-enable max-len */ hasWarned[control] = true; } }; } export default renderFunctionReturnContentsLackDisplayName;
index.windows.js
jiriKuba/Calculatic
import React from 'react'; import {AppRegistry} from 'react-native'; import Root from './src/root'; AppRegistry.registerComponent('calculatic', () => Root)
local-cli/templates/HelloWorld/App.js
jevakallio/react-native
/** * Sample React Native App * https://github.com/facebook/react-native * @flow */ import React, { Component } from 'react'; import { Platform, StyleSheet, Text, View } from 'react-native'; const instructions = Platform.select({ ios: 'Press Cmd+R to reload,\n' + 'Cmd+D or shake for dev menu', android: 'Double tap R on your keyboard to reload,\n' + 'Shake or press menu button for dev menu', }); type Props = {}; export default class App extends Component<Props> { render() { return ( <View style={styles.container}> <Text style={styles.welcome}> Welcome to React Native! </Text> <Text style={styles.instructions}> To get started, edit App.js </Text> <Text style={styles.instructions}> {instructions} </Text> </View> ); } } const styles = StyleSheet.create({ container: { flex: 1, justifyContent: 'center', alignItems: 'center', backgroundColor: '#F5FCFF', }, welcome: { fontSize: 20, textAlign: 'center', margin: 10, }, instructions: { textAlign: 'center', color: '#333333', marginBottom: 5, }, });
src/js/components/page/index.js
Arlefreak/arlefreakClient
import PropTypes from 'prop-types'; import React from 'react'; import { Helmet } from 'react-helmet'; import Loading from '../loading'; import Id from '../id'; const Page = ({ id, title, isFetching, children, className, meta_url, meta_title, meta_description, meta_preview, meta_audio, }) => { let child; if (isFetching) { child = ( <div> <Loading /> <Id index={id} /> </div> ); } else { child = ( <div className={className}> {title != null && <h1 className="title-text box shadow">{title}</h1>} {children} <Id index={id} /> </div> ); } let description = meta_description; if (meta_description.length > 140) description = `${description.substring(0, 140)} ...`; let meta = [ { property: 'og:title', content: meta_title }, { name: 'twitter:title', content: meta_title }, { property: 'og:url', content: meta_url }, { name: 'twitter:url', content: meta_url }, { property: 'og:image', content: meta_preview }, { name: 'twitter:image', content: meta_preview }, { name: 'description', content: description }, { property: 'og:description', content: description }, { name: 'twitter:description', content: description }, ]; if (meta_audio) meta.push({ property: 'og:audio', content: meta_audio }); return ( <div> <Helmet title={meta_title} meta={meta} /> {child} </div> ); }; Page.propTypes = { id: PropTypes.string.isRequired, title: PropTypes.string, isFetching: PropTypes.bool.isRequired, children: PropTypes.node.isRequired, className: PropTypes.string, meta_description: PropTypes.string.isRequired, meta_url: PropTypes.string.isRequired, meta_title: PropTypes.string.isRequired, meta_preview: PropTypes.string.isRequired, meta_audio: PropTypes.string, }; export default Page;
src/templates/tags.js
zccz14/blog
import React from 'react' import PropTypes from 'prop-types' import { graphql } from 'gatsby' import SEO from '../components/seo' import Layout from '../components/layout' import Post from '../components/post' import Navigation from '../components/navigation' import '../styles/layout.css' const Tags = ({ data, pageContext: { nextPagePath, previousPagePath, tag }, }) => { const { allMarkdownRemark: { edges: posts }, } = data return ( <> <SEO /> <Layout> <div className="infoBanner"> Posts with tag: <span>#{tag}</span> </div> {posts.map(({ node }) => { const { id, excerpt: autoExcerpt, frontmatter: { title, date, path, author, coverImage, excerpt, tags, }, } = node return ( <Post key={id} title={title} date={date} path={path} author={author} tags={tags} coverImage={coverImage} excerpt={excerpt || autoExcerpt} /> ) })} <Navigation previousPath={previousPagePath} previousLabel="Newer posts" nextPath={nextPagePath} nextLabel="Older posts" /> </Layout> </> ) } Tags.propTypes = { data: PropTypes.object.isRequired, pageContext: PropTypes.shape({ nextPagePath: PropTypes.string, previousPagePath: PropTypes.string, }), } export const postsQuery = graphql` query($limit: Int!, $skip: Int!, $tag: String!) { allMarkdownRemark( filter: { frontmatter: { tags: { in: [$tag] } } } sort: { fields: [frontmatter___date], order: DESC } limit: $limit skip: $skip ) { edges { node { id excerpt frontmatter { title date(formatString: "DD MMMM YYYY") path author excerpt tags coverImage { childImageSharp { fluid(maxWidth: 800) { ...GatsbyImageSharpFluid } } } } } } } } ` export default Tags
component/NavLink.js
Lucifier129/react-imvc
import React from 'react' import classnames from 'classnames' import connect from '../hoc/connect' import Link from './Link' const withLocation = connect(({ state }) => { return { location: state.location } }) export default withLocation(NavLink) function NavLink({ isActive: getIsActive, location, className, activeClassName, style, activeStyle, to, ...rest }) { let isActive = checkActive(getIsActive, to, location) let finalClassName = classnames(className, isActive && activeClassName) let finalStyle = isActive ? { ...style, ...activeStyle } : style return <Link to={to} className={finalClassName} style={finalStyle} {...rest} /> } function checkActive(getIsActive, path, location) { return getIsActive ? !!getIsActive(path, location) : path === location.raw }
webapp/src/components/ActionMenu.js
gcallah/Indra
import React, { Component } from 'react'; import ListGroup from 'react-bootstrap/ListGroup'; import axios from 'axios'; import autoBind from 'react-autobind'; import PageLoader from './PageLoader'; import PopulationGraph from './PopulationGraph'; import ScatterPlot from './ScatterPlot'; import Debugger from './Debugger'; import ModelStatusBox from './ModelStatusBox'; import SourceCodeViewer from './SourceCodeViewer'; import RunModelButton from './RunModelButton'; import './styles.css'; import config from '../config'; import LogsViewer from './LogsViewer'; const POP = 2; const SCATTER = 3; const DATA = 4; const SOURCE = 5; const LOG = 6; const API_SERVER = `${config.API_URL}models/menu/`; class ActionMenu extends Component { constructor(props) { super(props); autoBind(this); this.state = { menu: {}, loadingData: true, envFile: {}, source: '', periodNum: 10, errorMessage: '', disabledButton: false, loadingSourceCode: false, loadingDebugger: false, loadingPopulation: false, loadingScatter: false, loadingLogs: false, activeDisplay: null, }; } async componentDidMount() { try { document.title = 'Indra | Menu'; const m = await axios.get(API_SERVER); this.setState({ menu: m.data, name: localStorage.getItem('name'), source: localStorage.getItem('source'), envFile: JSON.parse(localStorage.getItem('envFile')), msg: JSON.parse(localStorage.getItem('envFile')).user.user_msgs, loadingData: false, }); } catch (error) { return false; } const defaultGraph = localStorage.getItem('graph'); if (defaultGraph === 'scatter') { this.setState({ loadingScatter: true, activeDisplay: SCATTER, }); } else { this.setState({ loadingPopulation: true, activeDisplay: POP, }); } try { const code = await this.viewSource(); this.setState({ sourceCode: code, }); } catch (error) { return false; } return true; } viewSource = async () => { try { const { source } = this.state; const splitSource = source.split('/'); const filename = splitSource[splitSource.length - 1]; const res = await axios.get( `https://raw.githubusercontent.com/gcallah/indras_net/master/models/${filename}`, ); return res.data; } catch (error) { return 'Something has gone wrong.'; } }; handleRunPeriod = (e) => { this.setState({ periodNum: e.target.value, }); const valid = this.checkValidity(e.target.value); if (valid === 0) { this.setState({ errorMessage: '**Please input an integer', disabledButton: true, }); } else { this.setState({ errorMessage: '', disabledButton: false, }); } }; checkValidity = (data) => { if (data % 1 === 0) { return 1; } return 0; }; handleClick = (e) => { this.setState({ loadingData: false, loadingSourceCode: false, loadingDebugger: false, loadingScatter: false, loadingPopulation: false, loadingLogs: false, }); this.setState({ activeDisplay: e, }); switch (e) { case POP: this.setState({ loadingPopulation: true }); break; case SCATTER: this.setState({ loadingScatter: true }); break; case DATA: this.setState({ loadingDebugger: true }); break; case SOURCE: this.setState({ loadingSourceCode: true }); break; case LOG: this.setState({ loadingLogs: true }); break; default: break; } }; sendNumPeriods = async () => { const { periodNum, envFile } = this.state; this.setState({ loadingData: true }); try { const res = await axios.put( `${API_SERVER}run/${String(periodNum)}`, envFile, periodNum, ); this.setState({ envFile: res.data, loadingData: false, msg: res.data.user.user_msgs, }); return true; } catch (e) { return false; } }; renderHeader = () => { const { name } = this.state; return <h1 className="header">{name}</h1>; }; MenuItem = (i, action, text, key) => { /** * All models will have all the menu items appear on the page. * However, we keep one of the graphs (Population graph or Scatter plot) * disabled based on "graph" field from models.json */ const defaultGraph = localStorage.getItem('graph'); const { activeDisplay } = this.state; return ( <ListGroup.Item className="w-50 p-3 list-group-item list-group-item-action" as="li" active={activeDisplay === action} disabled={ (action === SCATTER && defaultGraph === 'line') || (action === POP && defaultGraph === 'scatter') } key={key} onClick={() => this.handleClick(action)} > {text} </ListGroup.Item> ); }; renderMenuItem = () => { const { envFile, loadingDebugger, loadingSourceCode, sourceCode, loadingPopulation, loadingScatter, loadingLogs, } = this.state; return ( <div className="mt-5"> <Debugger loadingData={loadingDebugger} envFile={envFile} /> <SourceCodeViewer loadingData={loadingSourceCode} code={sourceCode} /> <PopulationGraph loadingData={loadingPopulation} envFile={envFile} /> <ScatterPlot loadingData={loadingScatter} envFile={envFile} /> <LogsViewer loadingData={loadingLogs} envFile={envFile} /> </div> ); }; renderMapItem = () => { const { menu } = this.state; return ( <div className="row margin-bottom-80"> <div className="col w-25"> <ListGroup> {Object.keys(menu).map((item, i) => (menu[item].id > 1 ? this.MenuItem( i, menu[item].id, menu[item].question, menu[item].func, ) : null))} </ListGroup> </div> </div> ); }; render() { const { loadingData, msg, disabledButton, errorMessage, } = this.state; if (loadingData) { return <PageLoader />; } return ( <div> {this.renderHeader()} <div> <ModelStatusBox title="Model Status" msg={msg} ref={this.modelStatusBoxElement} /> </div> <ul className="list-group"> <div className="row"> <div> <RunModelButton disabledButton={disabledButton} errorMessage={errorMessage} sendNumPeriods={this.sendNumPeriods} handleRunPeriod={this.handleRunPeriod} /> <h3 className="margin-top-50 mb-4">Model Analysis:</h3> </div> </div> {this.renderMapItem()} </ul> {this.renderMenuItem()} </div> ); } } ActionMenu.propTypes = {}; ActionMenu.defaultProps = { history: {}, }; export default ActionMenu;
src/components/MainPage/MainPage.js
ggdiam/storia
import React, { Component } from 'react'; import styles from './MainPage.css'; import withStyles from '../../decorators/withStyles'; import Link from '../Link'; import { canUseDOM } from 'fbjs/lib/ExecutionEnvironment'; import dataClient from '../../core/DataClient'; import cachedDataClient from '../../core/CachedDataClient'; import apiUrls from '../../constants/ApiUrls'; import localStorageHelper from '../../core/LocalStorageHelper'; import delayedLikeClient from '../../core/DelayedLikeClient'; import MomentsList from '../MomentsList'; import FilterType from '../../constants/FilterType'; @withStyles(styles) class MainPage extends Component { constructor(props) { super(props); this.loadMoreInProgress = false; this.loadedPages = 0; var filteredData = null; var data = props && props.data ? props.data : null; var filterType = this.loadFilterState(); if (data) { this.loadedPages = 1; //фильтруем данные filteredData = this.filterData(data, filterType); } //if (canUseDOM) { // console.log('MainPage ctor', data, filteredData, filterType); //} //начальное состояние this.state = { data: data, filteredData: filteredData, filterType: filterType }; //колбек на перезагрузку данных //не очень красиво, пока не придумал куда перенести delayedLikeClient.setReloadDataCallback(this.reloadData.bind(this)); } //нужно перезагрузить данные после лайка / unlike, чтобы синхронизировать состояние reloadData() { console.log('MainPage data reloading...'); if (this.loadedPages <= 1) { this.getFeedContent(); } else { var maxPages = this.loadedPages; var curPage = 0; function res(data) { curPage += 1; if (curPage < maxPages) { console.log('loadNextPage data loaded, curPage', curPage, 'loading more...'); this.loadNextPage(data).then(res.bind(this)); } else { //фильтруем данные var filteredData = this.filterData(data, this.state.filterType); //записываем в стейт this.setState({ data: data, filteredData: filteredData }); console.log('loadNextPage data loaded, curPage', curPage, 'reload finished'); } } this.loadNextPage(null, null, true).then(res.bind(this)) } } //загружает данные следующей страницы loadNextPage(currentData, minId, first) { return new Promise((resolve, reject) => { var url = ''; if (first) { url = apiUrls.FeedContent; } else { var min = minId ? minId : currentData.minId; url = `${apiUrls.FeedContent}?limit=20&until=${currentData.minId}`; } //получаем ленту cachedDataClient.get(url).then((data) => { if (currentData) { //мерджим данные item'ов с уже имеющимися data.items = currentData.items.concat(data.items); } currentData = data; //обновляем кэш cachedDataClient.saveDataForRequest(apiUrls.FeedContent, null, currentData); resolve(currentData); }).catch((err) => { console.error('loadNextPage err', err); reject(err); }) }) } //загрузить следующие страницы loadMore() { console.log('loadMore click'); if (this.state.data && !this.loadMoreInProgress) { this.loadMoreInProgress = true; this.loadNextPage(this.state.data).then((data) => { this.loadedPages += 1; console.log('loadMore, loadedPages', this.loadedPages); //фильтруем данные var filteredData = this.filterData(data, this.state.filterType); //записываем в стейт this.setState({ data: data, filteredData: filteredData }); this.loadMoreInProgress = false; }).catch((err) => { console.log('load more err', err); }) } } componentDidMount() { var data = this.state.data; if (!data) { //получаем данные this.getFeedContent(); } } loadFilterState() { if (canUseDOM) { //если в браузере - получаем фильтр var filter = localStorageHelper.getItem('filter'); if (filter) { return filter; } } //по-умолчанию - выводим все return FilterType.All; } setFilter(filterType) { //сохраняем фильтр в localStorage localStorageHelper.setItem('filter', filterType); var data = this.state.data ? this.state.data : null; //фильтруем данные var filteredData = this.filterData(data, filterType); //записываем в стейт this.setState({ filterType: filterType, filteredData: filteredData }) } //Фильтрует список моментов согласно фильтру filterData(data, filterType) { //deep copy var filteredData = JSON.parse(JSON.stringify(data)); var items = filteredData.items; //console.log('filterData before count:', items.length); if (filterType == FilterType.WithPictures) { //фильтруем с каритнками filteredData.items = items.filter((item, ix)=> { return item.objectPreview.attachments.length > 0; }); } else if (filterType == FilterType.WithOutPictures) { //фильтруем без каритнок filteredData.items = items.filter((item, ix)=> { return item.objectPreview.attachments.length == 0; }); } //console.log('filterData after count:', filteredData.items.length); return filteredData; } //Получает данные getFeedContent() { //получаем ленту cachedDataClient.get(apiUrls.FeedContent).then((data) => { //console.log(data); //ToDo: debug //data.items[1].objectPreview.attachments = [ // {file: {title: 'my_fav_img.png'}}, // {file: {title: 'my_fav_img_two.png'}}, // {file: {title: 'my_fav_img_3.png'}} //]; //фильтруем данные var filteredData = this.filterData(data, this.state.filterType); //записываем в стейт this.setState({ data: data, filteredData: filteredData }) }).catch((err) => { console.error('getFeedContent err', err); }) } renderFilter() { var data = this.state ? this.state.data : null; var filterType = this.state.filterType; var defaultClassName = "btn btn-default"; var activeClassName = "btn btn-default active"; if (data) { return ( <div className="MainPage-toolbar btn-toolbar" role="toolbar"> <div className="btn-group"> <button title="Все моменты" type="button" onClick={(e)=>this.setFilter(FilterType.All)} className={filterType == FilterType.All ? activeClassName : defaultClassName}> <span className="glyphicon glyphicon-asterisk"></span> </button> <button title="Моменты с картинками" type="button" onClick={(e)=>this.setFilter(FilterType.WithPictures)} className={filterType == FilterType.WithPictures ? activeClassName : defaultClassName}> <span className="glyphicon glyphicon-picture"></span> </button> <button title="Моменты без картинок" type="button" onClick={(e)=>this.setFilter(FilterType.WithOutPictures)} className={filterType == FilterType.WithOutPictures ? activeClassName : defaultClassName}> <span className="glyphicon glyphicon-th-list"></span> </button> </div> </div> ) } return null; } render() { var data = this.state ? this.state.filteredData : null; if (data) { var filterType = this.state.filterType; console.log('render', filterType, 'data items length', data.items.length); } if (data) { //флаг загрузки еще var loadMoreAvailable = data.moreAvailable; return ( <div className="MainPage"> <div className="container"> { this.renderFilter() } <MomentsList data={data} reloadData={this.reloadData.bind(this)}/> { loadMoreAvailable ? <button onClick={this.loadMore.bind(this)} className="btn btn-default">Load More</button> : null } </div> </div> ); } else { return ( <div className="MainPage"> <div className="container"> <br /> <br /> Loading... <br /> <br /> </div> </div> ) } } } export default MainPage;
imports/ui/components/resident-details/accounts/transaction/transaction-mc.js
gagpmr/app-met
import React from 'react'; import * as Styles from '/imports/modules/styles.js'; import { UpdateResident } from '/imports/api/residents/methods.js'; export class TransactionMc extends React.Component { constructor(props) { super(props); } removeBill(e) { e.preventDefault(); var resid = e.currentTarget.dataset.resid; var billId = e.currentTarget.dataset.billid; var data = { ResidentId: resid, DeleteTransactionMcBill: true, BillId: billId } UpdateResident.call({ data: data }, (error, result) => { if (error) { Bert.alert(error, 'danger'); } }); } render() { if (this.props.resident.TxnMcBills) { return ( <table style={ Styles.TableHeader } className="table table-bordered table-condensed table-striped"> <thead> <tr> <td style={ Styles.PaddingThreeCenterBold }> Sr </td> <td style={ Styles.PaddingThreeCenterBold }> Span </td> <td style={ Styles.PaddingThreeCenterBold }> Mess-1 </td> <td style={ Styles.PaddingThreeCenterBold }> Mess-2 </td> <td style={ Styles.PaddingThreeCenterBold }> M-Fine </td> <td style={ Styles.PaddingThreeCenterBold }> Canteen </td> <td style={ Styles.PaddingThreeCenterBold }> Can-Fine </td> <td style={ Styles.PaddingThreeCenterBold }> Amenity </td> <td style={ Styles.PaddingThreeCenterBold }> Total </td> <td style={ Styles.PaddingThreeCenterBold }> Actions </td> </tr> </thead> <tbody> { this.props.resident.TxnMcBills.map((doc) => <tr key={ doc._id }> <td style={ Styles.PaddingThreeCenter }> { doc.SrNo } </td> <td style={ Styles.PaddingThreeCenter }> { doc.Month } </td> <td style={ Styles.PaddingThreeCenter }> { doc.MessOne } </td> <td style={ Styles.PaddingThreeCenter }> { doc.MessTwo } </td> <td style={ Styles.PaddingThreeCenter }> { doc.MessFine } </td> <td style={ Styles.PaddingThreeCenter }> { doc.Canteen } </td> <td style={ Styles.PaddingThreeCenter }> { doc.CanteenFine } </td> <td style={ Styles.PaddingThreeCenter }> { doc.Amenity } </td> <td style={ Styles.PaddingThreeCenter }> { doc.Total } </td> <td style={ Styles.PaddingThreeCenterBold }> <a onClick={ this.removeBill } data-resid={ this.props.resident._id } data-billid={ doc._id } data-toggle="tooltip" title="Delete From Transaction" href=""> <i className="fa fa-trash-o" aria-hidden="true"></i> </a> </td> </tr>) } </tbody> </table> ); } else { return null; } } }; TransactionMc.propTypes = { resident: React.PropTypes.object };
node_modules/react-bootstrap/es/PagerItem.js
NickingMeSpace/questionnaire
import _extends from 'babel-runtime/helpers/extends'; import _objectWithoutProperties from 'babel-runtime/helpers/objectWithoutProperties'; import _classCallCheck from 'babel-runtime/helpers/classCallCheck'; import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn'; import _inherits from 'babel-runtime/helpers/inherits'; import classNames from 'classnames'; import React from 'react'; import PropTypes from 'prop-types'; import SafeAnchor from './SafeAnchor'; import createChainedFunction from './utils/createChainedFunction'; var propTypes = { disabled: PropTypes.bool, previous: PropTypes.bool, next: PropTypes.bool, onClick: PropTypes.func, onSelect: PropTypes.func, eventKey: PropTypes.any }; var defaultProps = { disabled: false, previous: false, next: false }; var PagerItem = function (_React$Component) { _inherits(PagerItem, _React$Component); function PagerItem(props, context) { _classCallCheck(this, PagerItem); var _this = _possibleConstructorReturn(this, _React$Component.call(this, props, context)); _this.handleSelect = _this.handleSelect.bind(_this); return _this; } PagerItem.prototype.handleSelect = function handleSelect(e) { var _props = this.props, disabled = _props.disabled, onSelect = _props.onSelect, eventKey = _props.eventKey; if (onSelect || disabled) { e.preventDefault(); } if (disabled) { return; } if (onSelect) { onSelect(eventKey, e); } }; PagerItem.prototype.render = function render() { var _props2 = this.props, disabled = _props2.disabled, previous = _props2.previous, next = _props2.next, onClick = _props2.onClick, className = _props2.className, style = _props2.style, props = _objectWithoutProperties(_props2, ['disabled', 'previous', 'next', 'onClick', 'className', 'style']); delete props.onSelect; delete props.eventKey; return React.createElement( 'li', { className: classNames(className, { disabled: disabled, previous: previous, next: next }), style: style }, React.createElement(SafeAnchor, _extends({}, props, { disabled: disabled, onClick: createChainedFunction(onClick, this.handleSelect) })) ); }; return PagerItem; }(React.Component); PagerItem.propTypes = propTypes; PagerItem.defaultProps = defaultProps; export default PagerItem;
demo/component/Sankey.js
thoqbk/recharts
import React, { Component } from 'react'; import { Sankey, Tooltip } from 'recharts'; import _ from 'lodash'; import DemoSankeyLink from './DemoSankeyLink'; import DemoSankeyNode from './DemoSankeyNode'; const data0 = { nodes: [ { name: 'Agricultural waste' }, { name: 'Bio-conversion' }, { name: 'Liquid' }, { name: 'Losses' }, { name: 'Solid' }, { name: 'Gas' }, { name: 'Biofuel imports' }, { name: 'Biomass imports' }, { name: 'Coal imports' }, { name: 'Coal' }, { name: 'Coal reserves' }, { name: 'District heating' }, { name: 'Industry' }, { name: 'Heating and cooling - commercial' }, { name: 'Heating and cooling - homes' }, { name: 'Electricity grid' }, { name: 'Over generation / exports' }, { name: 'H2 conversion' }, { name: 'Road transport' }, { name: 'Agriculture' }, { name: 'Rail transport' }, { name: 'Lighting & appliances - commercial' }, { name: 'Lighting & appliances - homes' }, { name: 'Gas imports' }, { name: 'Ngas' }, { name: 'Gas reserves' }, { name: 'Thermal generation' }, { name: 'Geothermal' }, { name: 'H2' }, { name: 'Hydro' }, { name: 'International shipping' }, { name: 'Domestic aviation' }, { name: 'International aviation' }, { name: 'National navigation' }, { name: 'Marine algae' }, { name: 'Nuclear' }, { name: 'Oil imports' }, { name: 'Oil' }, { name: 'Oil reserves' }, { name: 'Other waste' }, { name: 'Pumped heat' }, { name: 'Solar PV' }, { name: 'Solar Thermal' }, { name: 'Solar' }, { name: 'Tidal' }, { name: 'UK land based bioenergy' }, { name: 'Wave' }, { name: 'Wind' }, ], links: [ { source: 0, target: 1, value: 124.729 }, { source: 1, target: 2, value: 0.597 }, { source: 1, target: 3, value: 26.862 }, { source: 1, target: 4, value: 280.322 }, { source: 1, target: 5, value: 81.144 }, { source: 6, target: 2, value: 35 }, { source: 7, target: 4, value: 35 }, { source: 8, target: 9, value: 11.606 }, { source: 10, target: 9, value: 63.965 }, { source: 9, target: 4, value: 75.571 }, { source: 11, target: 12, value: 10.639 }, { source: 11, target: 13, value: 22.505 }, { source: 11, target: 14, value: 46.184 }, { source: 15, target: 16, value: 104.453 }, { source: 15, target: 14, value: 113.726 }, { source: 15, target: 17, value: 27.14 }, { source: 15, target: 12, value: 342.165 }, { source: 15, target: 18, value: 37.797 }, { source: 15, target: 19, value: 4.412 }, { source: 15, target: 13, value: 40.858 }, { source: 15, target: 3, value: 56.691 }, { source: 15, target: 20, value: 7.863 }, { source: 15, target: 21, value: 90.008 }, { source: 15, target: 22, value: 93.494 }, { source: 23, target: 24, value: 40.719 }, { source: 25, target: 24, value: 82.233 }, { source: 5, target: 13, value: 0.129 }, { source: 5, target: 3, value: 1.401 }, { source: 5, target: 26, value: 151.891 }, { source: 5, target: 19, value: 2.096 }, { source: 5, target: 12, value: 48.58 }, { source: 27, target: 15, value: 7.013 }, { source: 17, target: 28, value: 20.897 }, { source: 17, target: 3, value: 6.242 }, { source: 28, target: 18, value: 20.897 }, { source: 29, target: 15, value: 6.995 }, { source: 2, target: 12, value: 121.066 }, { source: 2, target: 30, value: 128.69 }, { source: 2, target: 18, value: 135.835 }, { source: 2, target: 31, value: 14.458 }, { source: 2, target: 32, value: 206.267 }, { source: 2, target: 19, value: 3.64 }, { source: 2, target: 33, value: 33.218 }, { source: 2, target: 20, value: 4.413 }, { source: 34, target: 1, value: 4.375 }, { source: 24, target: 5, value: 122.952 }, { source: 35, target: 26, value: 839.978 }, { source: 36, target: 37, value: 504.287 }, { source: 38, target: 37, value: 107.703 }, { source: 37, target: 2, value: 611.99 }, { source: 39, target: 4, value: 56.587 }, { source: 39, target: 1, value: 77.81 }, { source: 40, target: 14, value: 193.026 }, { source: 40, target: 13, value: 70.672 }, { source: 41, target: 15, value: 59.901 }, { source: 42, target: 14, value: 19.263 }, { source: 43, target: 42, value: 19.263 }, { source: 43, target: 41, value: 59.901 }, { source: 4, target: 19, value: 0.882 }, { source: 4, target: 26, value: 400.12 }, { source: 4, target: 12, value: 46.477 }, { source: 26, target: 15, value: 525.531 }, { source: 26, target: 3, value: 787.129 }, { source: 26, target: 11, value: 79.329 }, { source: 44, target: 15, value: 9.452 }, { source: 45, target: 1, value: 182.01 }, { source: 46, target: 15, value: 19.013 }, { source: 47, target: 15, value: 289.366 }, ], }; const data1 = { nodes: [ { name: 'Visit' }, { name: 'Direct-Favourite' }, { name: 'Page-Click' }, { name: 'Detail-Favourite' }, { name: 'Lost' }, ], links: [ { source: 0, target: 1, value: 3728.3 }, { source: 0, target: 2, value: 354170 }, { source: 2, target: 3, value: 62429 }, { source: 2, target: 4, value: 291741 }, ], }; function SankeyDemo() { return ( <div className="sankey-charts"> <div> <pre>1. Simple Sankey</pre> <Sankey width={960} height={500} data={data0}> <Tooltip /> </Sankey> </div> <br /> <div> <pre>2. Customized Sankey.</pre> <Sankey width={960} height={500} data={data0} node={{ fill: '#8a52b6' }} link={{ stroke: '#77c878' }} > {/* <Tooltip /> */} </Sankey> </div> <br /> <div> <pre>2. Sankey with gradient color, name and value, and use margin to avoid outer-clip.</pre> <Sankey width={960} height={500} margin={{ top: 20, bottom: 20 }} data={data1} nodeWidth={10} nodePadding={60} linkCurvature={0.61} iterations={64} link={<DemoSankeyLink />} node={<DemoSankeyNode containerWidth={960} />} > <defs> <linearGradient id={'linkGradient'}> <stop offset="0%" stopColor="rgba(0, 136, 254, 0.5)" /> <stop offset="100%" stopColor="rgba(0, 197, 159, 0.3)" /> </linearGradient> </defs> </Sankey> </div> </div> ); } export default SankeyDemo;
public/js/entry.js
2cats/webserial
import React from 'react' import Root from './Root' import ReactDOM from 'react-dom' ReactDOM.render( <Root/>,document.getElementById('root') );
docs/src/app/components/pages/components/List/ExampleSimple.js
pomerantsev/material-ui
import React from 'react'; import MobileTearSheet from '../../../MobileTearSheet'; import {List, ListItem} from 'material-ui/List'; import ContentInbox from 'material-ui/svg-icons/content/inbox'; import ActionGrade from 'material-ui/svg-icons/action/grade'; import ContentSend from 'material-ui/svg-icons/content/send'; import ContentDrafts from 'material-ui/svg-icons/content/drafts'; import Divider from 'material-ui/Divider'; import ActionInfo from 'material-ui/svg-icons/action/info'; const ListExampleSimple = () => ( <MobileTearSheet> <List> <ListItem primaryText="Inbox" leftIcon={<ContentInbox />} /> <ListItem primaryText="Starred" leftIcon={<ActionGrade />} /> <ListItem primaryText="Sent mail" leftIcon={<ContentSend />} /> <ListItem primaryText="Drafts" leftIcon={<ContentDrafts />} /> <ListItem primaryText="Inbox" leftIcon={<ContentInbox />} /> </List> <Divider /> <List> <ListItem primaryText="All mail" rightIcon={<ActionInfo />} /> <ListItem primaryText="Trash" rightIcon={<ActionInfo />} /> <ListItem primaryText="Spam" rightIcon={<ActionInfo />} /> <ListItem primaryText="Follow up" rightIcon={<ActionInfo />} /> </List> </MobileTearSheet> ); export default ListExampleSimple;
app/server/index.js
ShandyClub/shandy-club
import 'regenerator-runtime/runtime' import express from 'express' import path from 'path' import httpProxy from 'http-proxy' import bodyParser from 'body-parser' import compression from 'compression' import React from 'react' import { renderToString } from 'react-dom/server' import { Provider } from 'react-redux' import { match, RouterContext } from 'react-router' import configureStore from '../universal/shared/store/configureStore' import rootSaga from '../universal/shared/sagas' import routes from '../universal/routes' import ApiRoutes from './routes' import './database' // critical CSS - temp fix for https://github.com/styled-components/styled-components/issues/124 import styles from './styles' // setup express const app = express() const PORT = process.env.PORT || 8000 const isApiRoute = path => path.match(/^\/api/) const isDevelopment = process.env.NODE_ENV === 'development' // construct static assets path const staticPath = isDevelopment ? path.join(__dirname, '../../public') : './' // layout method // TODO - abstract this template const renderPage = (html, initialState) => ` <!DOCTYPE html> <html> <meta charset="utf-8"> <title>Shandy Club</title> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no" media="(device-height: 568px)" /> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/10up-sanitize.css/4.1.0/sanitize.min.css"> <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Lato:700|Karla"> <link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons"> <link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css" /> <link rel="shortcut icon" href="/favicon.png"> ${styles} <div id="Root">${html}</div> <script>window.__INITIAL_STATE__ = ${initialState}</script> <script src="/bundle.js"></script> ` // compress static assets in production if (!isDevelopment) app.use(compression()) // serve static assets app.use(express.static(staticPath)) // parser app.use(bodyParser.json()) app.use(bodyParser.urlencoded({ extended: false })) // API routes app.use('/api', ApiRoutes) // development env if (isDevelopment) { // proxy non-API requests to webpack-dev-server const proxy = httpProxy.createProxyServer() app.all('/*', function (req, res, next) { if (isApiRoute(req.path)) return next() proxy.web(req, res, { target: 'http://localhost:3000' }) }) } // send all non-API requests to index.html so browserHistory works app.use((req, res, next) => { if (isApiRoute(req.path)) return next() // create Redux store const store = configureStore() match({ routes, location: req.url }, (err, redirect, props) => { if (err) return res.status(500).send(err.message) else if (redirect) return res.redirect(redirect.pathname + redirect.search) else if (props) { // start sagas store.runSaga(rootSaga).done.then( () => { // Render the component to a string const html = renderToString( <Provider store={store}> <RouterContext {...props}/> </Provider> ) // Grab the initial state from our Redux store const initialState = JSON.stringify(store.getState()) // Send the rendered page back to the client res.send(renderPage(html, initialState)) }).catch( e => res.status(500).send(e.message) ) // terminate sagas store.close() } else return res.status(404).send('Not Found') }) }) /* eslint-disable no-unused-vars */ // error handling app.use( (err, req, res, next) => { console.error(err.stack) res.status(500).send(err.message) }) /* eslint-enable no-unused-vars */ const server = app.listen(PORT, () => { console.log(`🍺 Production server running on port ${server.address().port}`) })
app/components/Sidebar.js
chehitskenniexd/Archiver
import React, { Component } from 'react'; import { Link, hashHistory } from 'react-router'; import { connect } from 'react-redux'; import styles from './Sidebar.css'; import Project_List from './Project_List'; import { fetchUserProjects } from '../reducers/projects_list'; import { logUserOut } from '../reducers/login'; import * as fs from 'fs'; import * as FEActions from '../../utilities/vcfrontend'; import { setCurrentProject } from '../reducers/currentsReducer'; import { clearProjects } from '../reducers/projects_list'; import { clearInvs } from '../reducers/invitations'; import axios from 'axios'; export class Sidebar extends Component { constructor(props) { super(props) this.localLogUserOut = this.localLogUserOut.bind(this); this.linkToHomeView = this.linkToHomeView.bind(this); } componentDidUpdate() { if (this.props.loginUser.id && !Object.keys(this.props.projects).length) { this.props.onLoadProjects(this.props.loginUser.id); } // Re-set the current project to the updated one (THIS IS NOT THE BEST WAY) const numCurrentCommits = this.props.currents && this.props.currents.currentProject ? this.props.currents.currentProject.commits.length : 0; const numProjectCommits = this.props.currents && this.props.currents.currentProject && this.props.projects ? this.props.projects.projects .filter(project => project.id === this.props.currents.currentProject.id)[0].commits.length : 0; this.props.currents && numCurrentCommits != numProjectCommits && axios.get(`http://localhost:3000/api/vcontrol/${this.props.currents.currentProject.id}`) .then(project => { const oldProject = project.data[0]; const newProject = Object.assign({}, oldProject, { commits: oldProject.commits.reverse() }) this.props.setCurrentProject(newProject); }); } linkToHomeView() { hashHistory.push('/mainHome'); } localLogUserOut() { this.props.logMeOut(); } linkToHomeView() { hashHistory.push('/mainHome'); } localLogUserOut() { // clear projects state and my invitations state after logout for next user login if (this.props.projects.id) { this.props.nullProjects(); this.props.nullInvs(); } // then log user out this.props.logMeOut(); } render() { return ( <div className={styles.container} > <div className="row"> <div className="col s12"> <Link> <span onClick={() => hashHistory.push('/info')}> <i className="small material-icons icon-light pull-right">info</i> </span> </Link> <br /> <br /> <Link onClick={this.linkToHomeView}> <div className="welcome-name light-text">Welcome, {this.props.loginUser.first_name}</div> <i className="material-icons large icon-light">person_pin</i> </Link> </div> <div> <Link to={'/'}> <h6 onClick={this.localLogUserOut} className="light-text">Logout</h6> </Link> </div> <div> <Project_List /> </div> </div> </div> ); } } function mapStateToProps(state) { return { loginUser: state.login, projects: state.projects, currents: state.currents } } function mapDispatchToProps(dispatch) { return { onLoadProjects: function (user) { dispatch(fetchUserProjects(user)); }, fetchProjects: (userId) => { dispatch(fetchUserProjects(userId)) }, setCurrentProject: (project) => { dispatch(setCurrentProject(project)); }, logMeOut: function () { dispatch(logUserOut()); }, nullProjects: () => { dispatch(clearProjects()); }, nullInvs: () => { dispatch(clearInvs()); } } } export default connect( mapStateToProps, mapDispatchToProps )(Sidebar);
src/docs/examples/RegistrationForm/ExampleRegistrationForm.js
dryzhkov/ps-react-dr
import React from 'react'; import RegistrationForm from 'ps-react/RegistrationForm'; /** Registration from with email and password inputs */ export default class ExampleRegistrationForm extends React.Component { onSubmit = (user) => { console.log(user); } render() { return <RegistrationForm confirmationMessage="Success!!!" onSubmit={this.onSubmit} minPasswordLength={8} /> } }
src/routes/UIElement/dropOption/index.js
yunqiangwu/kmadmin
import React from 'react' import { DropOption } from 'components' import { Table, Row, Col, Card, message } from 'antd' const DropOptionPage = () => (<div className="content-inner"> <Row gutter={32}> <Col lg={8} md={12}> <Card title="默认"> <DropOption menuOptions={[{ key: '1', name: '编辑' }, { key: '2', name: '删除' }]} /> </Card> </Col> <Col lg={8} md={12}> <Card title="样式"> <DropOption menuOptions={[{ key: '1', name: '编辑' }, { key: '2', name: '删除' }]} buttonStyle={{ border: 'solid 1px #eee', width: 60 }} /> </Card> </Col> <Col lg={8} md={12}> <Card title="事件"> <DropOption menuOptions={[{ key: '1', name: '编辑' }, { key: '2', name: '删除' }]} buttonStyle={{ border: 'solid 1px #eee', width: 60 }} onMenuClick={({ key }) => { switch (key) { case '1': message.success('点击了编辑') break case '2': message.success('点击了删除') break default: break } }} /> </Card> </Col> </Row> <h2 style={{ margin: '16px 0' }}>Props</h2> <Row> <Col lg={18} md={24}> <Table rowKey={(record, key) => key} pagination={false} bordered scroll={{ x: 800 }} columns={[ { title: '参数', dataIndex: 'props', }, { title: '说明', dataIndex: 'desciption', }, { title: '类型', dataIndex: 'type', }, { title: '默认值', dataIndex: 'default', }, ]} dataSource={[ { props: 'menuOptions', desciption: '下拉操作的选项,格式为[{name:string,key:string}]', type: 'Array', default: '必选', }, { props: 'onMenuClick', desciption: '点击 menuitem 调用此函数,参数为 {item, key, keyPath}', type: 'Function', default: '-', }, { props: 'buttonStyle', desciption: '按钮的样式', type: 'Object', default: '-', }, { props: 'dropdownProps', desciption: '下拉菜单的参数,可参考antd的【Dropdown】组件', type: 'Object', default: '-', }, ]} /> </Col> </Row> </div>) export default DropOptionPage
packages/reactor-kitchensink/src/examples/Tabs/TabBar/TabBar.js
dbuhrman/extjs-reactor
import React, { Component } from 'react'; import { TabBar, Tab, Panel, Container } from '@extjs/ext-react'; export default class TabBarExample extends Component { state = { activeTab: "download" } render() { const { activeTab } = this.state; return ( <Container layout={{ type: 'vbox', align: 'center' }} padding="10"> <Panel ui="instructions" margin="0 0 20 0" shadow > <div>To acheive the look and feel of tabs without using a <code>TabPanel</code>, you can use <code>TabBar</code> and <code>Tab</code> as standalone components.</div> </Panel> <TabBar width="400" shadow onActiveTabChange={this.onTabChange} activeTab={activeTab}> <Tab itemId="info" title="Info" iconCls="x-fa fa-info-circle" onActivate={this.onActivateTab}/> <Tab itemId="download" title="Download" iconCls="x-fa fa-download" badgeText="2" onActivate={this.onActivateTab}/> <Tab itemId="favorites" title="Favorites" iconCls="x-fa fa-star" onActivate={this.onActivateTab}/> <Tab itemId="bookmarks" title="Bookmarks" iconCls="x-fa fa-bookmark" onActivate={this.onActivateTab}/> </TabBar> <Panel ui="instructions" margin="20 0 0 0" shadow > <div>Active Tab: {activeTab}</div> </Panel> </Container> ) } onTabChange = (bar, tab) => { this.setState({ activeTab: tab.getItemId() }) } }
Libraries/Modal/Modal.js
formatlos/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 Modal * @flow */ 'use strict'; const AppContainer = require('AppContainer'); const I18nManager = require('I18nManager'); const Platform = require('Platform'); const React = require('React'); const PropTypes = require('prop-types'); const StyleSheet = require('StyleSheet'); const View = require('View'); const deprecatedPropType = require('deprecatedPropType'); const requireNativeComponent = require('requireNativeComponent'); const RCTModalHostView = requireNativeComponent('RCTModalHostView', null); /** * The Modal component is a simple way to present content above an enclosing view. * * _Note: If you need more control over how to present modals over the rest of your app, * then consider using a top-level Navigator._ * * ```javascript * import React, { Component } from 'react'; * import { Modal, Text, TouchableHighlight, View } from 'react-native'; * * class ModalExample extends Component { * * state = { * modalVisible: false, * } * * setModalVisible(visible) { * this.setState({modalVisible: visible}); * } * * render() { * return ( * <View style={{marginTop: 22}}> * <Modal * animationType="slide" * transparent={false} * visible={this.state.modalVisible} * onRequestClose={() => {alert("Modal has been closed.")}} * > * <View style={{marginTop: 22}}> * <View> * <Text>Hello World!</Text> * * <TouchableHighlight onPress={() => { * this.setModalVisible(!this.state.modalVisible) * }}> * <Text>Hide Modal</Text> * </TouchableHighlight> * * </View> * </View> * </Modal> * * <TouchableHighlight onPress={() => { * this.setModalVisible(true) * }}> * <Text>Show Modal</Text> * </TouchableHighlight> * * </View> * ); * } * } * ``` */ class Modal extends React.Component { static propTypes = { /** * The `animationType` prop controls how the modal animates. * * - `slide` slides in from the bottom * - `fade` fades into view * - `none` appears without an animation * * Default is set to `none`. */ animationType: PropTypes.oneOf(['none', 'slide', 'fade']), /** * The `presentationStyle` prop controls how the modal appears (generally on larger devices such as iPad or plus-sized iPhones). * See https://developer.apple.com/reference/uikit/uimodalpresentationstyle for details. * @platform ios * * - `fullScreen` covers the screen completely * - `pageSheet` covers portrait-width view centered (only on larger devices) * - `formSheet` covers narrow-width view centered (only on larger devices) * - `overFullScreen` covers the screen completely, but allows transparency * * Default is set to `overFullScreen` or `fullScreen` depending on `transparent` property. */ presentationStyle: PropTypes.oneOf(['fullScreen', 'pageSheet', 'formSheet', 'overFullScreen']), /** * The `transparent` prop determines whether your modal will fill the entire view. Setting this to `true` will render the modal over a transparent background. */ transparent: PropTypes.bool, /** * The `hardwareAccelerated` prop controls whether to force hardware acceleration for the underlying window. * @platform android */ hardwareAccelerated: PropTypes.bool, /** * The `visible` prop determines whether your modal is visible. */ visible: PropTypes.bool, /** * The `onRequestClose` callback is called when the user taps the hardware back button. * @platform android */ onRequestClose: Platform.OS === 'android' ? PropTypes.func.isRequired : PropTypes.func, /** * The `onShow` prop allows passing a function that will be called once the modal has been shown. */ onShow: PropTypes.func, animated: deprecatedPropType( PropTypes.bool, 'Use the `animationType` prop instead.' ), /** * The `supportedOrientations` prop allows the modal to be rotated to any of the specified orientations. * On iOS, the modal is still restricted by what's specified in your app's Info.plist's UISupportedInterfaceOrientations field. * When using `presentationStyle` of `pageSheet` or `formSheet`, this property will be ignored by iOS. * @platform ios */ supportedOrientations: PropTypes.arrayOf(PropTypes.oneOf(['portrait', 'portrait-upside-down', 'landscape', 'landscape-left', 'landscape-right'])), /** * The `onOrientationChange` callback is called when the orientation changes while the modal is being displayed. * The orientation provided is only 'portrait' or 'landscape'. This callback is also called on initial render, regardless of the current orientation. * @platform ios */ onOrientationChange: PropTypes.func, }; static defaultProps = { visible: true, hardwareAccelerated: false, }; static contextTypes = { rootTag: PropTypes.number, }; constructor(props: Object) { super(props); Modal._confirmProps(props); } componentWillReceiveProps(nextProps: Object) { Modal._confirmProps(nextProps); } static _confirmProps(props: Object) { if (props.presentationStyle && props.presentationStyle !== 'overFullScreen' && props.transparent) { console.warn(`Modal with '${props.presentationStyle}' presentation style and 'transparent' value is not supported.`); } } render(): ?React.Element<any> { if (this.props.visible === false) { return null; } const containerStyles = { backgroundColor: this.props.transparent ? 'transparent' : 'white', }; let animationType = this.props.animationType; if (!animationType) { // manually setting default prop here to keep support for the deprecated 'animated' prop animationType = 'none'; if (this.props.animated) { animationType = 'slide'; } } let presentationStyle = this.props.presentationStyle; if (!presentationStyle) { presentationStyle = 'fullScreen'; if (this.props.transparent) { presentationStyle = 'overFullScreen'; } } const innerChildren = __DEV__ ? ( <AppContainer rootTag={this.context.rootTag}> {this.props.children} </AppContainer>) : this.props.children; return ( <RCTModalHostView animationType={animationType} presentationStyle={presentationStyle} transparent={this.props.transparent} hardwareAccelerated={this.props.hardwareAccelerated} onRequestClose={this.props.onRequestClose} onShow={this.props.onShow} style={styles.modal} onStartShouldSetResponder={this._shouldSetResponder} supportedOrientations={this.props.supportedOrientations} onOrientationChange={this.props.onOrientationChange} > <View style={[styles.container, containerStyles]}> {innerChildren} </View> </RCTModalHostView> ); } // We don't want any responder events bubbling out of the modal. _shouldSetResponder(): boolean { return true; } } const side = I18nManager.isRTL ? 'right' : 'left'; const styles = StyleSheet.create({ modal: { position: 'absolute', }, container: { position: 'absolute', [side] : 0, top: 0, } }); module.exports = Modal;
src/svg-icons/social/notifications.js
rhaedes/material-ui
import React from 'react'; import pure from 'recompose/pure'; import SvgIcon from '../../SvgIcon'; let SocialNotifications = (props) => ( <SvgIcon {...props}> <path d="M12 22c1.1 0 2-.9 2-2h-4c0 1.1.89 2 2 2zm6-6v-5c0-3.07-1.64-5.64-4.5-6.32V4c0-.83-.67-1.5-1.5-1.5s-1.5.67-1.5 1.5v.68C7.63 5.36 6 7.92 6 11v5l-2 2v1h16v-1l-2-2z"/> </SvgIcon> ); SocialNotifications = pure(SocialNotifications); SocialNotifications.displayName = 'SocialNotifications'; export default SocialNotifications;
test/TooltipSpec.js
deerawan/react-bootstrap
import React from 'react'; import ReactTestUtils from 'react/lib/ReactTestUtils'; import Tooltip from '../src/Tooltip'; describe('Tooltip', function () { it('Should output a tooltip with content', function () { let instance = ReactTestUtils.renderIntoDocument( <Tooltip positionTop={10} positionLeft={20}> <strong>Tooltip Content</strong> </Tooltip> ); assert.ok(ReactTestUtils.findRenderedDOMComponentWithTag(instance, 'strong')); const tooltip = ReactTestUtils.findRenderedDOMComponentWithClass(instance, 'tooltip'); assert.deepEqual(tooltip.props.style, {top: 10, left: 20}); }); describe('When a style property is provided', function () { it('Should render a tooltip with merged styles', function () { let instance = ReactTestUtils.renderIntoDocument( <Tooltip style={{opacity: 0.9}} positionTop={10} positionLeft={20}> <strong>Tooltip Content</strong> </Tooltip> ); const tooltip = ReactTestUtils.findRenderedDOMComponentWithClass(instance, 'tooltip'); assert.deepEqual(tooltip.props.style, {opacity: 0.9, top: 10, left: 20}); }); }); });
app/app/components/Dashboard/ProgramLogo.js
lycha/masters-thesis
import React from 'react'; class ProgramLogo extends React.Component { constructor(props) { super(props); this.displayName = 'ProgramLogo'; } render() { return ( <div className="col-lg-4 col-md-4 col-sm-4 mb"> <div className="darkblue-panel pn"> <div id="profile-program"> <div className="user"> <img className="img-circle" width="200" src="../public/assets/img/gt-logo.png" /> </div> </div> </div> </div> ); } } export default ProgramLogo;
src/svg-icons/places/child-friendly.js
tan-jerene/material-ui
import React from 'react'; import pure from 'recompose/pure'; import SvgIcon from '../../SvgIcon'; let PlacesChildFriendly = (props) => ( <SvgIcon {...props}> <path d="M13 2v8h8c0-4.42-3.58-8-8-8zm6.32 13.89C20.37 14.54 21 12.84 21 11H6.44l-.95-2H2v2h2.22s1.89 4.07 2.12 4.42c-1.1.59-1.84 1.75-1.84 3.08C4.5 20.43 6.07 22 8 22c1.76 0 3.22-1.3 3.46-3h2.08c.24 1.7 1.7 3 3.46 3 1.93 0 3.5-1.57 3.5-3.5 0-1.04-.46-1.97-1.18-2.61zM8 20c-.83 0-1.5-.67-1.5-1.5S7.17 17 8 17s1.5.67 1.5 1.5S8.83 20 8 20zm9 0c-.83 0-1.5-.67-1.5-1.5S16.17 17 17 17s1.5.67 1.5 1.5S17.83 20 17 20z"/> </SvgIcon> ); PlacesChildFriendly = pure(PlacesChildFriendly); PlacesChildFriendly.displayName = 'PlacesChildFriendly'; PlacesChildFriendly.muiName = 'SvgIcon'; export default PlacesChildFriendly;
dev/test-studio/parts/tools/test-intent-tool.js
sanity-io/sanity
import React from 'react' import {route, withRouterHOC} from '@sanity/base/router' export default { router: route('/:type/:id'), canHandleIntent(intentName, params) { return (intentName === 'edit' && params.id) || (intentName === 'create' && params.type) }, getIntentState(intentName, params) { return { type: params.type || '*', id: params.id, } }, title: 'Test intent', name: 'test-intent', component: withRouterHOC((props) => ( <div style={{padding: 10}}> <h2>Test intent precedence</h2> If you click an intent link (e.g. from search results) while this tool is open, it should be opened here. <pre>{JSON.stringify(props.router.state, null, 2)}</pre> </div> )), }
components/game-listing/component.js
kalle-manninen/veikkaaja
import React, { Component } from 'react'; import { View, FlatList, Text } from 'react-native'; import PropTypes from 'prop-types'; import { Game } from '../game'; import { styles } from './style'; class GameListing extends Component { constructor(props) { super(props); this.state = { refresh: this.props.refreshGameListing }; } _keyExtractor = (item, index) => item.id; _renderItem = ({ item }) => { const homeTeam = item.outcome.home; const awayTeam = item.outcome.away; return (<Game id={item.id} homeTeam={homeTeam} awayTeam={awayTeam} popularity={item.outcome.popularity} selectResult={(id, result) => { this.props.selectResult(id, result); this.setState({ refresh: !this.state.refresh }); }} selection={item.outcome.selection} />); }; render() { return ( <View style={styles.gameList}> <View style={styles.title}> <Text style={styles.titleText}>Home</Text><Text style={styles.titleText}>1 X 2</Text> <Text style={styles.titleText}>Away</Text> </View> { this.props.gamesList.length > 0 ? <FlatList data={this.props.gamesList[this.props.selectedGamesList].rows} renderItem={this._renderItem} keyExtractor={this._keyExtractor} extraData={this.state.refresh} /> : null } </View> ); } } GameListing.propTypes = { gamesList: PropTypes.array.isRequired, selectResult: PropTypes.func.isRequired, selectedGamesList: PropTypes.number, refreshGameListing: PropTypes.bool }; GameListing.defaultProps = { refreshGameListing: false }; export { GameListing };
app/components/instagram/HashTagPicsContainer.js
alexko13/block-and-frame
import React from 'react'; import HashTagPic from './HashTagPicComponent'; const HashTagPicsContainer = (props) => { return ( <div> <p> <i className="icon small instagram"></i>Tag your grams for this Spread with {props.hashtag} <i className="icon small arrow circle down"></i> </p> {props.hashTagPics.map((pic, index) => <HashTagPic key={index} id={index} pic = {pic} /> )} </div> ); }; export default HashTagPicsContainer;
src/components/Link/Link.js
kuao775/mandragora
/** * React Starter Kit (https://www.reactstarterkit.com/) * * Copyright © 2014-present Kriasoft, LLC. All rights reserved. * * This source code is licensed under the MIT license found in the * LICENSE.txt file in the root directory of this source tree. */ import React from 'react'; import PropTypes from 'prop-types'; import history from '../../history'; function isLeftClickEvent(event) { return event.button === 0; } function isModifiedEvent(event) { return !!(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey); } class Link extends React.Component { static propTypes = { to: PropTypes.string.isRequired, children: PropTypes.node.isRequired, onClick: PropTypes.func, }; static defaultProps = { onClick: null, }; handleClick = event => { if (this.props.onClick) { this.props.onClick(event); } if (isModifiedEvent(event) || !isLeftClickEvent(event)) { return; } if (event.defaultPrevented === true) { return; } event.preventDefault(); history.push(this.props.to); }; render() { const { to, children, ...props } = this.props; return ( <a href={to} {...props} onClick={this.handleClick}> {children} </a> ); } } export default Link;
packages/flow-upgrade/src/upgrades/0.53.0/ReactComponentSimplifyTypeArgs/__tests__/fixtures/DefaultPropsInferred.js
ylu1317/flow
// @flow import React from 'react'; class MyComponent extends React.Component<*, Props> { static defaultProps = {}; defaultProps: T; static props: T; static state: T; a: T; b = 5; c: T = 5; method() {} } const expression = () => class extends React.Component<*, Props> { static defaultProps = {}; defaultProps: T; static props: T; static state: T; a: T; b = 5; c: T = 5; method() {} }
app/components/SecondScene.js
ethan605/react-native-zero
/** * @providesModule ZeroProj.Components.SecondScene */ /* eslint-disable no-unused-vars */ import React from 'react'; /* eslint-enable no-unused-vars */ import { StyleSheet, View } from 'react-native'; import { Actions } from 'react-native-router-flux'; import Button from 'react-native-button'; // Utils import FontUtils from 'app/utils/FontUtils'; export default function SecondScene() { return ( <View style={styles.container}> <Button onPress={Actions.pop} style={styles.buttonText}> Back to FirstScene </Button> </View> ); } const styles = StyleSheet.create({ container: { alignItems: 'center', flex: 1, justifyContent: 'center', }, buttonText: FontUtils.build({ color: '#3b5998', size: 20, weight: FontUtils.weights.semibold, }), });
app/components/Toolbar.js
nantaphop/redd
import React from 'react' import AppBar from 'material-ui/AppBar' import Toolbar from 'material-ui/Toolbar' import styled from 'styled-components' const _AppBar = styled(AppBar)` margin-bottom: 2px; ` export default (props) => { return ( <_AppBar position="static" color="white" elevation={2} square> <Toolbar> {props.children} </Toolbar> </_AppBar> ) }
src/index.js
jiaolongchao/gallery-Picture
import 'core-js/fn/object/assign'; import React from 'react'; import ReactDOM from 'react-dom'; import App from './components/Main'; // Render the main component into the dom ReactDOM.render(<App />, document.getElementById('app'));
gadget-system-teamwork/src/components/users/LoginForm.js
TeodorDimitrov89/JS-Web-Teamwork-2017
import React from 'react' import Input from '../common/forms/Input' const LoginForm = (props) => ( <div className='container'> <form> <div className='error'>{props.error}</div> <Input type='email' name='email' value={props.user.email} placeholder='E-mail' onChange={props.onChange} /> <br /> <Input type='password' name='password' value={props.user.password} placeholder='Password' onChange={props.onChange} /> <input className='btn btn-primary' type='submit' value='login' onClick={props.onSave} /> <br /> </form> </div> ) export default LoginForm
src/CarouselCaption.js
dozoisch/react-bootstrap
import classNames from 'classnames'; import React from 'react'; import elementType from 'react-prop-types/lib/elementType'; import { bsClass, getClassSet, splitBsProps } from './utils/bootstrapUtils'; const propTypes = { componentClass: elementType, }; const defaultProps = { componentClass: 'div', }; class CarouselCaption extends React.Component { render() { const { componentClass: Component, className, ...props } = this.props; const [bsProps, elementProps] = splitBsProps(props); const classes = getClassSet(bsProps); return ( <Component {...elementProps} className={classNames(className, classes)} /> ); } } CarouselCaption.propTypes = propTypes; CarouselCaption.defaultProps = defaultProps; export default bsClass('carousel-caption', CarouselCaption);
src/scripts/views/components/avatar.js
DBozz/IronPong
import React from 'react' import ACTIONS from '../../actions.js' import STORE from '../../store.js' var Avatar = React.createClass({ render: function(){ return(<div className = 'avatar-wrapper'> </div>) } }) export default Avatar
actor-apps/app-web/src/app/components/modals/invite-user/ContactItem.react.js
ruikong/actor-platform
import React from 'react'; import { PureRenderMixin } from 'react/addons'; import AvatarItem from 'components/common/AvatarItem.react'; var ContactItem = React.createClass({ displayName: 'ContactItem', propTypes: { contact: React.PropTypes.object, onSelect: React.PropTypes.func }, mixins: [PureRenderMixin], _onSelect() { this.props.onSelect(this.props.contact); }, render() { let contact = this.props.contact; return ( <li className="contacts__list__item row"> <AvatarItem image={contact.avatar} placeholder={contact.placeholder} size="small" title={contact.name}/> <div className="col-xs"> <span className="title"> {contact.name} </span> </div> <div className="controls"> <a className="material-icons" onClick={this._onSelect}>add</a> </div> </li> ); } }); export default ContactItem;
js/customer/HaircutHistoryItem.js
BarberHour/barber-hour
import React, { Component } from 'react'; import { View, Text, StyleSheet, Image, } from 'react-native'; import Icon from 'react-native-vector-icons/MaterialIcons'; import HaircutDetails from './HaircutDetails'; import Touchable from '../common/Touchable'; export default class HaircutHistoryItem extends Component { _openDetails() { this.props.navigator.push({ component: HaircutDetails, passProps: {appointment: this.props.appointment} }); } _iconForStatus(status) { switch (status) { case 'finished': return 'alarm-on'; case 'canceled': return 'alarm-off'; case 'scheduled': return 'alarm'; } } render() { const { appointment } = this.props; const { schedule, barber } = appointment; return( <Touchable style={styles.card} onPress={this._openDetails.bind(this)}> <View> <View> <Text style={styles.date} numberOfLines={1}>{schedule.day_number} de {schedule.month_name} às {schedule.hour}</Text> <Text style={styles.barber} numberOfLines={1}>{barber.name}</Text> <View style={styles.statusContainer}> <Icon name={this._iconForStatus(appointment.status)} size={24} color='#003459' style={styles.icon} /> <Text>{appointment.translated_status}</Text> </View> </View> </View> </Touchable> ); } } var styles = StyleSheet.create({ card: { flexDirection: 'column', backgroundColor: 'white', borderColor: '#E8E8E8', borderWidth: 1, padding: 10, marginBottom: 10, borderRadius: 2, elevation: 2, flex: 1 }, date: { fontWeight: 'bold', color: '#292929', fontSize: 18 }, barber: { color: '#A2A2A2', fontSize: 18 }, icon: { marginRight: 5 }, statusContainer: { flexDirection: 'row', marginTop: 5, alignItems: 'center' } });
src/docs/examples/ProgressBar/Example10Percent.js
wsherman67/UBA
import React from 'react'; import ProgressBar from 'ps-react/ProgressBar'; /** 10% progress */ export default function Example10Percent() { return <ProgressBar percent={10} width={150} /> }
src/components/Switch/demo/basic/index.js
lebra/lebra-components
import React, { Component } from 'react'; import Switch from '../../index'; import { render } from 'react-dom'; import './index.less'; export default class SwitchDemo extends Component{ handleChange = (e) => { alert("切换") } render() { return ( <div className="switch-demo"> <div className="lebra-cells__title">Switch Demo</div> <div className="lebra-cells lebra-cells_form"> <div className="lebra-cell lebra-cell_switch"> <div className="lebra-cell__bd">默认选中状态,可切换</div> <div className="lebra-cell__ft"> <Switch defaultChecked={true} /> </div> </div> <div className="lebra-cell lebra-cell_switch"> <div className="lebra-cell__bd">默认未选中状态,可切换</div> <div className="lebra-cell__ft"> <Switch defaultChecked={false} handleChange={this.handleChange}/> </div> </div> <div className="lebra-cell lebra-cell_switch"> <div className="lebra-cell__bd">默认未选中状态,不可切换</div> <div className="lebra-cell__ft"> <Switch defaultChecked={false} disabled={true}/> </div> </div> </div> </div> ) } } let root = document.getElementById('app'); render(<SwitchDemo />, root);
src/client/components/message/chatMessageShortcut.js
uuchat/uuchat
import React, { Component } from 'react'; import { Modal, Input } from 'antd'; import '../../static/css/shortcut.css'; class ChatMessageShortcut extends Component{ constructor(){ super(); this.state={ isSetShow: false }; } setShortcut = () => { this.toggleSet(true); }; shortcutFetch = () => { let _self = this; let shortKey = this.refs.shortKey.input.value; let shortValue = this.refs.shortValue.textAreaRef.value; let bodyData = 'csid='+(localStorage.getItem('uuchat.csid') || '')+'&shortcut='+shortKey+'&msg='+shortValue; if (shortKey.replace(/^\s$/g, '') === '') { _self.toggleSet(false); return false; } fetch('/shortcuts', { credentials: 'include', method: 'POST', headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, body: bodyData }).then(d=>d.json()).then(data=>{ localStorage.setItem('newShortcut', '{"shortcut": "'+shortKey+'","msg": "'+shortValue+'", "action":"INSERT"}'); _self.toggleSet(false); }).catch((e)=>{}); }; shortcutCancel = () => { this.toggleSet(false); }; toggleSet = (flag) => { this.setState({ isSetShow: flag }); }; render(){ let { content } = this.props; content = content.replace(/&nbsp;/g, ' ').replace(/(^\s*)/g, '').replace(/&gt;/g, '>').replace(/&lt;/g, '<'); return ( <div className="short-item-setting" onClick={this.setShortcut}> <Modal title="Add a Personal Shortcut" visible={this.state.isSetShow} cancelText="Cancel" okText="Save" onCancel={this.shortcutCancel} onOk={this.shortcutFetch} > <div> <div className="set-item"> Add a personal shortcut for the text you want to expand then type <i>;</i> in chat to search for the shortcut. </div> <div className="set-item"> <p className="set-item-label">Shortcut</p> <Input defaultValue="" addonBefore=";" ref="shortKey" /> <p className="set-item-label">Expanded Message</p> <Input.TextArea defaultValue={content} ref="shortValue" /> </div> </div> </Modal> </div> ); } } export default ChatMessageShortcut;
app/containers/Preschool/Preschool.js
klpdotorg/tada-frontend
import React, { Component } from 'react'; import PropTypes from 'prop-types'; import { connect } from 'react-redux'; import isEmpty from 'lodash.isempty'; import get from 'lodash.get'; import { getBoundariesEntities, getLanguages, getInstitutionCategories, getManagements, openTeachers, toggleClassModal, } from '../../actions'; import { PreschoolView } from '../../components/Preschool'; import { checkPermissions, getEntitiesPath } from '../../utils'; class FetchPreschoolEntity extends Component { componentDidMount() { const { params, institution, parentId } = this.props; const { districtNodeId, projectNodeId, circleNodeId, institutionNodeId } = params; if (isEmpty(institution)) { const entities = [ parentId, districtNodeId, projectNodeId, circleNodeId, institutionNodeId, ].map((id, i) => { return { depth: i, uniqueId: id }; }); this.props.getBoundariesEntities(entities); } this.props.getLanguages(); this.props.getInstitutionCats(); this.props.getManagements(); } render() { const { params } = this.props; const { blockNodeId, districtNodeId, clusterNodeId, institutionNodeId } = params; const path = [districtNodeId, blockNodeId, clusterNodeId, institutionNodeId]; return <PreschoolView {...this.props} depth={path.length} />; } } FetchPreschoolEntity.propTypes = { params: PropTypes.object, institution: PropTypes.object, getBoundariesEntities: PropTypes.func, getLanguages: PropTypes.func, getInstitutionCats: PropTypes.func, getManagements: PropTypes.func, parentId: PropTypes.string, }; const mapStateToProps = (state, ownProps) => { const { districtNodeId, projectNodeId, circleNodeId, institutionNodeId } = ownProps.params; const { isAdmin } = state.profile; const district = get(state.boundaries.boundaryDetails, districtNodeId, {}); const project = get(state.boundaries.boundaryDetails, projectNodeId, {}); const circle = get(state.boundaries.boundaryDetails, circleNodeId, {}); const institution = get(state.boundaries.boundaryDetails, institutionNodeId, {}); const hasPermissions = checkPermissions( isAdmin, state.userPermissions, [district.id, project.id, circle.id], institution.id, ); const pathname = get(ownProps, ['location', 'pathname'], ''); const paths = getEntitiesPath(pathname, [districtNodeId, projectNodeId, circleNodeId]); return { district, project, circle, institution, isLoading: state.appstate.loadingBoundary, isAdmin, paths, hasPermissions, parentId: state.profile.parentNodeId, }; }; const Preschool = connect(mapStateToProps, { toggleClassModal, showTeachers: openTeachers, getBoundariesEntities, getLanguages, getInstitutionCats: getInstitutionCategories, getManagements, })(FetchPreschoolEntity); export default Preschool;
app/javascript/mastodon/features/account_gallery/components/media_item.js
codl/mastodon
import React from 'react'; import ImmutablePropTypes from 'react-immutable-proptypes'; import ImmutablePureComponent from 'react-immutable-pure-component'; import Permalink from '../../../components/permalink'; export default class MediaItem extends ImmutablePureComponent { static propTypes = { media: ImmutablePropTypes.map.isRequired, }; render () { const { media } = this.props; const status = media.get('status'); let content, style; if (media.get('type') === 'gifv') { content = <span className='media-gallery__gifv__label'>GIF</span>; } if (!status.get('sensitive')) { style = { backgroundImage: `url(${media.get('preview_url')})` }; } return ( <div className='account-gallery__item'> <Permalink to={`/statuses/${status.get('id')}`} href={status.get('url')} style={style} > {content} </Permalink> </div> ); } }
src/NavItem.js
simonliubo/react-ui
import React from 'react'; import classNames from 'classnames'; import BootstrapMixin from './BootstrapMixin'; import SafeAnchor from './SafeAnchor'; const NavItem = React.createClass({ mixins: [BootstrapMixin], propTypes: { linkId: React.PropTypes.string, onSelect: React.PropTypes.func, active: React.PropTypes.bool, disabled: React.PropTypes.bool, href: React.PropTypes.string, role: React.PropTypes.string, title: React.PropTypes.node, eventKey: React.PropTypes.any, target: React.PropTypes.string, 'aria-controls': React.PropTypes.string }, render() { let { role, linkId, disabled, active, href, title, target, children, 'aria-controls': ariaControls, ...props } = this.props; let classes = { active, disabled }; let linkProps = { role, href, title, target, id: linkId, onClick: this.handleClick }; if (!role && href === '#') { linkProps.role = 'button'; } return ( <li {...props} role='presentation' className={classNames(props.className, classes)}> <SafeAnchor {...linkProps} aria-selected={active} aria-controls={ariaControls}> { children } </SafeAnchor> </li> ); }, handleClick(e) { if (this.props.onSelect) { e.preventDefault(); if (!this.props.disabled) { this.props.onSelect(this.props.eventKey, this.props.href, this.props.target); } } } }); export default NavItem;
fixtures/packaging/systemjs-builder/prod/input.js
maxschmeling/react
import React from 'react'; import ReactDOM from 'react-dom'; ReactDOM.render( React.createElement('h1', null, 'Hello World!'), document.getElementById('container') );