path
stringlengths
5
195
repo_name
stringlengths
5
79
content
stringlengths
25
1.01M
src/components/Label/Label.js
nreoch25/react-package-dev
import React from 'react'; import PropTypes from 'prop-types'; /** Label with required field display, htmlFor, and block styling */ function Label({htmlFor, label, required}) { return ( <label style={{display: 'block'}} htmlFor={htmlFor}> {label} { required && <span style={{color: 'red'}}> *</span> } </label> ) } Label.propTypes = { /** HTML ID for associated input */ htmlFor: PropTypes.string.isRequired, /** Label text */ label: PropTypes.string.isRequired, /** Display asterisk after label if true */ required: PropTypes.bool }; export default Label;
app/containers/DevTools.js
jkusachi/gitty
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="ctrl-h" changePositionKey="ctrl-q" > <LogMonitor /> </DockMonitor> );
src/admin/client/modules/products/list/components/list.js
cezerin/cezerin
import React from 'react'; import { List } from 'material-ui/List'; import Divider from 'material-ui/Divider'; import Head from './head'; import ProductsListItem from './item'; import RaisedButton from 'material-ui/RaisedButton'; import FontIcon from 'material-ui/FontIcon'; import messages from 'lib/text'; import style from './style.css'; export default class ProductsList extends React.Component { constructor(props) { super(props); } componentDidMount() { this.props.onLoad(); } render() { const { items, selected, loadingItems, onSelect, onSelectAll, selectedAll, loadMore, settings, hasMore, totalCount } = this.props; const rows = items.map((item, index) => { const itemSelected = selected.includes(item.id); return ( <ProductsListItem key={index} product={item} selected={itemSelected} onSelect={onSelect} settings={settings} /> ); }); return ( <div> <List> <Head onSelectAll={onSelectAll} /> <Divider /> {rows} <div className={style.more}> <RaisedButton disabled={loadingItems || !hasMore} label={messages.actions_loadMore} labelPosition="before" primary={false} icon={<FontIcon className="material-icons">refresh</FontIcon>} onClick={loadMore} /> </div> </List> </div> ); } }
src/components/Testimonials.js
maria-robobug/resume_viewer
import React from 'react'; class Testimonials extends React.Component { render () { return ( <section id="testimonials"> <div className="text-container"> <div className="row"> <div className="two columns header-col"> <h1><span>Client Testimonials</span></h1> </div> <div className="ten columns flex-container"> <div className="flexslider"> <ul className="slides"> <li> <blockquote> <p>Your work is going to fill a large part of your life, and the only way to be truly satisfied is to do what you believe is great work. And the only way to do great work is to love what you do. If you haven't found it yet, keep looking. Don't settle. As with all matters of the heart, you'll know when you find it. </p> <cite>Steve Jobs</cite> </blockquote> </li> <li> <blockquote> <p>This is Photoshop's version of Lorem Ipsum. Proin gravida nibh vel velit auctor aliquet. Aenean sollicitudin, lorem quis bibendum auctor, nisi elit consequat ipsum, nec sagittis sem nibh id elit. Duis sed odio sit amet nibh vulputate cursus a sit amet mauris. </p> <cite>Mr. Adobe</cite> </blockquote> </li> </ul> </div> </div> </div> </div> </section> ); } } export default Testimonials;
src/svg-icons/image/photo-size-select-large.js
igorbt/material-ui
import React from 'react'; import pure from 'recompose/pure'; import SvgIcon from '../../SvgIcon'; let ImagePhotoSizeSelectLarge = (props) => ( <SvgIcon {...props}> <path d="M21 15h2v2h-2v-2zm0-4h2v2h-2v-2zm2 8h-2v2c1 0 2-1 2-2zM13 3h2v2h-2V3zm8 4h2v2h-2V7zm0-4v2h2c0-1-1-2-2-2zM1 7h2v2H1V7zm16-4h2v2h-2V3zm0 16h2v2h-2v-2zM3 3C2 3 1 4 1 5h2V3zm6 0h2v2H9V3zM5 3h2v2H5V3zm-4 8v8c0 1.1.9 2 2 2h12V11H1zm2 8l2.5-3.21 1.79 2.15 2.5-3.22L13 19H3z"/> </SvgIcon> ); ImagePhotoSizeSelectLarge = pure(ImagePhotoSizeSelectLarge); ImagePhotoSizeSelectLarge.displayName = 'ImagePhotoSizeSelectLarge'; ImagePhotoSizeSelectLarge.muiName = 'SvgIcon'; export default ImagePhotoSizeSelectLarge;
src/components/options/QRCodeShow.js
secretin/secretin-app
import React, { Component } from 'react'; import { connect } from 'react-redux'; import { bindActionCreators } from 'redux'; import PropTypes from 'prop-types'; import Secretin from 'secretin'; import QRCode from 'qrcode.react'; import Form from 'components/utilities/Form'; import Modal from 'components/utilities/Modal'; import Button from 'components/utilities/Button'; import Input from 'components/utilities/Input'; import * as OptionsActions from 'slices/OptionsSlice'; class QRCodeShow extends Component { static propTypes = { shown: PropTypes.bool, errors: PropTypes.object, loading: PropTypes.bool, actions: PropTypes.object, }; static defaultProps = { shown: false, errors: {}, loading: false, }; static getDerivedStateFromProps(nextProps) { if (!nextProps.shown) { return { seed: Secretin.Utils.generateSeed(), token: '', }; } return null; } constructor(props) { super(props); this.handleChange = this.handleChange.bind(this); this.handleSubmit = this.handleSubmit.bind(this); this.state = { seed: Secretin.Utils.generateSeed(), token: '', }; } handleChange(e) { const token = e.value.replace(/\s+/g, '').slice(0, 6); this.setState({ token, }); } handleSubmit() { this.props.actions.activateTotp(this.state); } render() { return ( <Modal show={this.props.shown} onClose={this.props.actions.hideQRCode}> <Modal.Header> <span className="text">Activate Two-Factor authentication</span> </Modal.Header> <Modal.Body> <Form className="totp-form" id="totp" onSubmit={this.handleSubmit}> <div className="totp-form-qrcode"> <QRCode className="totp-form-qrcode" value={`otpauth://totp/Secret-in.me?secret=${this.state.seed.b32}`} size={256} /> </div> <Input name="token" inputProps={{ maxLength: 6, }} placeholder="6-digit code" value={this.state.token} onChange={this.handleChange} onSubmit={this.handleSubmit} error={this.props.errors.totp} autoFocus /> </Form> </Modal.Body> <Modal.Footer> <Button type="reset" buttonStyle="default" onClick={this.props.actions.hideQRCode} > Close </Button> <Button type="button" buttonStyle="primary" onClick={this.handleSubmit} disabled={this.props.loading} > Activate </Button> </Modal.Footer> </Modal> ); } } const mapDispatchToProps = dispatch => ({ actions: bindActionCreators(OptionsActions, dispatch), }); const mapStateToProps = state => { const { errors, showQRCode, loading } = state.Options; return { errors, shown: showQRCode, loading, }; }; export default connect(mapStateToProps, mapDispatchToProps)(QRCodeShow);
internals/templates/homePage/homePage.js
s0enke/react-boilerplate
/* * HomePage * * This is the first thing users see of our App, at the '/' route * * NOTE: while this component should technically be a stateless functional * component (SFC), hot reloading does not currently support SFCs. If hot * reloading is not a neccessity for you then you can refactor it and remove * the linting exception. */ import React from 'react'; import { FormattedMessage } from 'react-intl'; import messages from './messages'; export default class HomePage extends React.Component { // eslint-disable-line react/prefer-stateless-function render() { return ( <h1> <FormattedMessage {...messages.header} /> </h1> ); } }
app/src/components/Badge.js
quiaro/chunches
import React from 'react'; import styled from 'styled-components'; const Styled = styled.span` position: absolute; top: 5px; right: 5px; background-color: ${props => props.theme.badge_background}; color: ${props => props.theme.badge_text}; font-size: 0.7rem; height: 1.2rem; width: 1.2rem; border-radius: 50%; line-height: 1.2rem; text-align: center; `; const Badge = ({ number }) => { return number ? <Styled> {number} </Styled> : null; }; export default Badge;
src/instacelebs.js
oded-soffrin/gkm_viewer
import React from 'react'; import {render} from 'react-dom'; import { Provider } from 'react-redux'; import configureStore from './store/configureStore'; require('./favicon.ico'); // Tell webpack to load favicon.ico import './styles/styles.scss'; // Yep, that's right. You can import SASS/CSS files too! Webpack will run the associated loader and plug this into the page. import InstaCelebs from './components/InstaCelebs' import { getStats } from './actions/instaActions' const store = configureStore(); store.dispatch(getStats()) render( <Provider store={store}> <InstaCelebs/> </Provider>, document.getElementById('app') );
src/entypo/Raft.js
cox-auto-kc/react-entypo
import React from 'react'; import EntypoIcon from '../EntypoIcon'; const iconClass = 'entypo-svgicon entypo--Raft'; let EntypoRaft = (props) => ( <EntypoIcon propClass={iconClass} {...props}> <path d="M5.6734395,19c-0.877316,0-1.6501045-0.3605442-2.1763153-1.0143661c-0.6450326-0.8027058-0.8514075-1.9354591-0.5816016-3.1901903l0.0580709-0.2699594l1.9735143,0.4313974l-0.0580707,0.269063c-0.13937,0.6448536-0.083086,1.1650429,0.1581311,1.4654961c0.148304,0.1838589,0.3591456,0.2780323,0.6262712,0.2780323c0.7754688,0,1.5446839-1.2412777,2.125392-3.4179964c-0.6360989-0.2161474-1.2203803-0.5354357-1.7403374-0.9524832l-0.213522-0.1713028l1.2579031-1.5892649l0.2153087,0.1722002c0.2742729,0.2206316,0.580708,0.4009037,0.9139452,0.5372286c0.1688519-0.968626,0.3037548-2.0323219,0.4029226-3.168664L8.659173,8.1047468l2.0110369,0.1775808l-0.0241213,0.2744446c-0.1018476,1.1695271-0.240324,2.2673035-0.4109631,3.2682171c1.3874464-0.1399126,2.6516027-0.9273701,3.3547068-2.1112471c1.152482-1.9408398,0.694169-4.3704782-1.0890512-5.7776766c-0.7620678-0.601804-1.8814945-0.9433796-2.9267693-0.8913608c-1.3043594,0.0547094-2.4041319,0.642029-3.2680469,1.765815C5.2660508,6.1621122,5.1561627,8.1881561,6.0450931,9.6267452l0.1447301,0.2340851L4.4745007,10.934391l-0.1447301-0.2349815c-1.338309-2.1677494-1.182858-5.1014323,0.3796935-7.1328573c1.2266345-1.59644,2.8794193-2.4716568,4.7805681-2.5514789c1.5518312-0.0609876,3.1134892,0.4205006,4.2570381,1.3218613c2.5944252,2.0466716,3.2573261,5.5875397,1.5768461,8.4180813c-0.7397337,1.2457609-1.8823881,2.1955528-3.2430325,2.7067728c0.2519379,0.3838625,0.4663534,0.8430634,0.712038,1.5139265l0.1581316,0.4394693c0.4967279,1.3874674,0.7236509,1.5112371,1.2453957,1.5112371c0.2358561,0,0.4940481-0.1004505,0.6566467-0.256506c0.3126888-0.2995567,0.4047089-0.8753519,0.2742729-1.7121372l-0.0428829-0.2726507l1.9949551-0.3148041l0.0428829,0.2726507c0.235857,1.513031-0.0678978,2.7229156-0.8773155,3.4987144c-0.5422916,0.5183945-1.2891722,0.8152599-2.0485592,0.8152599c-0.9309206,0-1.684948-0.3479881-2.239747-1.0332012c-0.3850546-0.4735508-0.5985765-0.9641418-0.9050112-1.8179684l-0.152771-0.4260159c-0.3546791-0.9677296-0.6682615-1.4565268-1.1203203-1.7067556c-0.1375828,0.5264664-0.2894602,1.0188513-0.453846,1.4681864C8.4599457,17.8026695,7.2315245,19,5.6734395,19z"/> </EntypoIcon> ); export default EntypoRaft;
src/svg-icons/hardware/smartphone.js
owencm/material-ui
import React from 'react'; import pure from 'recompose/pure'; import SvgIcon from '../../SvgIcon'; let HardwareSmartphone = (props) => ( <SvgIcon {...props}> <path d="M17 1.01L7 1c-1.1 0-2 .9-2 2v18c0 1.1.9 2 2 2h10c1.1 0 2-.9 2-2V3c0-1.1-.9-1.99-2-1.99zM17 19H7V5h10v14z"/> </SvgIcon> ); HardwareSmartphone = pure(HardwareSmartphone); HardwareSmartphone.displayName = 'HardwareSmartphone'; HardwareSmartphone.muiName = 'SvgIcon'; export default HardwareSmartphone;
src/router.js
102010cncger/antd-admin
import React from 'react' import PropTypes from 'prop-types' import { Switch, Route, Redirect, routerRedux } from 'dva/router' import dynamic from 'dva/dynamic' import App from 'routes/app' const { ConnectedRouter } = routerRedux const Routers = function ({ history, app }) { const error = dynamic({ app, component: () => import('./routes/error'), }) const routes = [ { path: '/dashboard', models: () => [import('./models/dashboard')], component: () => import('./routes/dashboard/'), }, { path: '/user', models: () => [import('./models/user')], component: () => import('./routes/user/'), }, { path: '/user/:id', models: () => [import('./models/user/detail')], component: () => import('./routes/user/detail/'), }, { path: '/login', models: () => [import('./models/login')], component: () => import('./routes/login/'), }, { path: '/request', component: () => import('./routes/request/'), }, { path: '/UIElement/iconfont', component: () => import('./routes/UIElement/iconfont/'), }, { path: '/UIElement/search', component: () => import('./routes/UIElement/search/'), }, { path: '/UIElement/dropOption', component: () => import('./routes/UIElement/dropOption/'), }, { path: '/UIElement/layer', component: () => import('./routes/UIElement/layer/'), }, { path: '/UIElement/dataTable', component: () => import('./routes/UIElement/dataTable/'), }, { path: '/UIElement/editor', component: () => import('./routes/UIElement/editor/'), }, { path: '/chart/lineChart', component: () => import('./routes/chart/lineChart/'), }, { path: '/chart/barChart', component: () => import('./routes/chart/barChart/'), }, { path: '/chart/areaChart', component: () => import('./routes/chart/areaChart/'), }, { path: '/post', models: () => [import('./models/post')], component: () => import('./routes/post/'), }, ] return ( <ConnectedRouter history={history}> <App> <Switch> <Route exact path="/" render={() => (<Redirect to="/dashboard" />)} /> { routes.map(({ path, ...dynamics }, key) => ( <Route key={key} exact path={path} component={dynamic({ app, ...dynamics, })} /> )) } <Route component={error} /> </Switch> </App> </ConnectedRouter> ) } Routers.propTypes = { history: PropTypes.object, app: PropTypes.object, } export default Routers
linksa/pana.js
liuhui219/linksa
import React from 'react'; import { View, StyleSheet, Navigator, TouchableOpacity, TouchableHighlight, Text, ScrollView, ActivityIndicator, InteractionManager, Dimensions, ToastAndroid, TextInput, BackAndroid, Image, RefreshControl, ListView, } from 'react-native'; import ScrollableTabView, { DefaultTabBar, } from 'react-native-scrollable-tab-view'; import Token from './Token'; import Panainfo from './panainfo'; import Icon from 'react-native-vector-icons/Ionicons'; var array = []; var aa=[]; export default class qus extends React.Component { constructor(props) { super(props); this._pressButton = this._pressButton.bind(this); BackAndroid.addEventListener('hardwareBackPress', this._pressButton); this.state = { add:false, status:false, textaera:'', }; } _pressButton() { const { navigator } = this.props; if(navigator) { //很熟悉吧,入栈出栈~ 把当前的页面pop掉,这里就返回到了上一个页面了 navigator.pop(); return true; } return false; } componentDidMount() { } componentWillUnmount() { BackAndroid.removeEventListener('hardwareBackPress', this._pressButton); } _add(){ this.setState({add:!this.state.add,}) } _adds(){ this.setState({add:false,}) } _Tj(){ this.setState({add:false,}); } /* 新增文件夹 start */ new_folder(){ this.setState({status:true,add:false,}); } _cancer(){ this.setState({ status:false, }) } _yes(){ this.addFech('' + data.data.domain + '/index.php?app=Wangpan&m=MobileApi&a=create_folder&name='+this.state.textaera+'&uid='+data.data.uid+'&folder_str=0&access_token=' + data.data.token + '') this.setState({ status:false, }) } addFech(url){ var that = this; fetch(url, { method: 'GET', headers: { 'Content-Type': 'application/x-www-form-urlencoded', } }) .then(function (response) { return response.json(); }) .then(function (result) { ToastAndroid.show('创建成功', ToastAndroid.LONG) }) .catch((error) => { ToastAndroid.show('创建失败', ToastAndroid.LONG) }); } /* 新增文件夹 end */ render() { return ( <View style={{flex:1,flexDirection:'column',}}> <View style={styles.card}> <View style={{flex:1,justifyContent:'center'}}> <TouchableOpacity onPress={this._pressButton.bind(this)}> <View style={{justifyContent:'flex-start',flexDirection:'row',alignItems:'center',}}> <Image source={require('./imgs/back.png')} style={{width: 25, height: 25,marginLeft:5,}} /> <Text style={{color:'white',fontSize:16,marginLeft:-5,}} allowFontScaling={false} adjustsFontSizeToFit={false}>返回</Text> </View> </TouchableOpacity> </View> <View style={{flex:1,alignItems:'center',justifyContent:'center'}}> <View style={{justifyContent:'center',flexDirection:'row',alignItems:'center'}}> <Text style={{color:'white',fontSize:18}} allowFontScaling={false} adjustsFontSizeToFit={false}>个人网盘</Text> </View> </View> <View style={{flex:1,justifyContent:'flex-end',alignItems:'center', flexDirection:'row'}}> <TouchableOpacity > <View style={{paddingRight:20,paddingTop:3}}> <Image source={require('./imgs/update.png')} style={{width: 25, height: 25,}} /> </View> </TouchableOpacity> <TouchableOpacity onPress={this._add.bind(this)} > <View style={{paddingRight:15,}}> <Icon name="ios-more" color="#fff"size={32} /> </View> </TouchableOpacity> </View> </View> <View style={{flex:1,backgroundColor:'#ececec',}}> <Panainfo navigator = {this.props.navigator} {...this.props}/> </View> {this.state.add ? <TouchableOpacity onPress={this._adds.bind(this)} style={{width:Dimensions.get('window').width,height:Dimensions.get('window').height-45,position:'absolute',top:45,left:0,}}><View style={{width:Dimensions.get('window').width,height:Dimensions.get('window').height-45,backgroundColor:'rgba(61, 61, 62, 0)',position:'absolute',top:0,left:0,}}></View></TouchableOpacity> : <View></View>} {this.state.add ? <View style={{position:'absolute',top:40,right:5,flexDirection:'column',width:120,height:100,}}> <View style={{width:120,height:90,backgroundColor:'#fff',borderRadius:5,flexDirection:'column',alignItems:'center',marginTop:10,}}> <TouchableOpacity onPress={this._Tj.bind(this)}> <View style={{borderBottomWidth:1,borderColor:'#ccc',width:120,alignItems:'center',height:45,flexDirection:'row',paddingLeft:10,}}> <Text allowFontScaling={false} adjustsFontSizeToFit={false} style={{marginLeft:10,fontSize:16,}}>多选</Text> </View> </TouchableOpacity> <TouchableOpacity onPress={this.new_folder.bind(this)}> <View style={{width:120,alignItems:'center',height:45,flexDirection:'row',paddingLeft:10,}}> <Text allowFontScaling={false} adjustsFontSizeToFit={false} style={{marginLeft:10,fontSize:16,}}>新建文件夹</Text> </View> </TouchableOpacity> </View> <View style={{position:'absolute',top:-8,right:13}}><Icon name="md-arrow-dropup" color="#fff"size={30} /></View> </View> : <View></View>} {this.state.status ? <View style={{backgroundColor:'rgba(119, 119, 119, 0.51)',position:'absolute',width:(Dimensions.get('window').width),height:(Dimensions.get('window').height),top:0,left:0}}><View style={{position:'absolute',backgroundColor:'#fff',width:260,height:150,top:(Dimensions.get('window').height-230)/2,left:(Dimensions.get('window').width-260)/2,borderRadius:5,overflow:'hidden'}}> <View style={{height:40,alignItems:'center',justifyContent:'center',flexDirection:'row', }}> <Text allowFontScaling={false} adjustsFontSizeToFit={false} style={{fontSize:18,color:'#000'}}>文件夹名称</Text> </View> <View style={{flex:1,justifyContent:'center',alignItems:'center',borderBottomWidth:1,borderColor:'#ececec',}}> <TextInput onChangeText={(textaera) => this.setState({textaera})} numberOfLines={1} multiline = {true} placeholderTextColor={'#999'} style={{ color:'#666',fontSize:14,width:230,borderWidth:1,borderColor:'#ccc',height:35,textAlignVertical:'center',padding: 0,paddingLeft:5,borderRadius:3}} placeholder='文件夹名称' underlineColorAndroid={'transparent'} /> </View> <View style={{flexDirection:'row',justifyContent:'space-between',height:50,backgroundColor:'#ececec',borderBottomLeftRadius:5,borderBottomRightRadius:5}}> <TouchableOpacity onPress={this._cancer.bind(this)} style={{flex:1,alignItems:'center',justifyContent:'center',borderBottomLeftRadius:5,backgroundColor:'#fff'}}> <View ><Text allowFontScaling={false} adjustsFontSizeToFit={false}style={{color:'#4385f4',fontSize:16}}>取消</Text></View> </TouchableOpacity> <TouchableOpacity onPress={this._yes.bind(this)} style={{flex:1, alignItems:'center',justifyContent:'center', borderBottomRightRadius:5,marginLeft:1,backgroundColor:'#fff'}}> <View><Text allowFontScaling={false} adjustsFontSizeToFit={false} style={{color:'#4385f4',fontSize:16}}>确定</Text></View> </TouchableOpacity> </View> </View></View> : null} </View> ) } } const styles = StyleSheet.create({ tabView: { flex: 1, flexDirection: 'column', backgroundColor:'#fafafa', }, card: { height:45, backgroundColor:'#4385f4', flexDirection:'row' }, loading: { backgroundColor: 'gray', height: 80, width: 100, borderRadius: 10, justifyContent: 'center', alignItems: 'center', }, loadingTitle: { marginTop: 10, fontSize: 14, color: 'white' }, footer: { flexDirection: 'row', justifyContent: 'center', alignItems: 'center', height: 40, }, footerTitle: { marginLeft: 10, fontSize: 15, color: 'gray' }, default: { height: 37, borderWidth: 0, borderColor: 'rgba(0,0,0,0.55)', flex: 1, fontSize: 13, }, });
src/svg-icons/image/wb-cloudy.js
mit-cml/iot-website-source
import React from 'react'; import pure from 'recompose/pure'; import SvgIcon from '../../SvgIcon'; let ImageWbCloudy = (props) => ( <SvgIcon {...props}> <path d="M19.36 10.04C18.67 6.59 15.64 4 12 4 9.11 4 6.6 5.64 5.35 8.04 2.34 8.36 0 10.91 0 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5 0-2.64-2.05-4.78-4.64-4.96z"/> </SvgIcon> ); ImageWbCloudy = pure(ImageWbCloudy); ImageWbCloudy.displayName = 'ImageWbCloudy'; ImageWbCloudy.muiName = 'SvgIcon'; export default ImageWbCloudy;
lib/components/TxAnalyzer/index.js
0mkara/etheratom
'use babel' // Copyright 2018 Etheratom Authors // This file is part of Etheratom. // Etheratom is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // Etheratom is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with Etheratom. If not, see <http://www.gnu.org/licenses/>. import React from 'react'; import { connect } from 'react-redux'; import { Collapse } from 'react-collapse'; import ReactJson from 'react-json-view'; import VirtualList from 'react-tiny-virtual-list'; import PropTypes from 'prop-types'; class TxAnalyzer extends React.Component { constructor(props) { super(props); this.helpers = props.helpers; this.state = { txHash: undefined, txAnalysis: props.txAnalysis, toggleBtnStyle: 'btn icon icon-unfold inline-block-tight', isOpened: false, }; this._handleTxHashChange = this._handleTxHashChange.bind(this); this._handleTxHashSubmit = this._handleTxHashSubmit.bind(this); this._toggleCollapse = this._toggleCollapse.bind(this); } componentDidMount() { const { pendingTransactions } = this.props; if (pendingTransactions.length < 10) { this.setState({ isOpened: true, toggleBtnStyle: 'btn btn-success icon icon-fold inline-block-tight' }); } } componentDidUpdate(prevProps) { if (prevProps.txAnalysis !== this.props.txAnalysis) { this.setState({ txAnalysis: this.props.txAnalysis }); } } _toggleCollapse() { const { isOpened } = this.state; this.setState({ isOpened: !isOpened }); if (!isOpened) { this.setState({ toggleBtnStyle: 'btn btn-success icon icon-fold inline-block-tight' }); } else { this.setState({ toggleBtnStyle: 'btn icon icon-unfold inline-block-tight' }); } } _handleTxHashChange(event) { this.setState({ txHash: event.target.value }); } async _handleTxHashSubmit() { const { txHash } = this.state; if (txHash) { try { const txAnalysis = await this.helpers.getTxAnalysis(txHash); this.setState({ txAnalysis }); } catch (e) { console.log(e); } } } render() { const { toggleBtnStyle, isOpened } = this.state; const { pendingTransactions, txAnalysis } = this.props; const transactions = pendingTransactions.slice(); transactions.reverse(); return ( <div className="tx-analyzer"> <div className="flex-row"> <form className="flex-row" onSubmit={this._handleTxHashSubmit}> <div className="inline-block"> <input type="text" name="txhash" value={this.state.txHash} onChange={this._handleTxHashChange} placeholder="Transaction hash" className="input-search" /> </div> <div className="inline-block"> <input type="submit" value="Analyze" className="btn" /> </div> </form> <button className={toggleBtnStyle} onClick={this._toggleCollapse}> Transaction List </button> </div> <Collapse isOpened={isOpened}> { transactions.length > 0 && <VirtualList itemCount={transactions.length} itemSize={30} class="tx-list-container" overscanCount={10} renderItem={({ index }) => <div className="tx-list-item"> <span className="padded text-warning"> {transactions[index]} </span> </div> } /> } </Collapse> { (txAnalysis && txAnalysis.transaction) && <div className="block"> <h2 className="block highlight-info tx-header">Transaction</h2> <ReactJson src={txAnalysis.transaction} theme="chalk" displayDataTypes={false} name={false} collapseStringsAfterLength={64} iconStyle="triangle" /> </div> } { (txAnalysis && txAnalysis.transactionRecipt) && <div className="block"> <h2 className="block highlight-info tx-header">Transaction receipt</h2> <ReactJson src={txAnalysis.transactionRecipt} theme="chalk" displayDataTypes={false} name={false} collapseStringsAfterLength={64} iconStyle="triangle" /> </div> } </div> ); } } TxAnalyzer.propTypes = { helpers: PropTypes.any.isRequired, pendingTransactions: PropTypes.array, txAnalysis: PropTypes.any }; const mapStateToProps = ({ eventReducer }) => { const { pendingTransactions, txAnalysis } = eventReducer; return { pendingTransactions, txAnalysis }; }; export default connect(mapStateToProps, {})(TxAnalyzer);
pathfinder/vtables/applicationlifecycleprojects/src/index.js
leanix/leanix-custom-reports
// 3rd party css files import '../node_modules/bootstrap/dist/css/bootstrap.min.css'; import '../node_modules/bootstrap/dist/css/bootstrap-theme.min.css'; import '../node_modules/react-bootstrap-table/dist/react-bootstrap-table.min.css'; // Import css declarations for the report import './assets/main.css'; import '@leanix/reporting'; import React from 'react'; import ReactDOM from 'react-dom'; import Report from './Report'; ReactDOM.render(<Report />, document.getElementById('report'));
app/components/functionView.js
PPPatt/Lincroft
'use strict' import React from 'react' import {TouchableOpacity, View, Text} from 'react-native' const styles = require('../reusables/styles') module.exports = (args) => { return( <TouchableOpacity key={'fu'+args.funcID.toString()} style={styles.funcView}> <View style={styles.Row}> <View style={styles.pic}/> <View style={styles.innerContainer}> <Text>{args.fu.title?args.fu.title:'‘no title‘'}</Text> <Text>Type: {args.fu.type}</Text> {renderFuSpecs(args.fu)} </View> </View> </TouchableOpacity> ) } const renderFuSpecs = (fu) => { switch (fu.type) { case 'deadline': return( <Text>Deadline: {fu.config.deadline}</Text> ) case 'survey': return( <Text>{fu.config.surveyspecs.join(', ')}</Text> ) default: } }
app/components/Items/Items.js
zhrkian/SolarDataApp
// @flow import React, { Component } from 'react'; import s from './Items.css' import { Grid, GridItem } from '../Layouts/Grid' import OpenFITS from '../../components/OpenFITS/OpenFITS' import ListItem from '../ListItem/ListItem' // .container img { // /* Just in case there are inline attributes */ // width: 100% ; // height: auto ; //} class Items extends Component { render() { const { onOpenFiles, items, frames } = this.props return ( <div className={s.container}> <h2>Solar Data Application</h2> <div className={s.main}> <OpenFITS onOpenFiles={onOpenFiles} onClearAll={() => {}} /> </div> <div className={s.footer}> <Grid> { items.map(item => <ListItem key={item.id} item={item} frame={frames[item.id]} />) } </Grid> </div> </div> ); } } export default Items
node_modules/bs-recipes/recipes/webpack.react-transform-hmr/app/js/main.js
JuanLuisClaure/vistas
import React from 'react'; // It's important to not define HelloWorld component right in this file // because in that case it will do full page reload on change import HelloWorld from './HelloWorld.jsx'; React.render(<HelloWorld />, document.getElementById('react-root'));
website/src/components/blog/Blog/index.js
jwngr/sdow
import React from 'react'; import {Helmet} from 'react-helmet'; import Logo from '../../common/Logo'; import StyledLink from '../../common/StyledLink'; import NewsletterSignupForm from '../NewsletterSignupForm'; import { Title, Wrapper, Divider, BlogPostCardWrapper, BlogPostDate, BlogPostDescription, } from './index.styles'; import posts from '../posts/index.json'; const BlogPostCard = ({id, date, title, description}) => ( <BlogPostCardWrapper> <StyledLink href={`/blog/${id}`}>{title}</StyledLink> <BlogPostDate>{date}</BlogPostDate> <BlogPostDescription>{description}</BlogPostDescription> </BlogPostCardWrapper> ); const Blog = () => ( <React.Fragment> <Helmet> <title>Blog | Six Degrees of Wikipedia</title> </Helmet> <Logo /> <Wrapper> <Title>A blog about building, maintaining, and promoting Six Degrees of Wikipedia</Title> <Divider /> {posts.map((postInfo) => ( <React.Fragment key={postInfo.id}> <BlogPostCard {...postInfo} /> <Divider /> </React.Fragment> ))} <NewsletterSignupForm /> </Wrapper> </React.Fragment> ); export default Blog;
client/src/components/Tag/CompactTagList.js
silverstripe/silverstripe-admin
import React, { Component } from 'react'; import TagList from 'components/Tag/TagList'; import SummaryTag from './SummaryTag'; import ResizeAware from 'components/ResizeAware/ResizeAware'; import classnames from 'classnames'; import ReactDOM from 'react-dom'; import PropTypes from 'prop-types'; /** * Extension of TagList that is aware of its size and switch to a summary view if greater than a * specific width. */ class CompactTagList extends Component { constructor(props) { super(props); this.render = this.render.bind(this); this.onResize = this.onResize.bind(this); this.refreshShowSummaryView = this.refreshShowSummaryView.bind(this); this.getPlaceholderSize = this.getPlaceholderSize.bind(this); this.state = { showSummaryView: false }; } componentDidUpdate() { const placeholderWidth = this.getPlaceholderSize(); this.refreshShowSummaryView(placeholderWidth); } /** * Detect resizing of the TagList placeholder and compare it to the max width our component can * occupy. If it's bigger, the summary view is triggered. * @param tagListDimension */ onResize(tagListDimension) { this.refreshShowSummaryView(tagListDimension.width); } /** * Measure the width of the root node. This will tell us what the maximum size our tag list can * be. * @returns {number} */ getPlaceholderSize() { const node = ReactDOM.findDOMNode(this); if (!node) { return 0; } const placeholder = node.querySelector('.compact-tag-list__placeholder'); if (placeholder) { return placeholder.getBoundingClientRect().width; } return 0; } /** * Compare placeholderWidth to the max width and decide if we should the showSummaryView state. * @param placeholderWidth */ refreshShowSummaryView(placeholderWidth) { const maxWidth = this.props.maxSize; const showSummaryView = maxWidth < placeholderWidth; if (this.state.showSummaryView !== showSummaryView) { this.setState(() => ({ showSummaryView })); } } render() { const { maxSize, onSummary, ...listProps } = this.props; const showSummaryView = this.state.showSummaryView; const count = this.props.tags.length; const classes = classnames( 'compact-tag-list', { 'compact-tag-list__show-summary-view': showSummaryView } ); return ( <div className={classes}> <ResizeAware onResize={this.onResize} className="compact-tag-list__placeholder" aria-hidden> <TagList {...listProps} focusable={false} /> </ResizeAware> <div className="compact-tag-list__visible"> { showSummaryView ? <SummaryTag count={count} onClick={onSummary} onNext={listProps.onHolderFocus} /> : <TagList {...listProps} /> } </div> </div> ); } } CompactTagList.propTypes = Object.assign({}, TagList.propTypes, { maxSize: PropTypes.number, onSummary: PropTypes.func }); CompactTagList.defaultProps = { maxSize: 0, onSummary: () => {} }; export default CompactTagList;
src/routes/dashboard/components/weather.js
zhangjingge/sse-antd-admin
import React from 'react' import PropTypes from 'prop-types' import styles from './weather.less' function Weather ({ city, icon, dateTime, temperature, name }) { return (<div className={styles.weather}> <div className={styles.left}> <div className={styles.icon} style={{ backgroundImage: `url(${icon})`, }} /> <p>{name}</p> </div> <div className={styles.right}> <h1 className={styles.temperature}>{`${temperature}°`}</h1> <p className={styles.description}>{city},{dateTime}</p> </div> </div>) } Weather.propTypes = { city: PropTypes.string, icon: PropTypes.string, dateTime: PropTypes.string, temperature: PropTypes.string, name: PropTypes.string, } export default Weather
src/Main/News/Articles/2017-10-21-DiscordBot/index.js
hasseboulen/WoWAnalyzer
import React from 'react'; import DiscordLogo from 'Main/Images/Discord-Logo+Wordmark-White.svg'; import RegularArticle from 'Main/News/RegularArticle'; import DiscordBotGif from './discord-bot.gif'; export default ( <RegularArticle title="The WoWAnalyzer Discord bot" published="2017-12-24" bodyStyle={{ padding: 0, overflow: 'hidden', borderBottomLeftRadius: 5, borderBottomRightRadius: 5 }}> <div className="flex wrapable"> <div className="flex-main" style={{ padding: '20px 15px', minWidth: 300 }}> <div className="flex"> <div className="flex-sub" style={{ padding: 5 }}> <img src="/favicon.png" alt="Logo" style={{ width: 80, float: 'left' }} /> </div> <div className="flex-main" style={{ fontSize: 24, padding: '5px 15px', lineHeight: 1.4 }}> Introducing the <b>WoWAnalyzer</b> <img src={DiscordLogo} alt="Discord logo" style={{ height: '2em', marginTop: 3 }} /> bot </div> </div> <div className="text-center"> <div style={{ fontSize: 16, margin: '10px 25px 20px 25px' }}> Get users to analyze themselves without lifting a finger (even if they don't read the pins).<br /> </div> <div style={{ marginBottom: 7 }}> <a className="btn btn-default btn-lg" style={{ borderRadius: 0 }} href="https://discordapp.com/oauth2/authorize?&client_id=368144406181838861&scope=bot&permissions=3072" > Add to Discord </a> </div> <a href="https://github.com/WoWAnalyzer/DiscordBot#wowanalyzer-discord-bot-">More info</a> </div> </div> <div className="flex-sub"> <img src={DiscordBotGif} alt="Bot example gif" style={{ height: 300 }} /> </div> </div> </RegularArticle> );
src/components/molecules/FileCard/index.js
SIB-Colombia/biodiversity_catalogue_v2_frontend
import React from 'react'; import styled from 'styled-components'; import {Link, TitleSection, FileStatus} from 'components'; import {size, palette, font} from 'styled-theme'; import { Card, CardActions, CardHeader, CardMedia, CardTitle, CardText } from 'material-ui/Card'; import FlatButton from 'material-ui/FlatButton'; import Badge from 'material-ui/Badge'; import Comment from 'material-ui/svg-icons/communication/comment'; import Divider from 'material-ui/Divider'; const Wrapper = styled.div ` .card{ transition: .5s ease; -webkit-transition: .5s ease; &:hover{ box-shadow: rgba(0, 0, 0, 0.16) 0px 3px 8px, rgba(0, 0, 0, 0.23) 0px 3px 8px !important; -webkit-transform: scale(0.9); -ms-transform: scale(0.9); transform: scale(0.9); } } .card-title{ padding: 0px 10px 10px 10px !important; span{ display: inline-block; line-height: 36px; overflow: hidden; text-overflow: ellipsis; max-width: 88%; white-space: nowrap; } } .card-title > span:first-child{ font-size: ${font('xxs')} !important; font-weight: lighter; font-style: italic; color: ${palette('basescale', 2)} !important; } .card-title > span:last-child{ font-size: 10px !important; } .card-actions{ padding: 0px !important; .card-footer{ margin: 0 !important; font-size: 13px !important; background: ${palette('basescale', 10)} !important;; padding: 0 12px !important; height: 30px !important; line-height: 30px !important; color:white !important; border-radius: 0px !important; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; } } ` class FileCard extends React.Component { constructor(props) { super(props); } title(text){ return text.split(' ').slice(0,2).join(' '); } subtitle(text){ return text.split(' ').slice(2).join(' '); } render() { return ( <Wrapper> <Link to={`/file/summary/${this.props.record._id}`}> <Card className="space-card card"> <CardMedia> <img src={`https://s3.amazonaws.com/sib-resources/images/catalogo/miniatura/png/t-anfibios.png`}/> </CardMedia> <FileStatus title="EN"/> <CardTitle title={this.title(this.props.record.scientificNameSimple)} className="card-title" subtitle={this.subtitle(this.props.record.scientificNameSimple)}/> <CardActions className="card-actions align-center"> <div className="align-left padding card-footer"> {this.props.record.creation_date} </div> {/* <FlatButton fullWidth={true} className="align-left padding footer-card"> {this.props.record.creation_date} </FlatButton> */} </CardActions> </Card> </Link> </Wrapper> ) } } export default FileCard;
docs/src/app/components/pages/components/Slider/Page.js
ngbrown/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 sliderReadmeText from './README'; import SliderExampleSimple from './ExampleSimple'; import sliderExampleSimpleCode from '!raw!./ExampleSimple'; import SliderExampleDisabled from './ExampleDisabled'; import sliderExampleDisabledCode from '!raw!./ExampleDisabled'; import SliderExampleStep from './ExampleStep'; import sliderExampleStepCode from '!raw!./ExampleStep'; import SliderExampleControlled from './ExampleControlled'; import sliderExampleControlledCode from '!raw!./ExampleControlled'; import sliderCode from '!raw!material-ui/Slider/Slider'; const descriptions = { simple: 'The `defaultValue` property sets the initial position of the slider. The slider appearance changes when ' + 'not at the starting position.', stepped: 'By default, the slider is continuous. The `step` property causes the slider to move in discrete ' + 'increments.', value: 'The slider bar can have a set minimum and maximum, and the value can be ' + 'obtained through the value parameter fired on an onChange event.', }; const SliderPage = () => ( <div> <Title render={(previousTitle) => `Slider - ${previousTitle}`} /> <MarkdownElement text={sliderReadmeText} /> <CodeExample title="Simple examples" description={descriptions.simple} code={sliderExampleSimpleCode} > <SliderExampleSimple /> </CodeExample> <CodeExample title="Disabled examples" code={sliderExampleDisabledCode} > <SliderExampleDisabled /> </CodeExample> <CodeExample title="Stepped example" description={descriptions.stepped} code={sliderExampleStepCode} > <SliderExampleStep /> </CodeExample> <CodeExample title="Controlled Examples" description={descriptions.value} code={sliderExampleControlledCode} > <SliderExampleControlled /> </CodeExample> <PropTypeDescription code={sliderCode} /> </div> ); export default SliderPage;
packages/material-ui-icons/src/FilterBAndW.js
AndriusBil/material-ui
import React from 'react'; import pure from 'recompose/pure'; import SvgIcon from 'material-ui/SvgIcon'; let FilterBAndW = props => <SvgIcon {...props}> <path d="M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16l-7-8v8H5l7-8V5h7v14z" /> </SvgIcon>; FilterBAndW = pure(FilterBAndW); FilterBAndW.muiName = 'SvgIcon'; export default FilterBAndW;
app/javascript/mastodon/features/list_editor/components/edit_list_form.js
yukimochi/mastodon
import React from 'react'; import { connect } from 'react-redux'; import PropTypes from 'prop-types'; import { changeListEditorTitle, submitListEditor } from '../../../actions/lists'; import IconButton from '../../../components/icon_button'; import { defineMessages, injectIntl } from 'react-intl'; const messages = defineMessages({ title: { id: 'lists.edit.submit', defaultMessage: 'Change title' }, }); const mapStateToProps = state => ({ value: state.getIn(['listEditor', 'title']), disabled: !state.getIn(['listEditor', 'isChanged']) || !state.getIn(['listEditor', 'title']), }); const mapDispatchToProps = dispatch => ({ onChange: value => dispatch(changeListEditorTitle(value)), onSubmit: () => dispatch(submitListEditor(false)), }); export default @connect(mapStateToProps, mapDispatchToProps) @injectIntl class ListForm extends React.PureComponent { static propTypes = { value: PropTypes.string.isRequired, disabled: PropTypes.bool, intl: PropTypes.object.isRequired, onChange: PropTypes.func.isRequired, onSubmit: PropTypes.func.isRequired, }; handleChange = e => { this.props.onChange(e.target.value); } handleSubmit = e => { e.preventDefault(); this.props.onSubmit(); } handleClick = () => { this.props.onSubmit(); } render () { const { value, disabled, intl } = this.props; const title = intl.formatMessage(messages.title); return ( <form className='column-inline-form' onSubmit={this.handleSubmit}> <input className='setting-text' value={value} onChange={this.handleChange} /> <IconButton disabled={disabled} icon='check' title={title} onClick={this.handleClick} /> </form> ); } }
src/React/Widgets/AnnotationEditorWidget/BackgroundScore.js
Kitware/paraviewweb
import React from 'react'; import PropTypes from 'prop-types'; import style from 'PVWStyle/ReactWidgets/AnnotationEditorWidget.mcss'; export default function render(props) { return ( <div className={style.backgroundScore} style={{ background: props.color, top: `${props.index * props.step + props.margin}px`, height: props.fullHeight ? `calc(100% - ${2 * props.margin}px)` : `${props.step - 2 * props.margin}px`, }} /> ); } render.propTypes = { color: PropTypes.string, index: PropTypes.number, step: PropTypes.number, margin: PropTypes.number, fullHeight: PropTypes.bool, }; render.defaultProps = { index: 0, step: 28, margin: 1, fullHeight: false, color: undefined, };
index.android.js
dylanbathurst/bacon-mobile
import './shim'; import React, { Component } from 'react'; import { AppRegistry } from 'react-native'; import { Provider } from 'react-redux'; import { createStore, compose, applyMiddleware } from 'redux'; import { persistStore, autoRehydrate } from 'redux-persist'; import createSensitiveStorage from 'redux-persist-sensitive-storage'; import reducer, { initialState } from './src/Reducer.js'; import AppWithNavigationState from './src/Navigation'; import { logger } from 'redux-logger'; const store = createStore( reducer, initialState, compose(autoRehydrate()), applyMiddleware(logger) ); persistStore(store, { storage: createSensitiveStorage() }); // uncomment out the line below and comment out the line // above to purge the local storage in order to reset the app data like accounts // persistStore(store, {storage: createSensitiveStorage()}).purge(); export default class WalletAppWithNav extends Component { render () { return ( <Provider store={store}> <AppWithNavigationState /> </Provider> ) } } AppRegistry.registerComponent('baconer3', () => WalletAppWithNav);
project/src/pages/Page/components/Navigation/Navigation.js
boldr/boldr
/* eslint-disable no-return-assign, react/no-unused-state, no-implicit-coercion */ // @flow import React from 'react'; import type { Node } from 'react'; import Link from 'react-router-dom/Link'; import NavLink from 'react-router-dom/NavLink'; import { Cog, Container, Navbar, NavbarBrand, NavbarBurger, NavbarEnd, NavbarDropdown, NavbarLink, NavbarItem, NavbarMenu, AddressCard, SignOut, NavbarStart, } from '@boldr/ui'; import type { CurrentUser, SettingsType, RouterLocation, MenuType } from '../../../../types/boldr'; export type Props = { location: RouterLocation, menu: MenuType, settings?: SettingsType, currentUser: CurrentUser, onLogout: Function, token?: string, }; type State = { isActive: boolean, isDropdownOpen: boolean, }; class Navigation extends React.Component<Props, State> { constructor() { super(); this.state = { isActive: false, isDropdownOpen: false }; this.handleClickNav = this.handleClickNav.bind(this); this.onLogoutClick = this.onLogoutClick.bind(this); this.onClickDropdown = this.onClickDropdown.bind(this); } handleClickNav() { this.setState({ isActive: !this.state.isActive }); } onClickDropdown() { this.setState({ isDropdownOpen: !this.state.isDropdownOpen }); } onLogoutClick() { this.props.onLogout(); } props: Props; render(): Node { const { menu: { details }, currentUser, location, token } = this.props; const { isActive } = this.state; const dropdownItems = details.filter(detail => detail.parentId !== null); return ( <Navbar> <Container> <NavbarBrand> <NavbarItem> <Link to="/"> <img className="boldr-logo-img" alt="logo image" src="https://boldr.io/assets/boldr-logo-light.png" /> </Link> </NavbarItem> <NavbarBurger isActive={isActive} onClick={this.handleClickNav} /> </NavbarBrand> <NavbarMenu isActive={isActive} onClick={this.handleClickNav}> <NavbarStart> {details.map(detail => { if (!detail.hasDropdown && !detail.isDropdown) { return ( <NavbarItem key={detail.id} render={() => ( <NavLink className="boldr-navbar__item" activeClassName="is-active" to={detail.href}> {detail.title} </NavLink> )} /> ); } else if (detail.hasDropdown) { return ( <NavbarItem key={detail.id} hasDropdown isHoverable> <NavbarLink className="boldr-navbar__item" key={detail.id} render={() => ( <NavLink className="boldr-navbar__link" to={detail.href}> {detail.title} </NavLink> )} /> <NavbarDropdown> {dropdownItems.map(d => { return ( <NavbarItem key={d.id} title={d.safeName} render={() => ( <NavLink className="boldr-navbar__item" activeClassName="is-active" to={d.href}> {d.safeName} </NavLink> )} /> ); })} </NavbarDropdown> </NavbarItem> ); } })} </NavbarStart> <NavbarEnd> {token && parseInt(currentUser.roleId, 10) === 3 && ( <NavbarItem> <NavLink to="/admin"> <Cog size={20} fill="#afbbca" /> </NavLink> </NavbarItem> )} {!token && ( <NavbarItem> <NavLink to="/login">Login</NavLink> </NavbarItem> )} {token && ( <NavbarItem> <NavLink to={`/profiles/${currentUser.username}`}> <AddressCard size={20} fill="#afbbca" /> </NavLink> </NavbarItem> )} {token && ( <NavbarItem> <SignOut onClick={this.onLogoutClick} size={20} fill="#afbbca" /> </NavbarItem> )} {!token && ( <NavbarItem href="/signup" title="Signup"> <NavLink to="/signup">Signup</NavLink> </NavbarItem> )} </NavbarEnd> </NavbarMenu> </Container> </Navbar> ); } } export default Navigation;
src/components/common/InnerHtmlStripTags.js
VGraupera/1on1tracker
import React from 'react'; import String from 'string'; import PropTypes from 'prop-types'; /** * @description propTypes for InnerHtmlStripTags * @type {Object} */ const propTypes = { html: PropTypes.string.isRequired, }; /** * @function InnerHtmlStripTags * @param {String} html html string * @returns {XML} */ function InnerHtmlStripTags({ html }) { if (!html) { return null; } const stripedHtml = String(html) .trim() .replaceAll('&nbsp;', ' ') .stripTags() .s; return <span className="ellipsisListItem" dangerouslySetInnerHTML={{ __html: stripedHtml }} />; } InnerHtmlStripTags.propTypes = propTypes; export default InnerHtmlStripTags;
src/client/components/ReputationTag.js
busyorg/busy
import React from 'react'; import PropTypes from 'prop-types'; import { injectIntl } from 'react-intl'; import { Tag } from 'antd'; import BTooltip from './BTooltip'; import formatter from '../helpers/steemitFormatter'; function ReputationTag({ intl, reputation }) { const formattedReputation = formatter.reputationFloat(reputation); return ( <BTooltip title={intl.formatMessage( { id: 'reputation_score_value', defaultMessage: 'Reputation score: {value}' }, { value: formattedReputation.toFixed(3) }, )} > <Tag>{Math.floor(formattedReputation)}</Tag> </BTooltip> ); } ReputationTag.propTypes = { intl: PropTypes.shape().isRequired, reputation: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired, }; export default injectIntl(ReputationTag);
src/components/Modal/ModalBtn/ModalBtn.js
jmlweb/paskman
import React from 'react'; import PT from 'prop-types'; import styled from 'styled-components'; import { stripUnit } from 'polished'; import ModalBtnSVG from './ModalBtnSVG'; import spacing from '../../../styles/spacing'; import topBarHeight from '../../../styles/topBarHeight'; const StyledModalBtn = styled.button` align-items: center; background: transparent; border: 0; display: inline-flex; height: ${topBarHeight}; justify-content: center; margin: 0; margin-right: ${+stripUnit(spacing.sm) * -1}px; outline: 0; width: 12vh; `; const ModalBtn = ({ handleClick }) => ( <StyledModalBtn onClick={handleClick}> <ModalBtnSVG /> </StyledModalBtn> ); ModalBtn.propTypes = { handleClick: PT.func.isRequired, }; export default ModalBtn;
examples/huge-apps/components/Dashboard.js
malte-wessel/react-router
import React from 'react' import { Link } from 'react-router' class Dashboard extends React.Component { render() { const { courses } = this.props return ( <div> <h2>Super Scalable Apps</h2> <p> Open the network tab as you navigate. Notice that only the amount of your app that is required is actually downloaded as you navigate around. Even the route configuration objects are loaded on the fly. This way, a new route added deep in your app will not affect the initial bundle of your application. </p> <h2>Courses</h2>{' '} <ul> {courses.map(course => ( <li key={course.id}> <Link to={`/course/${course.id}`}>{course.name}</Link> </li> ))} </ul> </div> ) } } export default Dashboard
3-add-redux/src/layout/index.js
chemoish/react-universal-tutorial
import React from 'react'; import { Link } from 'react-router'; export default function Layout(props) { return ( <div> <header> <nav> <ul> <li> <Link to="/">Home</Link> </li> <li> <Link to="/about">About</Link> </li> <li> <Link to="/settings">Settings</Link> </li> </ul> </nav> </header> <main> {props.children} </main> <footer>Footer</footer> </div> ); };
examples/Demo.js
yeyus/react-vertical-timeline
import React from 'react'; import { Timeline, Bookmark, Marker } from '../src/index'; export default class Demo extends React.Component { constructor(props) { super(props); this.state = { progress: 50 }; this.increment = this.increment.bind(this); this.progressClick = this.progressClick.bind(this); } componentDidMount() { this.interval = setInterval(() => { this.increment(); }, 1000); } componentWillUnmount() { clearInterval(this.interval); } increment() { const progress = this.state.progress > 100 ? 0 : (this.state.progress + 1); this.setState({ progress }); } progressClick(progress) { this.setState({ progress }); } render() { return ( <Timeline height={300} onSelect={this.progressClick} progress={this.state.progress} > <Bookmark onSelect={this.progressClick} progress={20}> Hi there 20% </Bookmark> <Marker progress={50} /> <Bookmark onSelect={this.progressClick} progress={55}> Hi there 55% </Bookmark> <Bookmark onSelect={this.progressClick} progress={75}> Hi there 75% </Bookmark> </Timeline> ); } }
src/svg-icons/editor/border-all.js
frnk94/material-ui
import React from 'react'; import pure from 'recompose/pure'; import SvgIcon from '../../SvgIcon'; let EditorBorderAll = (props) => ( <SvgIcon {...props}> <path d="M3 3v18h18V3H3zm8 16H5v-6h6v6zm0-8H5V5h6v6zm8 8h-6v-6h6v6zm0-8h-6V5h6v6z"/> </SvgIcon> ); EditorBorderAll = pure(EditorBorderAll); EditorBorderAll.displayName = 'EditorBorderAll'; EditorBorderAll.muiName = 'SvgIcon'; export default EditorBorderAll;
docs/src/ComponentsPage.js
Lucifier129/react-bootstrap
import React from 'react'; import findIndex from 'lodash-compat/array/findIndex'; import AutoAffix from 'react-overlays/lib/AutoAffix'; import Waypoint from 'react-waypoint'; import Nav from '../../src/Nav'; import NavItem from '../../src/NavItem'; import Anchor from './Anchor'; import NavMain from './NavMain'; import PageHeader from './PageHeader'; import PageFooter from './PageFooter'; import SubNav from './SubNav'; import AlertsSection from './sections/AlertsSection'; import BadgeSection from './sections/BadgeSection'; import BreadcrumbSection from './sections/BreadcrumbSection'; import ButtonGroupSection from './sections/ButtonGroupSection'; import ButtonSection from './sections/ButtonSection'; import CarouselSection from './sections/CarouselSection'; import DropdownSection from './sections/DropdownSection'; import FormSection from './sections/FormSection'; import GlyphiconSection from './sections/GlyphiconSection'; import GridSection from './sections/GridSection'; import ImageSection from './sections/ImageSection'; import JumbotronSection from './sections/JumbotronSection'; import LabelSection from './sections/LabelSection'; import ListGroupSection from './sections/ListGroupSection'; import MenuItemSection from './sections/MenuItemSection'; import ModalSection from './sections/ModalSection'; import NavbarSection from './sections/NavbarSection'; import NavSection from './sections/NavSection'; import OverlaySection from './sections/OverlaySection'; import PageHeaderSection from './sections/PageHeaderSection'; import PagerSection from './sections/PagerSection'; import PaginationSection from './sections/PaginationSection'; import PanelSection from './sections/PanelSection'; import PopoverSection from './sections/PopoverSection'; import ProgressBarSection from './sections/ProgressBarSection'; import ResponsiveEmbedSection from './sections/ResponsiveEmbedSection'; import TableSection from './sections/TableSection'; import TabsSection from './sections/TabsSection'; import ThumbnailSection from './sections/ThumbnailSection'; import TooltipSection from './sections/TooltipSection'; import TransitionSection from './sections/TransitionSection'; import WellSection from './sections/WellSection'; // order matters /* eslint-disable indent */ const sections = { buttons: '#buttons', btnGroups: '#btn-groups', dropdowns: '#btn-dropdowns', menuitems: '#menu-items', overlays: '#overlays', modals: '#modals', tooltips: '#tooltips', popovers: '#popovers', customOverlays: '#custom-overlays', navigation: '#navigation', navs: '#navs', navbars: '#navbars', crumbs: '#breadcrumbs', tabs: '#tabs', pagination: '#pagination', pager: '#pager', layout: '#page-layout', grid: '#grid', jumbotron: '#jumbotron', pageHeader: '#page-header', listGroup: '#list-group', tables: '#tables', panels: '#panels', wells: '#wells', forms: '#forms', media: '#media-content', images: '#images', thumbnails: '#thumbnails', embed: '#responsive-embed', carousels: '#carousels', misc: '#misc', icons: '#glyphicons', labels: '#labels', badges: '#badges', alerts: '#alerts', progress: '#progress', utilities: '#utilities', transitions: '#transitions', missing: '#missing', affix: '#affix', scrollspy: '#scrollspy' }; /* eslint-enable indent */ function prevSection(href) { let keys = Object.keys(sections); let idx = findIndex(keys, k => sections[k] === href); return sections[keys[Math.max(idx - 1, 0)]]; } let ScrollSpy = ({ href, onSpy }) => ( <Waypoint onEnter={(e, dir) => dir === 'above' && onSpy(href)} onLeave={(e, dir) => { if (dir === 'above') { onSpy(href); } if (dir === 'below') { onSpy(prevSection(href)); } }} /> ); const ComponentsPage = React.createClass({ getInitialState() { return { activeNavItemHref: null }; }, getMain() { return this.refs.main; }, handleNavItemSelect(key, href) { window.location = href; this.setActiveNavItem(); }, componentDidMount() { this.setActiveNavItem(); }, setActiveNavItem(href = window.location.hash) { this.setState({ activeNavItemHref: href }); }, render() { return ( <div> <NavMain activePage="components" ref="topNav" /> <PageHeader title="Components" subTitle="" /> <div ref="main" className="container bs-docs-container"> <div className="row"> <div className="col-md-9" role="main"> <ScrollSpy href={sections.buttons} onSpy={this.setActiveNavItem}/> <ButtonSection /> <ScrollSpy href={sections.btnGroups} onSpy={this.setActiveNavItem}/> <ButtonGroupSection /> <ScrollSpy href={sections.dropdowns} onSpy={this.setActiveNavItem}/> <DropdownSection /> <ScrollSpy href={sections.menuitems} onSpy={this.setActiveNavItem}/> <MenuItemSection /> <ScrollSpy href={sections.overlays} onSpy={this.setActiveNavItem}/> <div className="bs-docs-section"> <h1 className="page-header"> <Anchor id="overlays">Overlays</Anchor> </h1> <p className="lead">React-Bootstrap offers a number of accessible overlay components built using <a href="http://react-bootstrap.github.io/react-overlays/examples/">react-overlays</a>.</p> </div> <ScrollSpy href={sections.modals} onSpy={this.setActiveNavItem}/> <ModalSection /> <ScrollSpy href={sections.tooltips} onSpy={this.setActiveNavItem}/> <TooltipSection /> <ScrollSpy href={sections.popovers} onSpy={this.setActiveNavItem}/> <PopoverSection /> <ScrollSpy href={sections.customOverlays} onSpy={this.setActiveNavItem}/> <OverlaySection /> <ScrollSpy href={sections.navigation} onSpy={this.setActiveNavItem}/> <div className="bs-docs-section"> <h1 className="page-header"> <Anchor id="navigation">Navigation</Anchor> </h1> <p className="lead">React-Bootstrap offers a variety of responsive, accessible components for setting up navigation both across your website and within your pages.</p> </div> <ScrollSpy href={sections.navs} onSpy={this.setActiveNavItem}/> <NavSection /> <ScrollSpy href={sections.navbars} onSpy={this.setActiveNavItem}/> <NavbarSection /> <ScrollSpy href={sections.crumbs} onSpy={this.setActiveNavItem}/> <BreadcrumbSection /> <ScrollSpy href={sections.tabs} onSpy={this.setActiveNavItem}/> <TabsSection /> <ScrollSpy href={sections.pagination} onSpy={this.setActiveNavItem}/> <PaginationSection /> <ScrollSpy href={sections.pager} onSpy={this.setActiveNavItem}/> <PagerSection /> <ScrollSpy href={sections.layout} onSpy={this.setActiveNavItem}/> <div className="bs-docs-section"> <h1 className="page-header"> <Anchor id="page-layout">Page layout</Anchor> </h1> <p className="lead">The components in this section offer different ways to structure and present data on your page.</p> </div> <ScrollSpy href={sections.grid} onSpy={this.setActiveNavItem}/> <GridSection /> <ScrollSpy href={sections.jumbotron} onSpy={this.setActiveNavItem}/> <JumbotronSection /> <ScrollSpy href={sections.pageHeader} onSpy={this.setActiveNavItem}/> <PageHeaderSection /> <ScrollSpy href={sections.listGroup} onSpy={this.setActiveNavItem}/> <ListGroupSection /> <ScrollSpy href={sections.tables} onSpy={this.setActiveNavItem}/> <TableSection /> <ScrollSpy href={sections.panels} onSpy={this.setActiveNavItem}/> <PanelSection /> <ScrollSpy href={sections.wells} onSpy={this.setActiveNavItem}/> <WellSection /> <ScrollSpy href={sections.forms} onSpy={this.setActiveNavItem}/> <FormSection /> <ScrollSpy href={sections.media} onSpy={this.setActiveNavItem}/> <div className="bs-docs-section"> <h1 className="page-header"> <Anchor id="media-content">Media content</Anchor> </h1> <p className="lead">The React-Bootstrap media content components offer ways to present images and other media to your users in a responsive way, along with support for styling those components.</p> </div> <ScrollSpy href={sections.images} onSpy={this.setActiveNavItem}/> <ImageSection /> <ScrollSpy href={sections.thumbnails} onSpy={this.setActiveNavItem}/> <ThumbnailSection /> <ScrollSpy href={sections.embed} onSpy={this.setActiveNavItem}/> <ResponsiveEmbedSection /> <ScrollSpy href={sections.carousels} onSpy={this.setActiveNavItem}/> <CarouselSection /> <ScrollSpy href={sections.misc} onSpy={this.setActiveNavItem}/> <div className="bs-docs-section"> <h1 className="page-header"> <Anchor id="misc">Miscellaneous components</Anchor> </h1> <p className="lead">React-Bootstrap also offers various standalone components that can be used to present specific, relevant kinds of information across your pages.</p> </div> <ScrollSpy href={sections.icons} onSpy={this.setActiveNavItem}/> <GlyphiconSection /> <ScrollSpy href={sections.labels} onSpy={this.setActiveNavItem}/> <LabelSection /> <ScrollSpy href={sections.badges} onSpy={this.setActiveNavItem}/> <BadgeSection /> <ScrollSpy href={sections.alerts} onSpy={this.setActiveNavItem}/> <AlertsSection /> <ScrollSpy href={sections.progress} onSpy={this.setActiveNavItem}/> <ProgressBarSection /> <ScrollSpy href={sections.utilities} onSpy={this.setActiveNavItem}/> <div className="bs-docs-section"> <h1 className="page-header"> <Anchor id="utilities">Utilities</Anchor> </h1> <p className="lead">React-Bootstrap also exposes certain utility components used internally. They can be used to enhance your own custom components as well.</p> </div> <ScrollSpy href={sections.transitions} onSpy={this.setActiveNavItem}/> <TransitionSection /> <ScrollSpy href={sections.missing} onSpy={this.setActiveNavItem}/> <div className="bs-docs-section"> <h1 className="page-header"> <Anchor id="missing">Missing components</Anchor> </h1> <p className="lead">We've intentionally omitted a few components from React-Bootstrap. Don't worry, though &ndash; we cover what to do in this section.</p> </div> <ScrollSpy href={sections.affix} onSpy={this.setActiveNavItem}/> <div className="bs-docs-section"> <h2 className="page-header"> <Anchor id="affix">Affix</Anchor> </h2> <p>Use <a href="http://react-bootstrap.github.io/react-overlays/examples/#affixes"><code>{'<AutoAffix>'}</code> or <code>{'<Affix>'}</code> from react-overlays</a>.</p> <p>There isn't really any additional Bootstrap markup associated with affixes, so we didn't add a Bootstrap-specific affix class. The upstream ones already give you everything you need.</p> </div> <ScrollSpy href={sections.scrollspy} onSpy={this.setActiveNavItem}/> <div className="bs-docs-section"> <h2 className="page-header"> <Anchor id="scrollspy">Scrollspy</Anchor> </h2> <p>Setting up a scrollspy in idiomatic React requires wiring up a number of components across your entire page, both to handle elements scrolling in and to wire that up to the navigation. It's a poor fit for a component library, because it's not a standalone component.</p> <p> To implement this functionality, use a library like <a href="http://brigade.github.io/react-waypoint/">React Waypoint</a> along with a bit of your own state management. You can check out how we implemented it on the side panel here by reading the <a href="https://github.com/react-bootstrap/react-bootstrap/blob/master/docs/src/ComponentsPage.js">docs source</a>. </p> </div> </div> <div className="col-md-3 bs-docs-sidebar-holder"> <AutoAffix viewportOffsetTop={20} container={this.getMain} > <div className="bs-docs-sidebar hidden-print" role="complementary" > <Nav className="bs-docs-sidenav" activeHref={this.state.activeNavItemHref} onSelect={this.handleNavItemSelect} > <SubNav href={sections.buttons} text="Buttons"> <NavItem href={sections.btnGroups}>Button groups</NavItem> <NavItem href={sections.dropdowns}>Dropdowns</NavItem> <NavItem href={sections.menuitems}>Menu items</NavItem> </SubNav> <SubNav href={sections.overlays} text="Overlays"> <NavItem href={sections.modals}>Modals</NavItem> <NavItem href={sections.tooltips}>Tooltips</NavItem> <NavItem href={sections.popovers}>Popovers</NavItem> <NavItem href={sections.customOverlays}>Custom overlays</NavItem> </SubNav> <SubNav href={sections.navigation} text="Navigation"> <NavItem href={sections.navs}>Navs</NavItem> <NavItem href={sections.navbars}>Navbars</NavItem> <NavItem href={sections.crumbs}>Breadcrumbs</NavItem> <NavItem href={sections.tabs}>Tabs</NavItem> <NavItem href={sections.pagination}>Pagination</NavItem> <NavItem href={sections.pager}>Pager</NavItem> </SubNav> <SubNav href={sections.layout} text="Page layout"> <NavItem href={sections.grid}>Grid system</NavItem> <NavItem href={sections.jumbotron}>Jumbotron</NavItem> <NavItem href={sections.pageHeader}>Page header</NavItem> <NavItem href={sections.listGroup}>List group</NavItem> <NavItem href={sections.tables}>Tables</NavItem> <NavItem href={sections.panels}>Panels</NavItem> <NavItem href={sections.wells}>Wells</NavItem> </SubNav> <NavItem href={sections.forms}>Forms</NavItem> <SubNav href={sections.media} text="Media content"> <NavItem href={sections.images}>Images</NavItem> <NavItem href={sections.thumbnails}>Thumbnails</NavItem> <NavItem href={sections.embed}>Responsive embed</NavItem> <NavItem href={sections.carousels}>Carousels</NavItem> </SubNav> <SubNav href={sections.misc} text="Miscellaneous"> <NavItem href={sections.icons}>Glyphicons</NavItem> <NavItem href={sections.labels}>Labels</NavItem> <NavItem href={sections.badges}>Badges</NavItem> <NavItem href={sections.alerts}>Alerts</NavItem> <NavItem href={sections.progress}>Progress bars</NavItem> </SubNav> <SubNav href={sections.utilities} text="Utilities"> <NavItem href={sections.transitions}>Transitions</NavItem> </SubNav> <SubNav href={sections.missing} text="Missing components"> <NavItem href={sections.affix}>Affix</NavItem> <NavItem href={sections.scrollspy}>Scrollspy</NavItem> </SubNav> </Nav> <a className="back-to-top" href="#top"> Back to top </a> </div> </AutoAffix> </div> </div> </div> <PageFooter ref="footer" /> </div> ); } }); export default ComponentsPage;
components/User/UserProfile/ChangePicture.js
slidewiki/slidewiki-platform
import PropTypes from 'prop-types'; import React from 'react'; import UserPicture from '../../common/UserPicture'; import ChangePictureModal from './ChangePictureModal'; import { FormattedMessage, defineMessages } from 'react-intl'; import changeUserData from '../../../actions/user/userprofile/changeUserData'; class ChangePicture extends React.Component { constructor(){ super(); this.filePath = ''; this.filesize = 0; } componentDidMount() { let that = this; } openFileDialog() { $(this.refs.fileDialog).click(); } openCropPictureModal(e) { const messages = defineMessages({ modalTitle: { id: 'ChangePicture.modalTitle', defaultMessage: 'Big file', }, modalText: { id: 'ChangePicture.modalText', defaultMessage: 'The selected file is quite big (> 10MB). This could cause problems like a white profile picture. You should upload a smaller picture if you notice strange things.', }, modalTitle2: { id: 'ChangePicture.modalTitle2', defaultMessage: 'Wrong file type', }, modalText2: { id: 'ChangePicture.modalText2', defaultMessage: 'You have selected a file type that we currently do not support', }, }); this.filePath = URL.createObjectURL(e.target.files[0]); let toCheck = e.target.files[0].name.toLowerCase().trim(); this.filesize = e.target.files[0].size; // console.log('filesize:', this.filesize); this.filetype = toCheck.substr(toCheck.length - 3); if(toCheck.endsWith('.jpg') || toCheck.endsWith('.jpeg') || toCheck.endsWith('.png')) { if (this.filesize > 10000000) { swal({ title: this.context.intl.formatMessage(messages.modalTitle), text: this.context.intl.formatMessage(messages.modalText), type: 'warning', confirmButtonClass: 'ui primary button', buttonsStyling: false }).then(() => { this.forceUpdate(); $('#ChangePictureModalOpenButton').click(); }); } else { this.forceUpdate(); $('#ChangePictureModalOpenButton').click(); } } else swal({ title: this.context.intl.formatMessage(messages.modalTitle2), text: this.context.intl.formatMessage(messages.modalText2), type: 'error', confirmButtonClass: 'ui primary button', buttonsStyling: false }).then(() => {}); //The actual processing of the picture is implemented in the modal } useGravatar(e) { let payload = {}; Object.assign(payload, this.props.user); payload.picture = 'gravatar'; //hack to work with action changeUserData this.context.executeAction(changeUserData, payload); } removePicture(e) { let payload = {}; Object.assign(payload, this.props.user); payload.picture = ''; this.context.executeAction(changeUserData, payload); } render() { return ( <div> <div className="ui centered grid"> <div className="eight wide column"> <UserPicture picture={ this.props.user.picture } username={ this.props.user.uname } link={ false } private={ true } width={ 150 } centered={ true } size={ 'small' }/> </div> <div className="eight wide column"> <div className="ui vertical buttons"> <input type="file" accept="image/jpg, image/jpeg, image/png" style={{display: 'none'}} onChange={ this.openCropPictureModal.bind(this) } ref="fileDialog"/> <button className="ui primary labeled icon button" onClick={ this.openFileDialog.bind(this) }> <i className="icon upload"/> <FormattedMessage id='ChangePicture.upload' defaultMessage='Upload new Image' /> </button> <div className="ui hidden divider"/> <button className="ui teal labeled icon button" onClick={ this.useGravatar.bind(this) }> <i className="icon user"/> <FormattedMessage id='ChangePicture.gravatar' defaultMessage='Use Gravatar Image' /> </button> <div className="ui hidden divider"/> <button className="ui red labeled icon button" onClick={ this.removePicture.bind(this) }> <i className="icon ban"/> <FormattedMessage id='ChangePicture.remove' defaultMessage='Remove Image' /> </button> </div> </div> </div> <ChangePictureModal ref='ChangePictureModal' filePath={this.filePath} filesize={this.filesize} filetype={this.filetype} user={this.props.user}/> </div> ); } } ChangePicture.contextTypes = { executeAction: PropTypes.func.isRequired, intl: PropTypes.object.isRequired }; export default ChangePicture;
apps/marketplace/components/Brief/Edit/AddSellerActions.js
AusDTO/dto-digitalmarketplace-frontend
import React from 'react' import PropTypes from 'prop-types' import AUlinklist from '@gov.au/link-list/lib/js/react.js' import styles from './AddSellerActions.scss' const AddSellerActions = props => { const { id, onRemoveSellerClick } = props return ( <div className={styles.selectedItemActionsContainer}> <AUlinklist className={`${styles.selectedItemActions}`} inline items={[ { link: '#remove', onClick: e => { e.preventDefault() onRemoveSellerClick(id) }, text: 'Remove' } ]} /> </div> ) } AddSellerActions.defaultProps = { id: '', onRemoveSellerClick: () => {} } AddSellerActions.propTypes = { id: PropTypes.string.isRequired, onRemoveSellerClick: PropTypes.func.isRequired } export default AddSellerActions
js/common/SelectableButton.js
BarberHour/barber-hour
import React, { Component } from 'react'; import { View, Text, StyleSheet, Image } from 'react-native'; import Touchable from './Touchable'; const SelectableButton = (props) => { let styleKey; if (props.disabled) { styleKey = 'disabled'; } else if (props.selected) { styleKey = 'selected'; } else { styleKey = 'unselected' } const containerStyle = styles[`${styleKey}Container`]; const textStyle = styles[`${styleKey}Text`]; const onPress = props.disabled && !props.onPressIfDisabled ? null : props.onPress; return( <Touchable style={[containerStyle, styles.container, props.containerStyle]} onPress={onPress}> <View style={[containerStyle, styles.container, props.containerStyle]}> <Text style={[textStyle, styles.text, props.textStyle]}>{props.title}</Text> {props.text ? ( <Text style={[textStyle, styles.text, props.textStyle]}>{props.text}</Text> ) : null} </View> </Touchable> ); }; export default SelectableButton; var styles = StyleSheet.create({ container: { borderRadius: 2, borderWidth: 1, height: 65, width: 75, margin: 5, padding: 10, alignItems: 'center', justifyContent: 'center' }, text: { textAlign: 'center', fontWeight: 'bold' }, selectedContainer: { borderColor: '#00223A', backgroundColor: '#003459', }, unselectedContainer: { borderColor: '#003459', backgroundColor: 'white', }, disabledContainer: { borderColor: '#DCDCDC', backgroundColor: 'white', }, selectedText: { color: 'white', }, unselectedText: { color: '#003459', }, disabledText: { color: '#DCDCDC' } });
test/test_helper.js
nik149/react_test
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};
16/notes/src/pages/notes/NoteList.js
nanohop/hop_into_react
import React, { Component } from 'react'; import { PageHeader, Button, ListGroup } from 'react-bootstrap'; import FontAwesome from 'react-fontawesome'; import NoteItem from './NoteItem'; class NoteList extends Component { render() { if(!this.props.loaded) { return ( <div className="loading">Loading...</div> ) } return ( <div> <PageHeader> Notes <Button className="pull-right" onClick={this.props.addNote}> <FontAwesome name='plus' /> </Button> </PageHeader> <ListGroup> { this.props.notes.map((note) => { return <NoteItem key={note.id} note={note} deleteNote={() => this.props.deleteNote(note.id)} onClick={() => this.props.editNote(note.id)} /> }) } </ListGroup> </div> ); } } export default NoteList;
src/routes/contact/index.js
AlanDeLonga/portfolio
import React from 'react'; import Layout from '../../components/Layout'; import Contact from './Contact'; const title = 'Contact Us'; export default { path: '/contact', action() { return { title, component: <Layout><Contact title={title} /></Layout>, }; }, };
src/main/app/scripts/components/Siderbar.js
ondrejhudek/hudy-app
import React from 'react' import { LeftNav } from 'material-ui' import FontAwesome from 'react-fontawesome' import Menu from '../components/Menu' class Sidebar extends React.Component { constructor(props) { super(props) this.state = { open: true } } render() { return ( <LeftNav open={this.state.open} className="sidebar"> <header> <h1> <FontAwesome name="thumb-tack" className="app-icon"/> pinboard <small>beta</small> </h1> </header> <Menu/> <footer> <p className="copyright"> &copy; 2016 Made with <FontAwesome name="heart"/> by Ondřej Hudek </p> <p className="github"> <a href="https://github.com/ondrejhudek/hudy-app"> <FontAwesome name="github" size="3x"/> </a> </p> </footer> </LeftNav> ) } } export default Sidebar
fmi-2022-05-react-todos/src/About.js
iproduct/course-node-express-react
import React from 'react' export const About = ({application}) => { return ( <h2>About the {application} application ...</h2> ) }
src/containers/Account/Account.js
baruinho/cashier
import React, { Component } from 'react'; import { connect } from 'react-redux'; import AccountBalance from '../AccountBalance/AccountBalance'; import TransactionList from '../../components/TransactionList/TransactionList'; import * as accountActions from '../../redux/modules/accounts/actions'; import { getTransactionsByAccountId } from '../../redux/modules/transactions/reducer'; class Account extends Component { render() { const { account, getTransactionsByAccountId } = this.props; return ( <div> <h2>{account.name}</h2> <p>{account.description}</p> <AccountBalance account={account} /> <h2>Transactions</h2> <TransactionList accountId={account._id} transactions={ getTransactionsByAccountId(account._id) } /> </div> ); } } Account = connect( (state) => ({ getTransactionsByAccountId: (accountId) => getTransactionsByAccountId(state, accountId) }), accountActions )(Account); export default Account;
actor-apps/app-web/src/app/components/Install.react.js
liqk2014/actor-platform
import React from 'react'; export default class Install extends React.Component { render() { return ( <section className="mobile-placeholder col-xs row center-xs middle-xs"> <div> <img alt="Actor messenger" className="logo" src="assets/img/logo.png" srcSet="assets/img/[email protected] 2x"/> <h1>Web version of <b>Actor</b> works only on desktop browsers at this time</h1> <h3>Please install our apps for using <b>Actor</b> on your phone.</h3> <p> <a href="//actor.im/ios">iPhone</a> | <a href="//actor.im/android">Android</a> </p> </div> </section> ); } }
example/examples/CustomOverlayXMarksTheSpot.js
zigbang/react-native-maps
import React from 'react'; import PropTypes from 'prop-types'; import { View } from 'react-native'; import { Polygon, Polyline, Marker } from 'react-native-maps'; class XMarksTheSpot extends React.Component { render() { return ( <View> <Polygon coordinates={this.props.coordinates} strokeColor="rgba(0, 0, 0, 1)" strokeWidth={3} /> <Polyline coordinates={[this.props.coordinates[0], this.props.coordinates[2]]} /> <Polyline coordinates={[this.props.coordinates[1], this.props.coordinates[3]]} /> <Marker coordinate={this.props.center} /> </View> ); } } XMarksTheSpot.propTypes = { coordinates: PropTypes.array, center: PropTypes.object, zIndex: PropTypes.number, }; export default XMarksTheSpot;
jenkins-design-language/src/js/components/material-ui/svg-icons/notification/vibration.js
alvarolobato/blueocean-plugin
import React from 'react'; import SvgIcon from '../../SvgIcon'; const NotificationVibration = (props) => ( <SvgIcon {...props}> <path d="M0 15h2V9H0v6zm3 2h2V7H3v10zm19-8v6h2V9h-2zm-3 8h2V7h-2v10zM16.5 3h-9C6.67 3 6 3.67 6 4.5v15c0 .83.67 1.5 1.5 1.5h9c.83 0 1.5-.67 1.5-1.5v-15c0-.83-.67-1.5-1.5-1.5zM16 19H8V5h8v14z"/> </SvgIcon> ); NotificationVibration.displayName = 'NotificationVibration'; NotificationVibration.muiName = 'SvgIcon'; export default NotificationVibration;
lib/components/current-weather/summary.js
dunncl15/weathrly
import React from 'react'; const Summary = ({ weather }) => { const today = weather[0].forecast.simpleforecast.forecastday[0]; return ( <div> <p className='summary'> {weather[0].forecast.txt_forecast.forecastday[0].fcttext} </p> </div> ); }; export default Summary;
src/components/Tickets/index.js
nadavspi/UnwiseConnect
import * as TicketsActions from '../../actions/tickets'; import * as UserActions from '../../actions/user'; import AddProject from './AddProject'; import CreateTicketForm from './CreateTicketForm'; import Projects from './Projects'; import React, { Component } from 'react'; import Table from './Table'; import ToggleProjects from './ToggleProjects'; import EditTicketForm from './EditTicketForm'; import classnames from 'classnames'; import sortBy from 'sort-by'; import { connect } from 'react-redux'; import { search } from '../../actions/tickets'; class Tickets extends Component { state = { expanded: '', isEditingTicket: false, selectedProject: {}, } componentDidUpdate = (prevProps) => { if (prevProps.tickets.query !== this.props.tickets.query) { this.setSelectedProject(); } } setSelectedProject = () => { const selectedProject = this.props.tickets.query; this.setState({ selectedProject }); } projects = () => { // We can use the first ticket from each project to get the project's metadata const projects = Object.keys(this.props.tickets.nested).map(projectId => { return this.props.tickets.nested[projectId][0]; }); return projects.sort(sortBy('company.name', 'project.name')); } addProject = (projectId) => { this.props.dispatch(TicketsActions.updateTickets({ projectId })); this.toggleProject(projectId, true); } toggleProject = (projectId, checked) => { this.props.dispatch(UserActions.toggleProject({ add: checked, projectId, })); } toggleColumn = (payload) => { this.props.dispatch(UserActions.toggleColumn(payload)); } search = (query, incremental) => { let nextQuery = query; if (incremental) { nextQuery = { ...this.props.tickets.query, ...query, }; } this.props.dispatch(search(nextQuery)); } addNewTicketToColumns = payload => { this.props.dispatch(TicketsActions.updateSingleTicket(payload)); } expand = (id) => { const isExpanded = this.state.expanded === id; let nextState = id; if (isExpanded) { nextState = ''; } this.setState({ expanded: nextState }); } render() { const { expanded } = this.state; const addClassnames = classnames('dropdown', { 'open': expanded === 'addProject', }); return ( <div> <div className="panel-uc panel panel-default"> <div className="panel-uc__heading panel-heading clearfix"> <h4>Ticket Center {this.props.tickets.loading ? ( <small> Loading tickets&hellip;</small> ) : ( <small> {this.props.tickets.flattened.length} tickets from {Object.keys(this.props.tickets.nested).length} projects</small> )} </h4> <div className="panel-uc__manage"> <span className={addClassnames}> <button className="btn btn-link dropdown-toggle add-id" type="button" onClick={this.expand.bind(this, 'addProject')} > {'Add Project by ID '} <span className="caret"></span> </button> <div className="dropdown-menu dropdown-menu-right"> <AddProject onAdd={this.addProject} /> </div> </span> <ToggleProjects /> </div> </div> <div className="row panel-body"> <div className="panel-body projects__wrapper"> <h2>Active Projects ({this.projects().length})</h2> <Projects projects={this.projects()} searchProject={({ company, project }) => this.search({ 'company.name': company, 'project.name': project, }, true)} selectedProject={this.state.selectedProject} /> </div> <CreateTicketForm addNewTicketToColumns={this.addNewTicketToColumns} projects={this.projects()} selectedProject={this.state.selectedProject} tickets={this.props.tickets.flattened} /> {this.props.tickets.flattened.length > 0 && ( <Table id="table-search-tickets" query={this.props.tickets.query} search={this.search} tickets={this.props.tickets.flattened} toggleColumn={this.toggleColumn} userColumns={this.props.userColumns} /> )} </div> </div> </div> ); } } const mapStateToProps = state => ({ tickets: state.tickets, userColumns: state.user.columns, }); export default connect(mapStateToProps)(Tickets);
packages/wix-style-react/src/ListItemAction/docs/index.story.js
wix/wix-style-react
import React from 'react'; import { header, tabs, tab, description, importExample, title, columns, divider, example as baseExample, playground, api, testkit, } from 'wix-storybook-utils/Sections'; import icons from '../../../stories/utils/icons-for-story'; import * as examples from './examples'; import { storySettings } from '../test/storySettings'; import ListItemAction from '..'; const Link = ({ children, ...rest }) => <a {...rest}>{children}</a>; const example = config => baseExample({ components: { Link }, ...config }); export default { category: storySettings.category, storyName: 'ListItemAction', component: ListItemAction, componentPath: '..', componentProps: { title: 'Hello World!', }, exampleProps: { prefixIcon: icons, }, sections: [ header({ title: 'ListItemAction', component: ( <div style={{ width: '200px' }}> <ListItemAction as="button" title="Option 1" /> <ListItemAction as="button" title="Option 2" /> </div> ), }), tabs([ tab({ title: 'Description', sections: [ columns([ description({ title: 'Description', text: 'ListItemAction is an internal component which is used to build dropdown or menu like components. Usually this item should not be used by consumers, though custom options builder is exposed for usage with DropdownBase.', }), ]), importExample(` // Use directly import { ListItemAction } from 'wix-style-react'; // Or use a builder import { listItemActionBuilder } from 'wix-style-react';, `), divider(), title('Examples'), example({ title: 'Plain Example', text: 'Using options builder to render a list of items.', source: examples.simple, }), example({ title: 'Affix', text: 'Supports prefix icons.', source: examples.prefix, }), example({ title: 'Skin', text: 'Supports three different skins: standard, dark & destructive', source: examples.skin, }), example({ title: 'Size', text: 'Supports two sizes: small and medium', source: examples.size, }), example({ title: 'States', text: 'Supports disabled state.', source: examples.state, }), example({ title: 'Text Ellipsis', text: 'Text can be set to be ellipsed on tight container width.', source: examples.wrap, }), example({ title: 'Subtitle', text: 'A subtitle text can be set.', source: examples.subtitle, }), example({ title: 'Custom HTML tag', text: ` This component can be rendered as any given HTML tag – \`<button/>\`, \`<a/>\`, \`<Link/>\` (from react router), \`<div/>\`, \`<span/>\` etc.<br/> All props/attributes will pass to the <em>rendered</em> HTML tag.<br/> <br/> For example:<br/> - as an \`<a/>\`, the component can have attributes like \`href\`, \`target\`, etc.<br/> - as a \`<Link/>\` from react router, the component can have props like \`to\`, \`replace\`, etc. `, source: examples.custom, }), ], }), ...[ { title: 'API', sections: [api()] }, { title: 'Testkit', sections: [testkit()] }, { title: 'Playground', sections: [playground()] }, ].map(tab), ]), ], };
src/demo-data/data01.js
filipdanic/react-botkit
import React from 'react'; const userTypingInterval = 3000; const botTypingInterval = 2000; const GIF = <img src="https://media.giphy.com/media/daUOBsa1OztxC/giphy.gif" alt="jake from AT" style={{ height: 150 }} /> const CTA = <span> So… <strong><a href="https://github.com/filipdanic/react-botkit" target="_blank">get started!</a></strong> </span>; export default { conversationHash: 'convo-demo-1', settings: { skin: 'messenger', simulateChat: true, }, authors: { 'human': { background: '#0084ff', color: '#fff', position: 'right', }, 'bot-1': { background: '#f1f0f0', color: '#000', position: 'left', }, 'bot-2': { background: '#f03d25', color: '#fff', position: 'left', }, }, messages: [ { type: 'message', contents: 'Hello, nice to meet you! 👋', author: 'human', delay: userTypingInterval, }, { type: 'message', contents: 'Nice to meet you too! I’m React BotKit! 🤖', author: 'bot-1', delay: botTypingInterval, }, { type: 'message', contents: GIF, author: 'human', delay: userTypingInterval, }, { type: 'message', contents: 'Awesome! My name is Mark. 👱 This looks nice!', author: 'human', delay: userTypingInterval, }, { type: 'message', contents: 'Yeah, pretty neat huh? ⭐️', author: 'bot-1', delay: botTypingInterval, }, { type: 'message', contents: 'You can adjust: delays, colors, include GIFs, React components, HTML, forms, photos etc.', author: 'bot-1', delay: botTypingInterval, }, { type: 'message', contents: 'also, add as many “people” as you need! 🍻', author: 'bot-2', delay: botTypingInterval, }, { type: 'message', contents: CTA, author: 'bot-1', delay: botTypingInterval, }, { type: 'message', contents: 'Yeah, pretty neat! Cheers! 🍻', author: 'human', delay: userTypingInterval, }, ], };
src/svg-icons/social/mood.js
kittyjumbalaya/material-components-web
import React from 'react'; import pure from 'recompose/pure'; import SvgIcon from '../../SvgIcon'; let SocialMood = (props) => ( <SvgIcon {...props}> <path d="M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8zm3.5-9c.83 0 1.5-.67 1.5-1.5S16.33 8 15.5 8 14 8.67 14 9.5s.67 1.5 1.5 1.5zm-7 0c.83 0 1.5-.67 1.5-1.5S9.33 8 8.5 8 7 8.67 7 9.5 7.67 11 8.5 11zm3.5 6.5c2.33 0 4.31-1.46 5.11-3.5H6.89c.8 2.04 2.78 3.5 5.11 3.5z"/> </SvgIcon> ); SocialMood = pure(SocialMood); SocialMood.displayName = 'SocialMood'; SocialMood.muiName = 'SvgIcon'; export default SocialMood;
src/assets/js/react/components/Template/TemplateScreenshots.js
blueliquiddesigns/gravity-forms-pdf-extended
import PropTypes from 'prop-types' import React from 'react' /** * Display the Template Screenshot for the individual templates (uses different markup - out of our control) * * @package Gravity PDF * @copyright Copyright (c) 2020, Blue Liquid Designs * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License * @since 4.1 */ /** * React Stateless Component * * @since 4.1 */ const TemplateScreenshots = ({ image }) => { const className = (image) ? 'screenshot' : 'screenshot blank' return ( <div className='theme-screenshots'> <div className={className}> {image ? <img src={image} alt='' /> : null} </div> </div> ) } TemplateScreenshots.propTypes = { image: PropTypes.string } export default TemplateScreenshots
examples/async/index.js
gaulucky92/redux
import 'babel-core/polyfill'; import React from 'react'; import Root from './containers/Root'; React.render( <Root />, document.getElementById('root') );
src/helpers/shadowDOM.js
agutoli/react-styled-select
require('../polyfill') import React from 'react' import ShadowDOM from 'react-shadow' export default (element) => { return class ShadowDOMHelper extends React.PureComponent { constructor(props) { super(props) this.state = { stylesheet: false } } applyStylesheet = (classNameID) => { let style = document.querySelector('style[data-styled]'); if (!style) { style = document.querySelector(`style[data-styled-components*=${classNameID.split(' ')[1]}]`); } if (!style) return; try { this.styleTag.innerHTML = ''; } catch(e) {} this.styleTag.appendChild(style.cloneNode(true)); } render() { const { stylesheet } = this.state return ( <ShadowDOM> <span> <span ref={(n) => this.styleTag = n} /> {React.createElement(element, {...this.props, generatedClassName: this.applyStylesheet})} </span> </ShadowDOM> ) } } }
app/components/Table/index.js
VonIobro/ab-web
/** * Created by helge on 14.02.17. */ import React from 'react'; import PropTypes from 'prop-types'; import { Board } from './Board'; import TableMenu from '../../containers/TableMenu'; import ActionBar from '../../containers/ActionBar'; import tableImage from './tableBG.svg'; import Pot from '../Pot'; import Curtain from '../../containers/Curtain'; import { TableContainer, TableAndChairs, PokerTable, HandBox, Winner, } from './styles'; const Seats = (props) => ( <div name="seats"> { props.seats } </div> ); const TableComponent = (props) => ( <div name="table-component"> <Curtain {...props} /> <TableContainer name="table-container"> <TableAndChairs id="table-and-chairs" > <PokerTable> <img src={tableImage} alt="" /> { props.potSize > 0 && <Pot className="pot" potSize={props.potSize} top="58%" left="50%" /> } { props.seats } <Board id="board" board={props.board}> { props.board } </Board> { props.winners.length > 0 && <Winner className="winner">{ props.winners }</Winner> } </PokerTable> </TableAndChairs> { props.myHand && <HandBox className="hand-box"> { props.myHand.descr }</HandBox> } <TableMenu {...props} /> <ActionBar className="action-bar" {...props} sb={props.sb}></ActionBar> </TableContainer> </div> ); Seats.propTypes = { seats: React.PropTypes.array, }; TableComponent.propTypes = { board: PropTypes.array, seats: PropTypes.array, potSize: PropTypes.number, winners: PropTypes.array, myHand: PropTypes.object, sb: PropTypes.number, }; export default TableComponent;
web/app/layout/main.js
bitemyapp/serials
// @flow import React from 'react' import {RouteHandler, Link} from 'react-router' import {assign} from 'lodash' import {Users} from '../model/user' import {background, Colors, clickable, displayIf} from '../style' import {AlertView} from '../alert' import {Alerts} from '../model/alert' import {Routes, transitionTo} from '../router' import {Header, SiteTitle} from './header' import {OffCanvas, MenuHeader, MenuLinkStyle} from './offcanvas' import {SubmitLink} from '../source/submit-link' export class Main extends React.Component { render():React.Element { return <MainContainer alert={this.props.alert} currentUser={this.props.currentUser}> <RouteHandler {...this.props}/> </MainContainer> } } export class MainContainer extends React.Component { render():React.Element { return <OffCanvas> <SiteTitle key="title" currentUser={this.props.currentUser} /> <MainMenu key="menu" currentUser={this.props.currentUser}/> <div className="row"> <div className="columns small-12" style={background}> {this.props.children} </div> <AlertView alert={this.props.alert}/> </div> </OffCanvas> } } //class MenuLink extends React.Component { //} var MenuIcon = { float: 'right', display: 'block', fontSize: 24, marginTop: 0 } //class MenuIcon extends React.Component { //render():React.Element { //return <div className="right"> //</div> //} //} export class MainMenu extends React.Component { render():React.Element { var user = this.props.currentUser var userContent = "" if (user) { userContent = <UserMenu currentUser={user} /> } else { userContent = <AnonMenu /> } return <ul className="off-canvas-list"> {userContent} <div> <li><MenuHeader>Web Fiction</MenuHeader></li> <li><Link to={Routes.library} style={MenuLinkStyle}> <span style={MenuIcon} className="fa fa-book"></span> <span> Library</span> </Link></li> <li><SubmitLink style={MenuLinkStyle}> <span style={MenuIcon} className="fa fa-plus-circle"></span> <span> Submit a book</span> </SubmitLink></li> <li><Link to={Routes.about} style={MenuLinkStyle}>About</Link></li> </div> </ul> } } export class AnonMenu extends React.Component { render():React.Element { return <div> <li><MenuHeader>Account</MenuHeader></li> <li><Link to={Routes.login}> <span style={MenuIcon} className="fa fa-sign-in"></span> <span> Login</span> </Link></li> </div> } } export class UserMenu extends React.Component { logout() { Users.logout().then(function() { transitionTo("login") }) } render():React.Element { var user = this.props.currentUser return <div> <li><MenuHeader>{user.firstName} {user.lastName}</MenuHeader></li> <li><Link to={Routes.bookshelf} params={user} style={MenuLinkStyle}> <span style={MenuIcon} className="fa fa-bookmark"></span> <span> My Bookshelf</span> </Link></li> <li style={displayIf(user.admin)}> <Link to={Routes.admin} style={MenuLinkStyle}>Admin</Link> </li> <li><a onClick={this.logout.bind(this)} style={MenuLinkStyle}> <span> Logout</span> </a></li> </div> } } // if logged in: you have user stuff there, like "Profile", "Logout", etc? // or, why don't I JUST have the logged in button? // WHat do I need in there: // About // Admin // My Books // Logout or Login // Home // My Proposals (etc)
src/components/app.js
marcusdarmstrong/cloth-io
// @flow import React from 'react'; import { Provider } from 'react-redux'; import Route from './route'; import Post from './post'; import Home from './home'; import ShareForm from './share-form'; import Frame from './frame'; import Comments from './comments'; import binder from './binder'; const BoundPost = binder(Post); const BoundHome = binder(Home); const BoundFrame = binder(Frame); const BoundComments = binder(Comments); const App = ({ store }: { store: Object }) => (<Provider store={store}> <div> <Route name="Post"> <BoundFrame> <BoundPost /> <BoundComments /> </BoundFrame> </Route> <Route name="Share"> <BoundFrame noShareForm> <ShareForm /> </BoundFrame> </Route> <Route name="Home"> <BoundFrame> <BoundHome /> </BoundFrame> </Route> </div> </Provider>); App.propTypes = { store: React.PropTypes.object, }; export default App;
1l_React_ET_Lynda/Ex_Files_React_EssT/Ch04/04_08/finish/src/index.js
yevheniyc/C
import React from 'react' import { render } from 'react-dom' import './stylesheets/ui.scss' import { App } from './components/App' window.React = React render( <App />, document.getElementById('react-container') )
todo-app/src/index.js
mlaskowski/react
import React from 'react'; import ReactDOM from 'react-dom'; import './index.css'; function Square(props) { return ( <button className="square" onClick={props.onClick}> {props.value} </button> ); } class Board extends React.Component { renderSquare(i) { return ( <Square value={this.props.squares[i]} onClick={() => this.props.onClick(i)} /> ); } render() { return ( <div> <div className="board-row"> {this.renderSquare(0)} {this.renderSquare(1)} {this.renderSquare(2)} </div> <div className="board-row"> {this.renderSquare(3)} {this.renderSquare(4)} {this.renderSquare(5)} </div> <div className="board-row"> {this.renderSquare(6)} {this.renderSquare(7)} {this.renderSquare(8)} </div> </div> ); } } class Game extends React.Component { constructor() { super(); this.state = { history: [{ squares: Array(9).fill(null), }], xIsNext: true, stepNumber: 0, }; } handleClick(i) { const history = this.state.history.slice(0, this.state.stepNumber + 1);; const current = history[history.length - 1]; const squares = current.squares.slice(); if (calculateWinner(squares) || squares[i]) { return; } squares[i] = this.state.xIsNext ? 'X' : 'O'; this.setState({ history: history.concat([{squares: squares}]), stepNumber: history.length, xIsNext: !this.state.xIsNext, }); } jumpTo(step){ this.setState({ stepNumber: step, xIsNext: (step % 2) === 0, }); } render() { const history = this.state.history; const current = history[this.state.stepNumber] const winner = calculateWinner(current.squares); const moves = history.map((step, move) => { const desc = move ? 'Move #' + move : 'Game start'; return ( <li key={move}> <a href="#" onClick={() => this.jumpTo(move)}>{desc}</a> </li> ); }); let status; if (winner) { status = 'Winner: ' + winner; } else { status = 'Next player: ' + (this.state.xIsNext ? 'X' : 'O'); } return ( <div className="game"> <div className="game-board"> <Board squares={current.squares} onClick={(i) => this.handleClick(i)}/> </div> <div className="game-info"> <div>{status}</div> <ol>{moves}</ol> </div> </div> ); } } // ======================================== ReactDOM.render( <Game />, document.getElementById('root') ); function calculateWinner(squares) { const lines = [ [0, 1, 2], [3, 4, 5], [6, 7, 8], [0, 3, 6], [1, 4, 7], [2, 5, 8], [0, 4, 8], [2, 4, 6], ]; for (let i = 0; i < lines.length; i++) { const [a, b, c] = lines[i]; if (squares[a] && squares[a] === squares[b] && squares[a] === squares[c]) { return squares[a]; } } return null; }
src/components/Col/Col.js
aaronvanston/react-flexa
import React from 'react'; import PropTypes from 'prop-types'; import styled from 'styled-components'; import { themeProvider } from '../../theme'; import { filterProps, mediaQuery, columnWidth, gutter, CSSProperty } from '../../helpers'; const Col = styled(props => React.createElement(props.elementType, filterProps(props, Col.propTypes)), )` // Initial component properties box-sizing: border-box; ${props => themeProvider.breakpointsKeys(props).map(breakpoint => mediaQuery(props)[breakpoint]` // Generated Display ${CSSProperty(props, breakpoint, 'display')} // Generate gutter ${gutter.col(props, breakpoint)} // Generate flex rule before width, this avoid override ${CSSProperty(props, breakpoint, 'flex')} // Generate column width ${columnWidth(props, breakpoint)} // Responsive Flexbox properties ${CSSProperty(props, breakpoint, 'order')} ${CSSProperty(props, breakpoint, 'align-self')} `)} `; Col.defaultProps = { order: 0, alignSelf: 'auto', elementType: 'div', display: 'block', flex: '0 0 auto', }; const displayOptions = ['flex', 'inline-flex', 'block', 'none', 'inline-block']; export const alignSelfOptions = ['auto', 'flex-start', 'flex-end', 'center', 'baseline', 'stretch']; Col.propTypes = { xs: PropTypes.oneOfType([PropTypes.number, PropTypes.string, PropTypes.oneOf(['hidden', 'auto'])]), sm: PropTypes.oneOfType([PropTypes.number, PropTypes.string, PropTypes.oneOf(['hidden', 'auto'])]), md: PropTypes.oneOfType([PropTypes.number, PropTypes.string, PropTypes.oneOf(['hidden', 'auto'])]), lg: PropTypes.oneOfType([PropTypes.number, PropTypes.string, PropTypes.oneOf(['hidden', 'auto'])]), gutter: PropTypes.oneOfType([ PropTypes.number, PropTypes.string, PropTypes.shape({ xs: PropTypes.oneOfType([ PropTypes.number, PropTypes.string, ]), sm: PropTypes.oneOfType([ PropTypes.number, PropTypes.string, ]), md: PropTypes.oneOfType([ PropTypes.number, PropTypes.string, ]), lg: PropTypes.oneOfType([ PropTypes.number, PropTypes.string, ]), }), ]), order: PropTypes.oneOfType([ PropTypes.number, PropTypes.shape({ xs: PropTypes.number, sm: PropTypes.number, md: PropTypes.number, lg: PropTypes.number, }), ]), alignSelf: PropTypes.oneOfType([ PropTypes.oneOf(alignSelfOptions), PropTypes.shape({ xs: PropTypes.oneOf(alignSelfOptions), sm: PropTypes.oneOf(alignSelfOptions), md: PropTypes.oneOf(alignSelfOptions), lg: PropTypes.oneOf(alignSelfOptions), }), ]), elementType: PropTypes.string, flex: PropTypes.oneOfType([ PropTypes.number, PropTypes.string, ]), display: PropTypes.oneOfType([ PropTypes.oneOf(displayOptions), PropTypes.shape({ xs: PropTypes.oneOf(displayOptions), sm: PropTypes.oneOf(displayOptions), md: PropTypes.oneOf(displayOptions), lg: PropTypes.oneOf(displayOptions), }), ]), children: PropTypes.node, }; Col.displayName = 'Col'; export default Col;
src/documentation/RegularPage.js
wfp/ui
import PropTypes from 'prop-types'; import React from 'react'; import Link from '../components/Link'; import Footer from '../components/Footer'; import Search from '../components/Search'; import { SecondaryNavigation, SecondaryNavigationTitle, } from '../components/SecondaryNavigation'; import Breadcrumb from '../components/Breadcrumb'; import BreadcrumbItem from '../components/BreadcrumbItem'; import BreadcrumbHome from '../components/BreadcrumbHome'; import Tabs from '../components/Tabs'; import Tab from '../components/Tab'; import Button from '../components/Button'; import MainNavigation from '../components/MainNavigation'; import MainNavigationItem from '../components/MainNavigationItem'; import { SubNavigationList, SubNavigation, SubNavigationHeader, SubNavigationTitle, SubNavigationContent, SubNavigationGroup, SubNavigationFilter, SubNavigationItem, SubNavigationLink, } from '../components/SubNavigation'; import User from '../components/User'; const props = { tabs: { className: 'some-class', triggerHref: '#anotherAnchor', inline: true, }, tab: { className: 'another-class', }, }; const renderAnchor = (props) => { return <a href={props.href}>{props.label}</a>; }; const RegularPage = ({ children, withoutSecondary, withoutSecondaryTabs, pageWidth, title, }) => { return ( <div> <MainNavigation pageWidth={pageWidth} logo={<a href="#">Application name</a>}> <MainNavigationItem> <Link href="http://communities.wfp.org" target="_blank"> Section 1 </Link> </MainNavigationItem> <MainNavigationItem subNavigation={ <SubNavigation> <SubNavigationHeader> <SubNavigationTitle>The Title</SubNavigationTitle> <SubNavigationLink> <Button small>The SubPage Link</Button> </SubNavigationLink> <SubNavigationFilter> <Search className="some-class" small label={null} id="search-2" placeHolderText="Filter List" /> </SubNavigationFilter> </SubNavigationHeader> <SubNavigationContent> <SubNavigationList> <SubNavigationGroup title="First List" columns> <SubNavigationItem> <Link href="https://go.docs.wfp.org" target="_blank"> Lorem Ipsum et jomen </Link> </SubNavigationItem> <SubNavigationItem> <Link href="https://go.docs.wfp.org" target="_blank"> At vero eos </Link> </SubNavigationItem> <SubNavigationItem> <Link href="https://go.docs.wfp.org" target="_blank"> Sadipscing elitr </Link> </SubNavigationItem> <SubNavigationItem> <Link href="https://go.docs.wfp.org" target="_blank"> At vero eos </Link> </SubNavigationItem> <SubNavigationItem> <Link href="https://go.docs.wfp.org" target="_blank"> Sadipscing elitr </Link> </SubNavigationItem> <SubNavigationItem> <Link href="https://go.docs.wfp.org" target="_blank"> Dolore magna </Link> </SubNavigationItem> <SubNavigationItem> <Link href="https://go.docs.wfp.org" target="_blank"> Sadipscing elitr </Link> </SubNavigationItem> <SubNavigationItem> <Link href="https://go.docs.wfp.org" target="_blank"> Consetetur sadipscing </Link> </SubNavigationItem> <SubNavigationItem> <Link href="https://go.docs.wfp.org" target="_blank"> Sadipscing elitr </Link> </SubNavigationItem> </SubNavigationGroup> <SubNavigationGroup title="Second List of Items" columns> <SubNavigationItem> <Link href="https://go.docs.wfp.org" target="_blank"> At vero eos </Link> </SubNavigationItem> <SubNavigationItem> <Link href="https://go.docs.wfp.org" target="_blank"> Sadipscing elitr </Link> </SubNavigationItem> <SubNavigationItem> <Link href="https://go.docs.wfp.org" target="_blank"> At vero eos </Link> </SubNavigationItem> <SubNavigationItem> <Link href="https://go.docs.wfp.org" target="_blank"> Nonumy eirmod </Link> </SubNavigationItem> <SubNavigationItem> <Link href="https://go.docs.wfp.org" target="_blank"> Consetetur sadipscing </Link> </SubNavigationItem> <SubNavigationItem> <Link href="https://go.docs.wfp.org" target="_blank"> Dolore magna </Link> </SubNavigationItem> <SubNavigationItem> <Link href="https://go.docs.wfp.org" target="_blank"> Nonumy eirmod </Link> </SubNavigationItem> <SubNavigationItem> <Link href="https://go.docs.wfp.org" target="_blank"> Dolore magna </Link> </SubNavigationItem> <SubNavigationItem> <Link href="https://go.docs.wfp.org" target="_blank"> Sadipscing elitr </Link> </SubNavigationItem> </SubNavigationGroup> </SubNavigationList> </SubNavigationContent> </SubNavigation> }> <Link href="http://manuals.wfp.org" target="_blank"> Section 2 </Link> </MainNavigationItem> <MainNavigationItem> <Link href="https://go.docs.wfp.org" target="_blank"> Section 3 </Link> </MainNavigationItem> <MainNavigationItem> <Link href="http://opweb.wfp.org" target="_blank"> Section 4 </Link> </MainNavigationItem> <MainNavigationItem> <Search kind="main" id="search-2" placeHolderText="Search" /> </MainNavigationItem> <MainNavigationItem className="wfp--main-navigation__user" subNavigation={ <div> <h3>Hello World</h3> <p> Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquya. </p> </div> }> <User ellipsis title="Max Mustermann long name" /> </MainNavigationItem> </MainNavigation> {!withoutSecondary && ( <SecondaryNavigation additional="additional Information" pageWidth={pageWidth}> <Breadcrumb> <BreadcrumbItem> <a href="/#"> <BreadcrumbHome /> </a> </BreadcrumbItem> <BreadcrumbItem href="#">Breadcrumb 2</BreadcrumbItem> <BreadcrumbItem disableLink> Breadcrumb 3</BreadcrumbItem> </Breadcrumb> <SecondaryNavigationTitle> {title ? title : 'The page title'} </SecondaryNavigationTitle> {!withoutSecondaryTabs && ( <Tabs {...props.tabs} customTabContent={true}> <Tab {...props.tab} label="Tab label 1" href="http://www.de.wfp.org" renderAnchor={renderAnchor} /> <Tab {...props.tab} label="Tab label 2" href="http://www.es.wfp.org" renderAnchor={renderAnchor} /> <Tab {...props.tab} label="Tab label 3" href="http://www.us.wfp.org" renderAnchor={renderAnchor} /> <Tab {...props.tab} label="Tab label 4" href="http://www.fr.wfp.org" renderAnchor={renderAnchor} /> </Tabs> )} </SecondaryNavigation> )} {children} <Footer pageWidth={pageWidth} metaContent="WFP UI Kit version 1.0 – powered by RMT with full support of concerned divisions which are responsible for the accuracy of the content"> <div className="wfp--footer__info"> <div className="wfp--footer__info__item"> <p className="wfp--footer__label">A label</p> <ul className="wfp--footer__list"> <li> <Link href="http://www.wfp.org">First Link</Link> </li> <li> <Link href="http://www.wfp.org">Second Link</Link> </li> </ul> </div> <div className="wfp--footer__info__item"> <p className="wfp--footer__label">Another label</p> <ul className="wfp--footer__list"> <li> <Link href="http://www.wfp.org">First Link</Link> </li> <li> <Link href="http://www.wfp.org">Second Link</Link> </li> </ul> </div> </div> </Footer> </div> ); }; RegularPage.propTypes = { /** Width of Wrapper, use 'narrow' or leave empty */ children: PropTypes.node, className: PropTypes.string, }; RegularPage.defaultProps = { pageWidth: 'lg', }; export default RegularPage;
src/main/resources/static/bower_components/jqwidgets/demos/react/app/numberinput/defaultfunctionality/app.js
dhawal9035/WebPLP
import React from 'react'; import ReactDOM from 'react-dom'; import JqxNumberInput from '../../../jqwidgets-react/react_jqxnumberinput.js'; class App extends React.Component { render () { return ( <div id='jqxWidget'> <div style={{ marginTop: 10 }}>Number</div> <JqxNumberInput ref='numericInput' width={250} height={25} spinButtons={true} /> <div style={{ marginTop: 10 }}>Percentage</div> <JqxNumberInput ref='percentageInput' width={250} height={25} digits={3} spinButtons={true} symbolPosition={'right'} symbol={'%'} /> <div style={{ marginTop: 10 }}>Currency</div> <JqxNumberInput ref='currencyInput' width={250} height={25} symbol={'%'} spinButtons={true} /> <div style={{ marginTop: 10 }}>Disabled</div> <JqxNumberInput ref='disabledInput' width={250} height={25} disabled={true} spinButtons={true} /> </div> ) } } ReactDOM.render(<App />, document.getElementById('app'));
src/Parser/Hunter/BeastMastery/Modules/Traits/CobraCommander.js
hasseboulen/WoWAnalyzer
import React from 'react'; import Analyzer from 'Parser/Core/Analyzer'; import Combatants from 'Parser/Core/Modules/Combatants'; import SPELLS from 'common/SPELLS'; import SpellIcon from "common/SpellIcon"; import SpellLink from 'common/SpellLink'; import ItemDamageDone from 'Main/ItemDamageDone'; class CobraCommander extends Analyzer { static dependencies = { combatants: Combatants, }; summons = 0; cobraCommanderIDs = []; sneakySnakeDamage = 0; on_initialized() { this.active = this.combatants.selected.traitsBySpellId[SPELLS.COBRA_COMMANDER_TRAIT.id]; } on_byPlayer_summon(event) { const summonId = event.ability.guid; if (summonId !== SPELLS.COBRA_COMMANDER.id) { return; } this.cobraCommanderIDs.push({ ID: event.targetID, instance: event.targetInstance, }); this.summons += 1; } on_byPlayerPet_damage(event) { const index = this.cobraCommanderIDs.findIndex(sneakySnake => sneakySnake.ID === event.sourceID && sneakySnake.instance === event.sourceInstance); const selectedSneakySnake = this.cobraCommanderIDs[index]; if (!selectedSneakySnake) { return; } this.sneakySnakeDamage += event.amount + (event.absorbed || 0); } subStatistic() { return ( <div className="flex"> <div className="flex-main"> <SpellLink id={SPELLS.COBRA_COMMANDER.id}> <SpellIcon id={SPELLS.COBRA_COMMANDER.id} noLink /> Sneaky Snakes </SpellLink> </div> <div className="flex-sub text-right"> <ItemDamageDone amount={this.sneakySnakeDamage} /> </div> </div> ); } } export default CobraCommander;
blueocean-material-icons/src/js/components/svg-icons/device/graphic-eq.js
jenkinsci/blueocean-plugin
import React from 'react'; import SvgIcon from '../../SvgIcon'; const DeviceGraphicEq = (props) => ( <SvgIcon {...props}> <path d="M7 18h2V6H7v12zm4 4h2V2h-2v20zm-8-8h2v-4H3v4zm12 4h2V6h-2v12zm4-8v4h2v-4h-2z"/> </SvgIcon> ); DeviceGraphicEq.displayName = 'DeviceGraphicEq'; DeviceGraphicEq.muiName = 'SvgIcon'; export default DeviceGraphicEq;
src/svg-icons/action/face.js
frnk94/material-ui
import React from 'react'; import pure from 'recompose/pure'; import SvgIcon from '../../SvgIcon'; let ActionFace = (props) => ( <SvgIcon {...props}> <path d="M9 11.75c-.69 0-1.25.56-1.25 1.25s.56 1.25 1.25 1.25 1.25-.56 1.25-1.25-.56-1.25-1.25-1.25zm6 0c-.69 0-1.25.56-1.25 1.25s.56 1.25 1.25 1.25 1.25-.56 1.25-1.25-.56-1.25-1.25-1.25zM12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8 0-.29.02-.58.05-.86 2.36-1.05 4.23-2.98 5.21-5.37C11.07 8.33 14.05 10 17.42 10c.78 0 1.53-.09 2.25-.26.21.71.33 1.47.33 2.26 0 4.41-3.59 8-8 8z"/> </SvgIcon> ); ActionFace = pure(ActionFace); ActionFace.displayName = 'ActionFace'; ActionFace.muiName = 'SvgIcon'; export default ActionFace;
test/integration/css-fixtures/npm-import-nested/pages/_app.js
zeit/next.js
import React from 'react' import App from 'next/app' import '../styles/global.css' class MyApp extends App { render() { const { Component, pageProps } = this.props return <Component {...pageProps} /> } } export default MyApp
src0/components/Bids.js
yaswanthsvist/openCexTrade
import React from 'react'; import { StyleSheet, Text,Button, View,ScrollView,StatusBar,Image } from 'react-native'; class Bids extends React.Component{ constructor(props){ super(props) this.state={}; } static navigationOptions={ title:"Bids", drawerLabel: 'Home', tabBarLabel: 'Bids', } render(){ return( <View> </View> ) } } export default Bids;
src/calendar-body/CalendarBody.js
topcatcreatives/react-date-scroll
import React, { Component } from 'react'; import ReactDOM from 'react-dom'; import moment from 'moment'; import CalendarMonth from './CalendarMonth'; import './styles/calendar-body.css'; class CalendarBody extends Component { constructor(props) { super(props); this.state = { months: this.addMonths() }; this.handleScroll = this.handleScroll.bind(this); } handleScroll() { var bounds = document.querySelector('.calendar-body').getBoundingClientRect(), bottomPosition = bounds.bottom - window.innerHeight, bottomMinimum = 200, months = null; if (bottomPosition < bottomMinimum) { months = this.addMonths(this.state.months); this.setState({ months: months }); } } componentDidMount() { window.addEventListener('scroll', this.handleScroll); } componentWillUnmount() { window.removeEventListener('scroll', this.handleScroll); } componentDidUpdate() { var node = ReactDOM.findDOMNode(this); if (this.props.hasCleared) { node.scrollTop = 0; this.props.scrolledToTop(); } } addMonths(existingMonths) { var months = [], monthLength = 0, monthLengthInit = 12, monthLengthAppend = 4, startIndex = 0; if (typeof(existingMonths) !== 'undefined' && existingMonths) { months = existingMonths; startIndex = existingMonths.length; monthLength = monthLengthAppend + startIndex; } else { monthLength = monthLengthInit; } for (let i = startIndex; i < monthLength; i++) { months.push(moment().add(i, 'month').startOf('month')); } return months; } render() { var months = this.state.months, monthsList = [], startDate = this.props.startDate, endDate = this.props.endDate, dateClick = this.props.dateClick, dayIndex = this.props.dayIndex; monthsList = months.map(function(month, index) { return <CalendarMonth key={index} month={month} startDate={startDate} endDate={endDate} dateClick={dateClick} dayIndex={dayIndex}> </CalendarMonth> }, this); return ( <div className="calendar-body-wrapper" onScroll={this.handleScroll}> <div className="calendar-body"> {monthsList} </div> </div> ); } } export default CalendarBody;
src/components/dashboard/bar-chart.js
fnumono/combo
import React from 'react'; import { Bar } from 'react-chartjs'; import { getRandomInt } from './util'; class BarChart extends React.Component { constructor() { super(); this.state = { data: { labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'], datasets: [ { label: 'Bar Chart First dataset', fillColor: '#E8575A', strokeColor: '#E8575A', highlightFill: 'rgba(220,220,220,0.75)', highlightStroke: 'rgba(220,220,220,1)', data: [65, 59, 80, 81, 56, 55, 40], }, { label: 'My Second dataset', fillColor: '#0094D6', strokeColor: '#0094D6', highlightFill: 'rgba(151,187,205,0.75)', highlightStroke: 'rgba(151,187,205,1)', data: [28, 48, 40, 19, 86, 27, 90], }, ], }, }; } componentDidMount() { const refreshIntervalId = setInterval(() => { this.state.data.datasets[0].data.shift(); this.state.data.datasets[0].data.push(getRandomInt(0, 90)); this.state.data.datasets[1].data.shift(); this.state.data.datasets[1].data.push(getRandomInt(0, 90)); this.setState({ data: this.state.data, refreshIntervalId, }); }, 2000); } componentWillUnmount() { clearInterval(this.state.refreshIntervalId); } render() { return ( <div> <Bar data={this.state.data} options={{responsive: true, animationSteps: 300 }} height="210" width="800"/> </div> ); } } export default BarChart;
frontend/src/Settings/Profiles/Quality/QualityProfilesConnector.js
lidarr/Lidarr
import PropTypes from 'prop-types'; import React, { Component } from 'react'; import { connect } from 'react-redux'; import { createSelector } from 'reselect'; import { cloneQualityProfile, deleteQualityProfile, fetchQualityProfiles } from 'Store/Actions/settingsActions'; import createSortedSectionSelector from 'Store/Selectors/createSortedSectionSelector'; import sortByName from 'Utilities/Array/sortByName'; import QualityProfiles from './QualityProfiles'; function createMapStateToProps() { return createSelector( createSortedSectionSelector('settings.qualityProfiles', sortByName), (qualityProfiles) => qualityProfiles ); } const mapDispatchToProps = { dispatchFetchQualityProfiles: fetchQualityProfiles, dispatchDeleteQualityProfile: deleteQualityProfile, dispatchCloneQualityProfile: cloneQualityProfile }; class QualityProfilesConnector extends Component { // // Lifecycle componentDidMount() { this.props.dispatchFetchQualityProfiles(); } // // Listeners onConfirmDeleteQualityProfile = (id) => { this.props.dispatchDeleteQualityProfile({ id }); } onCloneQualityProfilePress = (id) => { this.props.dispatchCloneQualityProfile({ id }); } // // Render render() { return ( <QualityProfiles onConfirmDeleteQualityProfile={this.onConfirmDeleteQualityProfile} onCloneQualityProfilePress={this.onCloneQualityProfilePress} {...this.props} /> ); } } QualityProfilesConnector.propTypes = { dispatchFetchQualityProfiles: PropTypes.func.isRequired, dispatchDeleteQualityProfile: PropTypes.func.isRequired, dispatchCloneQualityProfile: PropTypes.func.isRequired }; export default connect(createMapStateToProps, mapDispatchToProps)(QualityProfilesConnector);
docs/Documentation/CardPage.js
reactivers/react-material-design
/** * Created by muratguney on 29/03/2017. */ import React from 'react'; import {Card, CardHeader, CardActions, CardBody,Button,Table,TableRow,TableHeaderColumn,TableHeader,TableRowColumn,TableBody} from '../../lib'; import HighLight from 'react-highlight.js' export default class CardPage extends React.Component { render() { let document = [ 'import React from "react";', 'import {Card, CardHeader,CardActions, CardBody} from "react-material-design";', 'export default class Example extends React.Component {', ' render(){', ' return (', ' <Card>', ' <CardHeader title="Card Header">', ' <CardBody>', ' Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin mollis ', ' lectus cursus nulla euismod,eu pellentesque est blandit. Cras ac massa ', ' justo. Ut dapibus laoreet ligula, id venenatis risusplacerat nec. Aliquam dapibus odio ', ' vel lectus sagittis, id luctus erat mattis.', ' </CardBody>', ' <CardActions>', ' <Button accent raised style={{marginRight:8}}>Action 1</Button>', ' <Button primary raised>Action 2</Button>', ' </CardActions>', ' </Card>', ' )', ' }', ' }', ].join('\n'); return ( <Card style={{padding:8}}> <CardHeader title="Card"/> <Card> <CardHeader title="Card Header" /> <CardBody > Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin mollis lectus cursus nulla euismod, eu pellentesque est blandit. Cras ac massa justo. Ut dapibus laoreet ligula, id venenatis risus placerat nec. Aliquam dapibus odio vel lectus sagittis, id luctus erat mattis. Pellentesque sit amet nisi euismod, lacinia lectus quis, porta velit. Nulla dapibus commodo lacinia. Etiam pellentesque turpis eu nisi sagittis, eu euismod dui ullamcorper. Aenean efficitur imperdiet quam. Suspendisse quis arcu erat. </CardBody> <CardActions> <Button accent raised style={{marginRight:8}}>Action 1</Button> <Button primary raised>Action 2</Button> </CardActions> </Card> <HighLight source="javascript"> {document} </HighLight> <CardHeader title="Card properties" /> <Table> <TableHeader> <TableRow> <TableHeaderColumn>Props</TableHeaderColumn> <TableHeaderColumn>Type</TableHeaderColumn> <TableHeaderColumn>Description</TableHeaderColumn> </TableRow> </TableHeader> <TableBody> <TableRow> <TableRowColumn>className</TableRowColumn> <TableRowColumn>String</TableRowColumn> <TableRowColumn>You can add your ownd css classes</TableRowColumn> </TableRow> <TableRow> <TableRowColumn>style</TableRowColumn> <TableRowColumn>Object</TableRowColumn> <TableRowColumn>You can add your own css inline-style</TableRowColumn> </TableRow> <TableRow> <TableRowColumn>shadow</TableRowColumn> <TableRowColumn>Number</TableRowColumn> <TableRowColumn longText>You can set shadow level by shadow props</TableRowColumn> </TableRow> </TableBody> </Table> <CardHeader title="CardHeader properties" /> <Table> <TableHeader> <TableRow> <TableHeaderColumn>Props</TableHeaderColumn> <TableHeaderColumn>Type</TableHeaderColumn> <TableHeaderColumn>Description</TableHeaderColumn> </TableRow> </TableHeader> <TableBody> <TableRow> <TableRowColumn>className</TableRowColumn> <TableRowColumn>String</TableRowColumn> <TableRowColumn>You can add your ownd css classes.</TableRowColumn> </TableRow> <TableRow> <TableRowColumn>style</TableRowColumn> <TableRowColumn>Object</TableRowColumn> <TableRowColumn>You can add your own css inline-style.</TableRowColumn> </TableRow> <TableRow> <TableRowColumn>title</TableRowColumn> <TableRowColumn>String</TableRowColumn> <TableRowColumn>Title for card.</TableRowColumn> </TableRow> <TableRow> <TableRowColumn>subtitle</TableRowColumn> <TableRowColumn>String</TableRowColumn> <TableRowColumn>If you need more explanation you can use subtitle props.</TableRowColumn> </TableRow> </TableBody> </Table> <CardHeader title="CardBody properties" /> <Table> <TableHeader> <TableRow> <TableHeaderColumn>Props</TableHeaderColumn> <TableHeaderColumn>Type</TableHeaderColumn> <TableHeaderColumn>Description</TableHeaderColumn> </TableRow> </TableHeader> <TableBody> <TableRow> <TableRowColumn>className</TableRowColumn> <TableRowColumn>String</TableRowColumn> <TableRowColumn>You can add your ownd css classes.</TableRowColumn> </TableRow> <TableRow> <TableRowColumn>style</TableRowColumn> <TableRowColumn>Object</TableRowColumn> <TableRowColumn>You can add your own css inline-style.</TableRowColumn> </TableRow> </TableBody> </Table> <CardHeader title="CardActions properties" /> <Table> <TableHeader> <TableRow> <TableHeaderColumn>Props</TableHeaderColumn> <TableHeaderColumn>Type</TableHeaderColumn> <TableHeaderColumn>Description</TableHeaderColumn> </TableRow> </TableHeader> <TableBody> <TableRow> <TableRowColumn>className</TableRowColumn> <TableRowColumn>String</TableRowColumn> <TableRowColumn>You can add your ownd css classes.</TableRowColumn> </TableRow> <TableRow> <TableRowColumn>style</TableRowColumn> <TableRowColumn>Object</TableRowColumn> <TableRowColumn>You can add your own css inline-style.</TableRowColumn> </TableRow> </TableBody> </Table> </Card> ) } }
packages/slate-html-serializer/test/serialize/block.js
AlbertHilb/slate
/** @jsx h */ import React from 'react' import h from '../helpers/h' export const rules = [ { serialize(obj, children) { if (obj.kind == 'block' && obj.type == 'paragraph') { return React.createElement('p', {}, children) } } } ] export const input = ( <state> <document> <paragraph> one </paragraph> </document> </state> ) export const output = ` <p>one</p> `.trim()
demo/src/index.js
sidferreira/aor-firebase-client
import React from 'react'; import ReactDOM from 'react-dom'; import './index.css'; import App from './App'; ReactDOM.render(<App />, document.getElementById('root'));
src/components/UI/Icon/Icon.js
Aloomaio/netlify-cms
import React from 'react'; import icons from './icons'; /** * Calculates rotation for icons that have a `direction` property configured * in the imported icon definition object. If no direction is configured, a * neutral rotation value is returned. * * Returned value is a string of shape `${degrees}deg`, for use in a CSS * transform. */ const getRotation = (iconDirection, newDirection) => { if (!iconDirection || !newDirection) { return '0deg'; } const rotations = { right: 90, down: 180, left: 270, up: 360 }; const degrees = rotations[newDirection] - rotations[iconDirection]; return `${degrees}deg`; } const sizes = { xsmall: '12px', small: '18px', medium: '24px', large: '32px', }; export const Icon = props => { const { type, direction, size = 'medium', className = '', width, height, ...remainingProps, } = props; const icon = icons[type]; const rotation = getRotation(icon.direction, direction) const transform = `rotate(${rotation})`; const sizeResolved = sizes[size] || size; const style = { width: sizeResolved, height: sizeResolved, transform }; return ( <span className={`nc-icon ${className}`} {...remainingProps}> <span dangerouslySetInnerHTML={{ __html: icon.image }} style={style}></span> </span> ); }
client/src/components/auth/require_authentication.js
uxal/AuthenticationReduxTest
/** * Created by dragos on 18/01/2017. */ import React, { Component } from 'react'; import { connect } from 'react-redux'; export default function(ComposedComponent) { class Authentication extends Component { static contextTypes = { router: React.PropTypes.object } componentWillMount() { if (!this.props.authenticated) { this.context.router.push('/'); } } componentWillUpdate(nextProps) { if (!nextProps.authenticated) { this.context.router.push('/'); } } render() { return <ComposedComponent {...this.props} /> } } function mapStateToProps(state) { return { authenticated: state.auth.authenticated }; } return connect(mapStateToProps)(Authentication); }
examples/with-redux-reselect-recompose/components/page.js
giacomorebonato/next.js
import React from 'react' import PropTypes from 'prop-types' import Link from 'next/link' import { compose, setDisplayName, pure, setPropTypes } from 'recompose' import Clock from './clock' import AddCount from './addCount' const Page = ({ title, linkTo, light, lastUpdate, count, addCount }) => <div> <h1>{title}</h1> <Clock lastUpdate={lastUpdate} light={light} /> <AddCount count={count} addCount={addCount} /> <nav> <Link href={linkTo}><a>Navigate</a></Link> </nav> </div> export default compose( setDisplayName('Page'), setPropTypes({ title: PropTypes.string, linkTo: PropTypes.string, light: PropTypes.bool, lastUpdate: PropTypes.number, count: PropTypes.number, addCount: PropTypes.func }), pure )(Page)
src/index.js
travism26/microservice-frontend
import React from 'react'; import ReactDOM from 'react-dom'; import App from './App'; import './index.css'; import './client.min.js' import Bootstrap from "./vendor/bootstrap-without-jquery" import { Router, Route, IndexRoute, browserHistory } from "react-router"; import Archives from "./pages/Archives" import Featured from "./pages/Featured" import Layout from "./pages/Layout" import Settings from "./pages/Settings" import Todos from "./pages/Todos" // ReactDOM.render( // <Layout />, // document.getElementById('root') // ); ReactDOM.render( <Router history={browserHistory}> <Route path="/" components={Layout}> <IndexRoute component={Featured}></IndexRoute> <Route path="archives(/:article)" component={Archives}></Route> <Route path="settings" component={Settings}></Route> <Route path="todos" component={Todos}></Route> </Route> </Router>, document.getElementById('root'));
newclient/scripts/components/user/dashboard/disclosure-table-row/index.js
kuali/research-coi
/* The Conflict of Interest (COI) module of Kuali Research Copyright © 2005-2016 Kuali, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/> */ import styles from './style'; import classNames from 'classnames'; import React from 'react'; import {GreyButton} from '../../../grey-button'; import {formatDate} from '../../../../format-date'; import { getDisclosureTypeString, getDisclosureStatusString } from '../../../../stores/config-store'; import { EDITABLE_STATUSES, DISCLOSURE_STATUS } from '../../../../../../coi-constants'; import {Link} from 'react-router'; function wrapWithUpdateLink(dom, type) { return ( <Link style={{color: window.colorBlindModeOn ? 'black' : '#0095A0'}} to={{pathname: '/coi/new/disclosure', query: {type}}} > {dom} </Link> ); } function wrapWithReviseLink(dom, disclosureId) { return ( <Link style={{color: window.colorBlindModeOn ? 'black' : '#0095A0'}} to={{pathname: `/coi/new/revise/${disclosureId}`}} > {dom} </Link> ); } function wrapWithReadOnlyLink(dom, disclosureId) { return ( <Link style={{color: window.colorBlindModeOn ? 'black' : '#0095A0'}} to={{pathname: `/coi/new/readonly/${disclosureId}`}} > {dom} </Link> ); } export default function DisclosureTableRow(props, {configState}) { const { status, type, configId, expiresOn, lastreviewed, className, disclosureId } = props; const updateable = EDITABLE_STATUSES.includes(status); const revisable = status === DISCLOSURE_STATUS.REVISION_REQUIRED; const disclosureType = getDisclosureTypeString( configState, type, configId ); let extraInfo; if (expiresOn) { extraInfo = ( <span role="gridcell" className={`${styles.cell} ${styles.one}`}> <div className={styles.type}>{disclosureType}</div> <div className={styles.extra}> Expires On: <span style={{marginLeft: 3}}> {formatDate(expiresOn)} </span> </div> </span> ); } else { extraInfo = ( <span role="gridcell" className={`${styles.cell} ${styles.one}`}> <div className={styles.type}>{disclosureType}</div> </span> ); } if (updateable) { extraInfo = wrapWithUpdateLink(extraInfo, type); } else if (revisable) { extraInfo = wrapWithReviseLink(extraInfo, disclosureId); } else { extraInfo = wrapWithReadOnlyLink(extraInfo, disclosureId); } const disclosureStatus = getDisclosureStatusString( configState, status, configId ); let statusColumn = ( <span role="gridcell" className={`${styles.cell} ${styles.two}`}> {disclosureStatus} </span> ); if (updateable) { statusColumn = wrapWithUpdateLink(statusColumn, type); } else if (revisable) { statusColumn = wrapWithReviseLink(statusColumn, disclosureId); } else { statusColumn = wrapWithReadOnlyLink(statusColumn, disclosureId); } let lastReviewed = ( <span role="gridcell" className={`${styles.cell} ${styles.three}`}> {lastreviewed ? formatDate(lastreviewed) : 'None'} </span> ); if (updateable) { lastReviewed = wrapWithUpdateLink(lastReviewed, type); } else if (revisable) { lastReviewed = wrapWithReviseLink(lastReviewed, disclosureId); } else { lastReviewed = wrapWithReadOnlyLink(lastReviewed, disclosureId); } let button; if (updateable) { button = wrapWithUpdateLink(( <GreyButton className={styles.button}>Update &gt;</GreyButton> ), type); } else if (revisable) { button = wrapWithReviseLink(( <GreyButton className={styles.button}>Revise &gt;</GreyButton> ), disclosureId); } else { button = wrapWithReadOnlyLink(( <GreyButton className={styles.button}>View &gt;</GreyButton> ), disclosureId); } const buttonColumn = ( <span role="gridcell" className={`${styles.cell} ${styles.four}`}> {button} </span> ); const classes = classNames( styles.container, {[styles.annual]: type === 'Annual'}, className ); return ( <div role="row" className={classes}> {extraInfo} {statusColumn} {lastReviewed} {buttonColumn} </div> ); } DisclosureTableRow.contextTypes = { configState: React.PropTypes.object };
src/index.js
tiddle/sheet-music-generator
import React from 'react'; import ReactDOM from 'react-dom'; import App from './App.jsx'; import './index.css'; ReactDOM.render( < App / > , document.getElementById('root') );
lib/MultiColumnList/PagingButton.js
folio-org/stripes-components
import React from 'react'; import PropTypes from 'prop-types'; import { Loading } from '../Loading'; import Button from '../Button'; const PagingButton = ({ loading, onClick, loadingMessage, pagingButtonLabel, sendMessage, ...props }) => { const handleClick = () => { sendMessage(loadingMessage); onClick(); }; return ( <> <Button onClick={handleClick} data-test-paging-button {... props} > {!loading && pagingButtonLabel} {loading && <Loading size="medium" useCurrentColor />} </Button> </> ); }; PagingButton.propTypes = { loading: PropTypes.bool, loadingMessage: PropTypes.string, onClick: PropTypes.func, pagingButtonLabel: PropTypes.node, sendMessage: PropTypes.func, }; export default PagingButton;
test/integration/production-swcminify/pages/svg-image.js
azukaru/next.js
import React from 'react' import Image from 'next/image' const Page = () => { return ( <div> <h1>SVG with a script tag attempting XSS</h1> <Image id="img" src="/xss.svg" width="100" height="100" /> <p id="msg">safe</p> </div> ) } export default Page
src/react.js
goldensunliu/redux
import React from 'react'; import createAll from './components/createAll'; export const { Provider, Connector, provide, connect } = createAll(React);
inc/option_fields/vendor/htmlburger/carbon-fields/assets/js/containers/components/container/base.js
wpexpertsio/WP-Secure-Maintainance
/** * The external dependencies. */ import React from 'react'; import PropTypes from 'prop-types'; import cx from 'classnames'; /** * The internal dependencies. */ import fieldFactory from 'fields/factory'; /** * The base component used to render the containers. * * @param {Object} props * @param {Object} props.container * @param {Object[]} props.fields * @param {React.Element} props.children * @return {React.Element} */ const ContainerBase = ({ container, fields, children }) => { const classes = [ 'carbon-container', `carbon-container-${container.id}`, `carbon-container-${container.type}`, ...container.classes, ]; return <div className={cx(classes)}> {children} { fields.map(({ id, type }) => fieldFactory(type, { id })) } </div>; }; /** * Validate the props. * * @type {Object} */ ContainerBase.propTypes = { container: PropTypes.shape({ id: PropTypes.string, type: PropTypes.string, classes: PropTypes.arrayOf(PropTypes.string), }), fields: PropTypes.arrayOf(PropTypes.shape({ id: PropTypes.string, type: PropTypes.string, })), children: PropTypes.element, }; export default ContainerBase;
src/parser/monk/windwalker/modules/talents/HitCombo.js
FaideWW/WoWAnalyzer
/* TODO: * Track number of times the buff drops * Track what spell / point in fight the buff dropped */ import React from 'react'; import SPELLS from 'common/SPELLS'; import SpellIcon from 'common/SpellIcon'; import SpellLink from 'common/SpellLink'; import StatisticBox, { STATISTIC_ORDER } from 'interface/others/StatisticBox'; import { formatPercentage } from 'common/format'; import Analyzer from 'parser/core/Analyzer'; class HitCombo extends Analyzer { constructor(...args) { super(...args); this.active = this.selectedCombatant.hasTalent(SPELLS.HIT_COMBO_TALENT.id); } get uptime() { return this.selectedCombatant.getBuffUptime(SPELLS.HIT_COMBO_BUFF.id) / this.owner.fightDuration; } get suggestionThresholds() { return { actual: this.uptime, isLessThan: { minor: 0.98, average: 0.95, major: 0.90, }, style: 'percentage', }; } suggestions(when) { when(this.suggestionThresholds).isLessThan(0.95) .addSuggestion((suggest, actual, recommended) => { return suggest(<span>You let your <SpellLink id={SPELLS.HIT_COMBO_TALENT.id} /> buff drop by casting a spell twice in a row. Dropping this buff is a large DPS decrease so be mindful of the spells being cast.</span>) .icon(SPELLS.HIT_COMBO_TALENT.icon) .actual(`${formatPercentage(actual)} % uptime`) .recommended(`>${formatPercentage(recommended)} % is recommended`); }); } statistic() { return ( <StatisticBox position={STATISTIC_ORDER.CORE(3)} icon={<SpellIcon id={SPELLS.HIT_COMBO_TALENT.id} />} value={`${formatPercentage(this.uptime)} %`} tooltip="Hit Combo Uptime" /> ); } } export default HitCombo;
docs/src/components/Icons/Icons.js
seekinternational/seek-asia-style-guide
import React from 'react'; import styles from './Icons.less'; import { PageBlock, Card, Section, Paragraph, Text } from 'seek-asia-style-guide/react'; import iconsSketchExports from '../../../../react/*/*.iconSketch.js'; import map from 'lodash/map'; const renderIcons = sketch => { return sketch && sketch.symbols ? ( <div> <PageBlock> <div> <Section className={styles.section}> {map(sketch.symbols || {}, (element, name) => ( <div key={name} className={styles.symbolContainer}> <div className={styles.symbolName}> <Text whispering>{name.replace(/\//g, ' \u25B8 ')}</Text> </div> <div className={styles.symbolElement}>{element}</div> </div> ))} </Section> </div> </PageBlock> </div> ) : null; }; const renderAllIcons = () => { return iconsSketchExports.map(symbols => { return renderIcons(symbols); }); }; export default function Icons() { return ( <div> <PageBlock> <Section header> <Text screaming>Icons</Text> </Section> <Card transparent style={{ maxWidth: 720 }}> <Section> <Paragraph> <Text> These are the icons components available for use in the SEEK Asia Style Guide. </Text> </Paragraph> </Section> </Card> </PageBlock> <PageBlock> <Card className={styles.iconsCard}>{renderAllIcons()}</Card> </PageBlock> </div> ); }
packages/component/src/Toast/ExpandIcon.js
billba/botchat
import PropTypes from 'prop-types'; import React from 'react'; const ExpandIcon = ({ className }) => ( <svg className={(className || '') + ''} height="10" viewBox="0 0 16 10" width="16" xmlns="http://www.w3.org/2000/svg"> <path d="M15.1484 0.648437L15.8516 1.35156L8 9.20312L0.148438 1.35156L0.851563 0.648438L8 7.79687L15.1484 0.648437Z" /> </svg> ); ExpandIcon.defaultProps = { className: undefined }; ExpandIcon.propTypes = { className: PropTypes.string }; export default ExpandIcon;
client/auth/login.js
jaketrent/gratigoose
import { connect } from 'react-redux' import React from 'react' import styleable from 'react-styleable' import * as actions from './actions' import Field from '../common/components/field' import Fullpage from '../common/layouts/fullpage' import css from './login.css' import renderWithState from '../common/store/render' import * as router from '../common/router' import Title from '../common/components/title' const { func } = React.PropTypes function mapStateToProps(state) { return { session: state.auth.session } } function mapDispatchToProps(dispatch) { return { login(username, password) { dispatch(actions.login(username, password)) } } } class LoginForm extends React.Component { constructor(props) { super(props) this.state = { username: '', password: '' } this.handleSubmit = this.handleSubmit.bind(this) this.handleFieldChange = this.handleFieldChange.bind(this) } handleSubmit(evt) { evt.preventDefault() this.props.onSubmit(this.state.username, this.state.password) } handleFieldChange(evt) { this.setState({ [evt.target.name]: evt.target.value }) } render() { return ( <div className={this.props.css.root}> <h1 className={this.props.css.img}>Gratigoose</h1> <form onSubmit={this.handleSubmit}> <Field isFocused={true} label="Username" onFieldChange={this.handleFieldChange} name="username" value={this.state.username} /> <Field label="Password" onFieldChange={this.handleFieldChange} name="password" type="password" value={this.state.password} /> <button className={this.props.css.btn}>Login</button> </form> </div> ) } } LoginForm.propTypes = { onSubmit: func.isRequired } const StyledLoginForm = styleable(css)(LoginForm) class Login extends React.Component { componentWillMount() { if (this.props.session) router.redirect('/') } componentWillReceiveProps(nextProps) { if (nextProps.session) router.redirect('/') } render() { return ( <Fullpage> <StyledLoginForm onSubmit={this.props.login} /> </Fullpage> ) } } export default function render(store, el) { renderWithState(connect(mapStateToProps, mapDispatchToProps)(Login), el) }
src/webview/js/components/log/string.js
julianburr/sketch-debugger
import React, { Component } from 'react'; export default class LogString extends Component { render () { const { name, string } = this.props; return ( <span className="log-string"> {name && ( <span> <span className="log-key">{name}</span> <span className="log-colon">: </span> </span> )} <span className="log-value">{JSON.stringify(string)}</span> </span> ); } }
src/js/components/components.app-background.js
stamkracht/Convy
import React from 'react'; class AppBackground extends React.Component { render() { let backgroundImage = { backgroundImage: `url('${this.props.backgroundImage}')` }; return ( <div className="c-app-background" style={ backgroundImage }></div> ); } // functions. } export default AppBackground;
actor-apps/app-web/src/app/components/sidebar/ContactsSectionItem.react.js
akingyin1987/actor-platform
import React from 'react'; import ReactMixin from 'react-mixin'; import addons from 'react/addons'; import DialogActionCreators from 'actions/DialogActionCreators'; import AvatarItem from 'components/common/AvatarItem.react'; const {addons: { PureRenderMixin }} = addons; @ReactMixin.decorate(PureRenderMixin) class ContactsSectionItem extends React.Component { static propTypes = { contact: React.PropTypes.object }; constructor(props) { super(props); } openNewPrivateCoversation = () => { DialogActionCreators.selectDialogPeerUser(this.props.contact.uid); } render() { const contact = this.props.contact; return ( <li className="sidebar__list__item row" onClick={this.openNewPrivateCoversation}> <AvatarItem image={contact.avatar} placeholder={contact.placeholder} size="small" title={contact.name}/> <div className="col-xs"> <span className="title"> {contact.name} </span> </div> </li> ); } } export default ContactsSectionItem;
packages/react-scripts/template/src/index.js
picter/create-react-app
import React from 'react'; import ReactDOM from 'react-dom'; import './index.css'; import App from './App'; import registerServiceWorker from './registerServiceWorker'; ReactDOM.render(<App />, document.getElementById('root')); registerServiceWorker();
src/components/common/forms/TextAreaInput.js
seyade/loggent
import React from 'react'; const TextAreaInput = ({label, name, id, placeholder, rows, cols, onChange, value}) => { return ( <div className="control"> <label className="control__label" htmlFor={id}>{label}</label> <textarea className="control__textarea" name={name} id={id} rows={rows} cols={cols} placeholder={placeholder} value={value} onChange={onChange}> </textarea> </div> ); }; export default TextAreaInput;
src/DropdownToggle.js
pombredanne/react-bootstrap
import React from 'react'; import classNames from 'classnames'; import Button from './Button'; import SafeAnchor from './SafeAnchor'; const CARET = <span> <span className="caret" /></span>; export default class DropdownToggle extends React.Component { render() { const caret = this.props.noCaret ? null : CARET; const classes = { 'dropdown-toggle': true }; const Component = this.props.useAnchor ? SafeAnchor : Button; return ( <Component {...this.props} className={classNames(classes, this.props.className)} type="button" aria-haspopup aria-expanded={this.props.open}> {this.props.children || this.props.title}{caret} </Component> ); } } DropdownToggle.defaultProps = { open: false, useAnchor: false, bsRole: 'toggle' }; DropdownToggle.propTypes = { bsRole: React.PropTypes.string, noCaret: React.PropTypes.bool, open: React.PropTypes.bool, title: React.PropTypes.string, useAnchor: React.PropTypes.bool }; DropdownToggle.isToggle = true; DropdownToggle.titleProp = 'title'; DropdownToggle.onClickProp = 'onClick';
src/renderer/renderPass.js
gabrielbull/jquery-retinadisplay
import React from 'react'; import { renderToString, renderToStaticMarkup } from 'react-dom/server'; import AsyncRenderer from '../components/AsyncRenderer'; import removeDuplicateModules from '../utils/removeDuplicateModules'; const renderPass = (context, element, staticMarkup = false) => { context.callback = () => { if (context.finishedLoadingModules && !context.statesRenderPass) { context.statesRenderPass = true; context.renderResult = renderPass(context, element, staticMarkup); if (context.fetchingStates <= 0 && context.modulesLoading <= 0) { context.resolve({ html: context.renderResult, state: context.fetchStateResults === undefined ? null : context.fetchStateResults, modules: context.modules === undefined ? null : removeDuplicateModules(context.modules) }); } } else if (context.finishedLoadingModules && context.statesRenderPass || !context.hasModules) { context.renderResult = renderPass(context, element, staticMarkup); if (context.fetchingStates <= 0 && context.modulesLoading <= 0) { context.resolve({ html: context.renderResult, state: context.fetchStateResults === undefined ? null : context.fetchStateResults, modules: context.modules === undefined ? null : removeDuplicateModules(context.modules) }); } } }; let component = ( <AsyncRenderer context={context}> {element} </AsyncRenderer> ); let result; try { if (staticMarkup) { result = renderToStaticMarkup(component); } else { result = renderToString(component); } } catch (e) { return context.reject(e); } if (!context.hasModules && !context.hasStates) { context.resolve({ html: result, state: context.fetchStateResults === undefined ? null : context.fetchStateResults, modules: context.modules === undefined ? null : removeDuplicateModules(context.modules) }); } return result; }; export default renderPass;
docs/app/Examples/elements/Input/States/InputExampleError.js
aabustamante/Semantic-UI-React
import React from 'react' import { Input } from 'semantic-ui-react' const InputExampleError = () => ( <Input error placeholder='Search...' /> ) export default InputExampleError
data-browser-ui/public/app/components/headerComponents/filterRowComponent.js
CloudBoost/cloudboost
import React from 'react' import { observer } from "mobx-react" import configObject from '../../config/app.js' @observer class FilterRow extends React.Component { constructor(){ super() this.state = { } } componentWillMount(){ } setDataType(e){ let types = configObject.filterTypes.filter((x)=>{ return x.type.indexOf(e.target.options[e.target.options.selectedIndex].getAttribute('type')) != -1 }) this.props.changeHandler('filterTypes',types[0].options,this.props.filterData.id) if(e.target.options[e.target.options.selectedIndex].getAttribute('data-relatedTo')){ this.props.changeHandler('relatedTo',e.target.options[e.target.options.selectedIndex].getAttribute('data-relatedTo'),this.props.filterData.id) if(types[0].notContains.indexOf(e.target.options[e.target.options.selectedIndex].getAttribute('data-relatedTo')) != -1){ this.props.changeHandler('filterTypes',types[0].optionsNotContains,this.props.filterData.id) } } this.props.changeHandler('columnType',e.target.options[e.target.options.selectedIndex].getAttribute('type'),this.props.filterData.id) this.props.changeHandler('filterType','',this.props.filterData.id) this.props.changeHandler('dataType',e.target.value,this.props.filterData.id) } setType(e){ this.props.changeHandler('selectedType',e.target.value,this.props.filterData.id) } setFilterType(e){ this.props.changeHandler('filterType',e.target.value,this.props.filterData.id) } setDataValue(ischeckbox,e){ let value = e.target.value if(ischeckbox) value = e.target.checked if(this.props.filterData.columnType === 'Number'){ value = parseInt(value) } this.props.changeHandler('dataValue',value,this.props.filterData.id) } setListDataValue(e){ let value = e.target.nextSibling.value if(value){ this.props.changeHandler('listDataValue',value,this.props.filterData.id) } e.target.nextSibling.value = null } removeListDataValue(index){ this.props.removeListDataValue(index,this.props.filterData.id) } getInputType(props){ let inputType // if filtertype selected is exists or doesnotexists then return disabled input if(['exists','doesNotExists'].indexOf(props.filterData.filterType) !== -1){ return <input type="text" className="inputfilter" disabled="true" style={{visibility:'hidden'}}/> } // if no filtertype selected then return disabled input if(!props.filterData.filterType){ return <input type="text" className="inputfilter" disabled="true"/> } if(props.filterData.columnType){ if(['Text','Email','URL','EncryptedText'].indexOf(props.filterData.columnType) != -1){ inputType = <input type="text" className="inputfilter" value={ props.filterData.dataValue } onChange={ this.setDataValue.bind(this,false) }/> } else if(['Number'].indexOf(props.filterData.columnType) != -1){ inputType = <input type="number" className="inputfilter" value={ props.filterData.dataValue } onChange={ this.setDataValue.bind(this,false) }/> } else if(['DateTime'].indexOf(props.filterData.columnType) != -1){ inputType = <input type="date" className="inputfilter" value={ props.filterData.dataValue } onChange={ this.setDataValue.bind(this,false) }/> } else if(['Boolean'].indexOf(props.filterData.columnType) != -1){ inputType = <input type="checkbox" className="inputfilter boolfilter" checked={ props.filterData.dataValue } onChange={ this.setDataValue.bind(this,true) }/> } else if(['List'].indexOf(props.filterData.columnType) != -1){ inputType = this.getListInput(props) } else { inputType = <input type="text" className="inputfilter" disabled="true"/> } } else { inputType = <input type="text" className="inputfilter" disabled="true"/> } return inputType } getListInput(props){ let inputType if(props.filterData.relatedTo){ if(['Text','Email','URL','EncryptedText','Number'].indexOf(props.filterData.relatedTo) != -1){ inputType = <div className="listfilterrows"> <i className="fa fa-plus listfilteradd" aria-hidden="true" onClick={ this.setListDataValue.bind(this) }></i> <input type="text" className="inputfilterlist"/> { this.props.filterData.listDataValue.map((x,i)=>{ return <div className="divadditionallist" key={ i }> <i className="fa fa-minus minuslist" aria-hidden="true" onClick={ this.removeListDataValue.bind(this,i) }></i> <input type="text" className="inputfilterlistValues" value={ x } disabled="true" /> </div> }) } </div> } else if(['DateTime'].indexOf(props.filterData.relatedTo) != -1){ inputType = <div className="listfilterrows"> <i className="fa fa-plus listfilteradd" aria-hidden="true" onClick={ this.setListDataValue.bind(this) }></i> <input type="date" className="inputfilterlist"/> { this.props.filterData.listDataValue.map((x,i)=>{ return <div className="divadditionallist" key={ i }> <i className="fa fa-minus minuslist" aria-hidden="true" onClick={ this.removeListDataValue.bind(this,i) }></i> <input type="date" className="inputfilterlistValues" value={ x } disabled="true" /> </div> }) } </div> } else { inputType = <input type="text" className="inputfilter" disabled="true" value={ props.filterData.dataValue } onChange={ this.setDataValue.bind(this,false) }/> } } else { inputType = <input type="text" className="inputfilter" disabled="true" value={ props.filterData.dataValue } onChange={ this.setDataValue.bind(this,false) }/> } return inputType } render() { let dataTypes = this.props.tableStore.getColumns .filter((x)=>{ return !(x.dataType == 'Id' || x.dataType == 'ACL') }) .map((data,i)=>{ if(data.dataType == 'List'){ return <option key={ i } value={ data.name } type={ data.dataType } data-relatedTo={ data.relatedTo }>{ data.name }</option> } else { return <option key={ i } value={ data.name } type={ data.dataType }>{ data.name }</option> } }) let type = this.props.filterData.type.map((x,i)=>{ return <option key={ i } value={ x }>{ x }</option> }) let filterTypes = this.props.filterData.filterTypes.map((data,i)=>{ return <option key={ i } value={ data }>{ data }</option> }) let inputType = this.getInputType(this.props) return ( <div className="filterrow"> <select className="form-control selectfilter" value={ this.props.filterData.selectedType } onChange={ this.setType.bind(this) }> { type } </select> <select className="form-control selectfilter" value={ this.props.filterData.dataType } onChange={ this.setDataType.bind(this) }> <option value=''>-select-</option> { dataTypes } </select> <select className="form-control selectfilter" value={ this.props.filterData.filterType } onChange={ this.setFilterType.bind(this) }> { filterTypes } </select> { inputType } <i onClick={ this.props.deleteFilter.bind(this,this.props.filterData.id) } className="fa fa-close filterclose" aria-hidden="true"></i> </div> ); } } export default FilterRow