path
stringlengths
5
195
repo_name
stringlengths
5
79
content
stringlengths
25
1.01M
src/PageItem.js
insionng/react-bootstrap
import React from 'react'; import classNames from 'classnames'; import SafeAnchor from './SafeAnchor'; const PageItem = React.createClass({ propTypes: { href: React.PropTypes.string, target: React.PropTypes.string, title: React.PropTypes.string, disabled: React.PropTypes.bool, previous: React.PropTypes.bool, next: React.PropTypes.bool, onSelect: React.PropTypes.func, eventKey: React.PropTypes.any }, getDefaultProps() { return { disabled: false, previous: false, next: false }; }, render() { let classes = { 'disabled': this.props.disabled, 'previous': this.props.previous, 'next': this.props.next }; return ( <li {...this.props} className={classNames(this.props.className, classes)}> <SafeAnchor href={this.props.href} title={this.props.title} target={this.props.target} onClick={this.handleSelect}> {this.props.children} </SafeAnchor> </li> ); }, handleSelect(e) { if (this.props.onSelect || this.props.disabled) { e.preventDefault(); if (!this.props.disabled) { this.props.onSelect(this.props.eventKey, this.props.href, this.props.target); } } } }); export default PageItem;
examples/full-example/src/isomorphic/base/components/header.js
yahoo/mendel
/* Copyright 2015, Yahoo Inc. Copyrights licensed under the MIT License. See the accompanying LICENSE file for terms. */ import React from 'react'; class Header extends React.Component { render() { return <header>AWESOME APP TITLE</header>; } } export default Header;
src/index.js
bottledsmoke/react-transform-boilerplate
import React from 'react'; import { App } from './App'; React.render(<App />, document.getElementById('root'));
src/client.js
vidaaudrey/avanta
/** * THIS IS THE ENTRY POINT FOR THE CLIENT, JUST LIKE server.js IS THE ENTRY POINT FOR THE SERVER. */ import 'babel/polyfill'; import React from 'react'; import ReactDOM from 'react-dom'; import createHistory from 'history/lib/createBrowserHistory'; import useScroll from 'scroll-behavior/lib/useStandardScroll'; import createStore from './redux/create'; import ApiClient from './helpers/ApiClient'; import io from 'socket.io-client'; import {Provider} from 'react-redux'; import {reduxReactRouter, ReduxRouter} from 'redux-router'; import getRoutes from './routes'; import makeRouteHooksSafe from './helpers/makeRouteHooksSafe'; const client = new ApiClient(); // Three different types of scroll behavior available. // Documented here: https://github.com/rackt/scroll-behavior const scrollableHistory = useScroll(createHistory); const dest = document.getElementById('content'); const store = createStore(reduxReactRouter, makeRouteHooksSafe(getRoutes), scrollableHistory, client, window.__data); function initSocket() { const socket = io('', {path: '/api/ws', transports: ['polling']}); socket.on('news', (data) => { console.log(data); socket.emit('my other event', { my: 'data from client' }); }); socket.on('msg', (data) => { console.log(data); }); return socket; } global.socket = initSocket(); const component = ( <ReduxRouter routes={getRoutes(store)} /> ); ReactDOM.render( <Provider store={store} key="provider"> {component} </Provider>, dest ); if (process.env.NODE_ENV !== 'production') { window.React = React; // enable debugger if (!dest || !dest.firstChild || !dest.firstChild.attributes || !dest.firstChild.attributes['data-react-checksum']) { console.error('Server-side React render was discarded. Make sure that your initial render does not contain any client-side code.'); } } if (__DEVTOOLS__ && !window.devToolsExtension) { const DevTools = require('./containers/DevTools/DevTools'); ReactDOM.render( <Provider store={store} key="provider"> <div> {component} <DevTools /> </div> </Provider>, dest ); }
molgenis-core-ui/src/main/javascript/modules/react-components/jobs/RunningJobs.js
marieke-bijlsma/molgenis
/** * Renders a ProgressBar component for each job passed down from its parent * component * * @module RunningJobs * * @param jobs * An array of job objects with status RUNNING * * @exports RunningJobs class */ import React from 'react'; import { Job } from './Job'; import DeepPureRenderMixin from '../mixin/DeepPureRenderMixin'; var RunningJobs = React.createClass({ mixins: [DeepPureRenderMixin], displayName: 'RunningJobs', propTypes : { jobs : React.PropTypes.array.isRequired, onSelect: React.PropTypes.func }, render: function() { const {jobs, onSelect} = this.props; return <div className="panel panel-primary"> <div className="panel-heading">Running Jobs</div> <div className="panel-body"> {jobs.map(function(job){ return <Job job={job} key={job.identifier} onClick={() => onSelect(job.identifier)} />; })} </div> </div>; } }); export { RunningJobs }; export default React.createFactory(RunningJobs);
admin/client/App/shared/Popout/PopoutList.js
sendyhalim/keystone
/** * Render a popout list. Can also use PopoutListItem and PopoutListHeading */ import React from 'react'; import blacklist from 'blacklist'; import classnames from 'classnames'; const PopoutList = React.createClass({ displayName: 'PopoutList', propTypes: { children: React.PropTypes.node.isRequired, className: React.PropTypes.string, }, render () { const className = classnames('PopoutList', this.props.className); const props = blacklist(this.props, 'className'); return ( <div className={className} {...props} /> ); }, }); module.exports = PopoutList; // expose the child to the top level export module.exports.Item = require('./PopoutListItem'); module.exports.Heading = require('./PopoutListHeading');
packages/wix-style-react/src/ModalSelectorLayout/docs/examples.js
wix/wix-style-react
import React from 'react'; export const single = ` () => { const DATA_SOURCE = (searchQuery, offset, limit) => new Promise(resolve => setTimeout(() => { const items = Array(50) .fill(0) .map((_, i) => ({ id: i, title: \`Title \${i}\`, subtitle: \`Subtitle \${i}\`, extraText: \`Extra Text \${i}\`, disabled: !(i % 2), image: ( <img width="100%" height="100%" src="http://via.placeholder.com/100x100" /> ), })); const filtered = items.filter(({ title }) => title.toLowerCase().startsWith(searchQuery.toLowerCase()), ); resolve({ items: filtered.slice(offset, offset + limit), totalCount: filtered.length, }); }, 2000), ); return ( <ModalSelectorLayout height="540px" itemsPerPage={4} onCancel={() => 'canceled'} onOk={function onOk(data) { const isArray = Array.isArray(data), view = function view(i) { return { id: i.id, title: i.title, subtitle: i.substitle }; }; return JSON.stringify(isArray ? data.map(view) : view(data)); }} searchDebounceMs={150} dataSource={DATA_SOURCE} /> ); }; `; export const multi = ` () => { const DATA_SOURCE = (searchQuery, offset, limit) => new Promise(resolve => setTimeout(() => { const items = Array(50) .fill(0) .map((_, i) => ({ id: i, title: \`Title \${i}\`, subtitle: \`Subtitle \${i}\`, extraText: \`Extra Text \${i}\`, disabled: !(i % 2), image: ( <img width="100%" height="100%" src="http://via.placeholder.com/100x100" /> ), })); const filtered = items.filter(({ title }) => title.toLowerCase().startsWith(searchQuery.toLowerCase()), ); resolve({ items: filtered.slice(offset, offset + limit), totalCount: filtered.length, }); }, 2000), ); return ( <ModalSelectorLayout multiple height="540px" itemsPerPage={4} onCancel={() => 'canceled'} onOk={function onOk(data) { const isArray = Array.isArray(data), view = function view(i) { return { id: i.id, title: i.title, subtitle: i.substitle }; }; return JSON.stringify(isArray ? data.map(view) : view(data)); }} searchDebounceMs={150} dataSource={DATA_SOURCE} /> ); }; `;
js/components/inputgroup/regular.js
bengaara/simbapp
import React, { Component } from 'react'; import { connect } from 'react-redux'; import { actions } from 'react-native-navigation-redux-helpers'; import { Container, Header, Title, Content, Button, Icon, Text, Body, Left, Right, Input, Item } from 'native-base'; import { Actions } from 'react-native-router-flux'; import styles from './styles'; const { popRoute, } = actions; class Regular extends Component { static propTypes = { popRoute: React.PropTypes.func, navigation: React.PropTypes.shape({ key: React.PropTypes.string, }), } popRoute() { this.props.popRoute(this.props.navigation.key); } render() { return ( <Container style={styles.container}> <Header> <Left> <Button transparent onPress={() => Actions.pop()}> <Icon name="arrow-back" /> </Button> </Left> <Body> <Title>Regular</Title> </Body> <Right /> </Header> <Content padder> <Item regular> <Input placeholder="Regular Textbox" /> </Item> </Content> </Container> ); } } function bindAction(dispatch) { return { popRoute: key => dispatch(popRoute(key)), }; } const mapStateToProps = state => ({ navigation: state.cardNavigation, themeState: state.drawer.themeState, }); export default connect(mapStateToProps, bindAction)(Regular);
src/TVShowInstance.js
AndrewCMartin/idb
import React from 'react' import { Link } from 'react-router-dom' import {Row, Col} from 'react-bootstrap' var axios = require('axios'); {/* Responsible for styling the content in the body */} class TVShowInstance extends React.Component { constructor(props) { super(props); {/* Store tv show info we get from query */} this.state = { tv_show: {} }; } componentDidMount() { {/* Query and store all data */} return axios.get("http://marvelus.me/api/tv_show/" + window.location.href.substring(window.location.href.lastIndexOf("/") + 1) ).then(res=> { const tv_show = res.data; this.setState({tv_show}); }); } render() { {/* Make containers for characters, actors to store the relationship to this model */} const characters = this.state.tv_show.characters || []; const actors = this.state.tv_show.actors || []; return ( <div class="container" style={{backgroundColor: 'black', margin: 'auto', height:'100'}}> <div class="instance"> <div class="panel" > <div class="panel-heading"> <h1>{this.state.tv_show.name}</h1> </div> <div class="panel-body"> <Row> {/* Information/attributes of the show */} <Col xs={5} md={5}> <img src={"https://image.tmdb.org/t/p/w500/" + this.state.tv_show.poster_path} class="img-responsive" class="img-responsive img-center" styles='width:100%' alt="Image" /> </Col> <Col xs={7} md={7}> <h3>Overview</h3> <p>{this.state.tv_show.overview}</p> <h3>Number of Seasons</h3> <p>{this.state.tv_show.num_seasons}</p> <h3>Number of Episodes</h3> <p>{this.state.tv_show.num_episodes}</p> <h3>Last Air Date</h3> <p>{this.state.tv_show.last_air_date}</p> <h3>Rating</h3> <p>{this.state.tv_show.rating}</p> </Col> </Row> <hr></hr> <Row> <Col xs={6} md={6}> {/* Goes through the data in the character lists, and makes linkable */} <h4>Characters</h4> <ul> {characters.length > 0 ? characters.map(function(character) { return (<li key={character.name}style={{color:'#d3d1d1'}}><Link to={`/character/${character.id}`}style={{color:'#ed2f2f', fontSize: '17px'}}>{character.name}</Link></li>) }) : <li>None</li>} </ul> </Col> <Col xs={6} md={6}> <h4>Actors</h4> <ul> {actors.length > 0 ? actors.map(function(actor) { return (<li key={actor.name}style={{color:'#d3d1d1'}}><Link to={`/actor/${actor.id}`}style={{color:'#ed2f2f', fontSize: '17px'}}>{actor.name}</Link></li>) }) : <li>None</li>} </ul> </Col> </Row> </div> </div> </div> </div> ); } } export default TVShowInstance
src/containers/app.js
ebn646/redux-google-maps
import React, { Component } from 'react'; import PropTypes from 'prop-types'; import Map from './map'; import List from './list'; import Header from '../components/header'; import Footer from '../components/footer'; import DropDown from './dropdown-list'; import { bindActionCreators } from 'redux'; import { connect } from 'react-redux'; import * as actions from '../actions'; require('../../style/main.scss'); class App extends Component { constructor(props){ super(props) this.state={ center:{ lat: 40.722938, lng: -74.007821, }, zoom:16 } } componentWillMount(){ this.props.onGetLocations(); } componentWillReceiveProps(nextProps){ if(nextProps.category !== this.props.category){ this.props.onGetLocations(nextProps.category); } if(nextProps.latlng !== this.props.latlng){ this.setState({ center:{ lat: nextProps.latlng.lat, lng: nextProps.latlng.lng, }, }) } } render() { return ( <div className="app" style={{background:'#f5f5f5'}}> <div className="row" > <Header {...this.props}/> </div> <div className="row main-container" > <div className="map-holder" className="col-md-8 col-md-push-4 no-padd"> <Map {...this.props} zoom={this.state.zoom} center={this.state.center}/> </div> <div className="list-holder" className="col-md-4 col-md-pull-8 no-padd"> <List {...this.props}/> </div> </div> <div className="row footer" > <Footer /> </div> </div> ); } } function mapStateToProps({venues,category,latlng}){ return{ venues, category, latlng } } function mapDispatchToProps(dispatch){ return bindActionCreators(actions,dispatch) } export default connect(mapStateToProps,mapDispatchToProps)(App);
src/SplitButton.js
cgvarela/react-bootstrap
import React from 'react'; import BootstrapMixin from './BootstrapMixin'; import Button from './Button'; import Dropdown from './Dropdown'; import SplitToggle from './SplitToggle'; class SplitButton extends React.Component { render() { let { children, title, onClick, target, href, // bsStyle is validated by 'Button' component bsStyle, // eslint-disable-line ...props } = this.props; let { disabled } = props; let button = ( <Button onClick={onClick} bsStyle={bsStyle} disabled={disabled} target={target} href={href} > {title} </Button> ); return ( <Dropdown {...props}> {button} <SplitToggle aria-label={title} bsStyle={bsStyle} disabled={disabled} /> <Dropdown.Menu> {children} </Dropdown.Menu> </Dropdown> ); } } SplitButton.propTypes = { ...Dropdown.propTypes, ...BootstrapMixin.propTypes, /** * @private */ onClick() {}, target: React.PropTypes.string, href: React.PropTypes.string, /** * The content of the split button. */ title: React.PropTypes.node.isRequired }; SplitButton.defaultProps = { disabled: false, dropup: false, pullRight: false }; SplitButton.Toggle = SplitToggle; export default SplitButton;
src/svg-icons/action/settings-phone.js
spiermar/material-ui
import React from 'react'; import pure from 'recompose/pure'; import SvgIcon from '../../SvgIcon'; let ActionSettingsPhone = (props) => ( <SvgIcon {...props}> <path d="M13 9h-2v2h2V9zm4 0h-2v2h2V9zm3 6.5c-1.25 0-2.45-.2-3.57-.57-.35-.11-.74-.03-1.02.24l-2.2 2.2c-2.83-1.44-5.15-3.75-6.59-6.58l2.2-2.21c.28-.27.36-.66.25-1.01C8.7 6.45 8.5 5.25 8.5 4c0-.55-.45-1-1-1H4c-.55 0-1 .45-1 1 0 9.39 7.61 17 17 17 .55 0 1-.45 1-1v-3.5c0-.55-.45-1-1-1zM19 9v2h2V9h-2z"/> </SvgIcon> ); ActionSettingsPhone = pure(ActionSettingsPhone); ActionSettingsPhone.displayName = 'ActionSettingsPhone'; ActionSettingsPhone.muiName = 'SvgIcon'; export default ActionSettingsPhone;
src/components/inbox/InboxItem.js
metasfresh/metasfresh-webui-frontend
import counterpart from 'counterpart'; import Moment from 'moment'; import React, { Component } from 'react'; import PropTypes from 'prop-types'; /** * @file Class based component. * @module InboxItem * @extends Component */ class InboxItem extends Component { constructor(props) { super(props); } /** * @method renderIconFromTarget * @summary ToDo: Describe the method * @param {*} target * @todo Write the documentation */ renderIconFromTarget = (target) => { switch (target) { case '143': return 'sales'; default: return 'system'; } }; /** * @method componentDidMount * @summary ToDo: Describe the method * @todo Write the documentation */ componentDidMount() { document.getElementsByClassName('js-inbox-wrapper')[0].focus(); } /** * @method renderCancelButton * @summary ToDo: Describe the method * @param {event} event * @todo Write the documentation */ handleKeyDown = (e) => { const { close } = this.props; switch (e.key) { case 'ArrowDown': e.preventDefault(); if (document.activeElement.nextSibling) { document.activeElement.nextSibling.focus(); } break; case 'ArrowUp': e.preventDefault(); if (document.activeElement.previousSibling) { document.activeElement.previousSibling.focus(); } break; case 'Enter': e.preventDefault(); document.activeElement.click(); break; case 'Escape': e.preventDefault(); close && close(); break; } }; /** * @method render * @summary ToDo: Describe the method * @todo Write the documentation */ render() { const { item, onClick, onDelete } = this.props; return ( <div onClick={onClick} onKeyDown={this.handleKeyDown} tabIndex={0} className={ 'inbox-item js-inbox-item pointer ' + (!item.read ? 'inbox-item-unread ' : '') } > {item.important && ( <div className="inbox-item-icon inbox-item-icon-sm"> <i className="meta-icon-important" /> </div> )} <div className="inbox-item-icon"> <i className={ 'meta-icon-' + this.renderIconFromTarget(item.target && item.target.documentType) } /> </div> <div className="inbox-item-content"> <div className="inbox-item-title">{item.message}</div> <div className="inbox-item-footer"> <div title={Moment(item.timestamp).format('DD.MM.YYYY HH:mm:ss')}> {Moment(item.timestamp).fromNow()} </div> <div> <a href="javascript:void(0)" className="inbox-item-delete" onClick={onDelete} > {counterpart.translate('window.Delete.caption')} </a> <span>Notification</span> </div> </div> </div> </div> ); } } /** * @typedef {object} Props Component props * @prop {*} [close] * @prop {*} [item] * @prop {*} [onClick] * @prop {*} [onDelete] * @todo Check props. Which proptype? Required or optional? */ InboxItem.propTypes = { close: PropTypes.any, item: PropTypes.any, onClick: PropTypes.any, onDelete: PropTypes.any, }; export default InboxItem;
docs/src/app/pages/components/Checkbox/ExampleCheckboxDefault.js
GetAmbassador/react-ions
import React from 'react' import Checkbox from 'react-ions/lib/components/Checkbox' const ExampleCheckboxDefault = () => ( <Checkbox label='Default checkbox' value={false} /> ) export default ExampleCheckboxDefault
src/index.js
Greynight/rebelle
import React from 'react'; import ReactDOM from 'react-dom'; import './index.css'; import App from './App'; ReactDOM.render(<App />, document.getElementById('root'));
example/posts.js
marmelab/admin-on-rest
import React from 'react'; import { BooleanField, BooleanInput, CheckboxGroupInput, ChipField, Create, CreateButton, Datagrid, DateField, DateInput, DisabledInput, Edit, EditButton, Filter, FormTab, ImageField, ImageInput, List, LongTextInput, NumberField, NumberInput, ReferenceArrayField, ReferenceManyField, ReferenceArrayInput, RefreshButton, Responsive, RichTextField, SaveButton, SelectArrayInput, SelectField, SelectInput, Show, ShowButton, SimpleForm, SimpleList, SingleFieldList, Tab, TabbedForm, TabbedShowLayout, TextField, TextInput, Toolbar, minValue, number, required, translate, } from 'admin-on-rest'; // eslint-disable-line import/no-unresolved import { CardActions } from 'material-ui/Card'; import RichTextInput from 'aor-rich-text-input'; import Chip from 'material-ui/Chip'; import BookIcon from 'material-ui/svg-icons/action/book'; // eslint-disable-line import/no-unresolved export const PostIcon = BookIcon; const QuickFilter = translate(({ label, translate }) => ( <Chip style={{ marginBottom: 8 }}>{translate(label)}</Chip> )); const PostFilter = props => ( <Filter {...props}> <TextInput label="post.list.search" source="q" alwaysOn /> <TextInput source="title" defaultValue="Qui tempore rerum et voluptates" /> <ReferenceArrayInput source="tags" reference="tags" defaultValue={[3]}> <SelectArrayInput optionText="name" /> </ReferenceArrayInput> <QuickFilter label="resources.posts.fields.commentable" source="commentable" defaultValue /> </Filter> ); const titleFieldStyle = { maxWidth: '20em', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap', }; const cardActionStyle = { zIndex: 2, display: 'inline-block', float: 'right', }; const PostActions = ({ resource, filters, displayedFilters, filterValues, basePath, showFilter, }) => ( <CardActions style={cardActionStyle}> {filters && React.cloneElement(filters, { resource, showFilter, displayedFilters, filterValues, context: 'button', })} <CreateButton basePath={basePath} /> <RefreshButton /> </CardActions> ); export const PostList = props => ( <List {...props} actions={<PostActions />} filters={<PostFilter />} sort={{ field: 'published_at', order: 'DESC' }} > <Responsive small={ <SimpleList primaryText={record => record.title} secondaryText={record => `${record.views} views`} tertiaryText={record => new Date(record.published_at).toLocaleDateString()} /> } medium={ <Datagrid> <TextField source="id" /> <TextField source="title" style={titleFieldStyle} /> <DateField source="published_at" style={{ fontStyle: 'italic' }} /> <BooleanField source="commentable" label="resources.posts.fields.commentable_short" /> <NumberField source="views" /> <ReferenceArrayField label="Tags" reference="tags" source="tags" > <SingleFieldList> <ChipField source="name" /> </SingleFieldList> </ReferenceArrayField> <EditButton /> <ShowButton /> </Datagrid> } /> </List> ); const PostTitle = translate(({ record, translate }) => ( <span> {record ? translate('post.edit.title', { title: record.title }) : ''} </span> )); const PostCreateToolbar = props => ( <Toolbar {...props}> <SaveButton label="post.action.save_and_show" redirect="show" submitOnEnter={true} /> <SaveButton label="post.action.save_and_add" redirect={false} submitOnEnter={false} raised={false} /> </Toolbar> ); const getDefaultDate = () => new Date(); const validate = values => { const errors = {}; ['title', 'teaser'].forEach(field => { if (!values[field]) { errors[field] = ['Required field']; } }); if (values.average_note < 0 || values.average_note > 5) { errors.average_note = ['Should be between 0 and 5']; } return errors; }; export const PostCreate = props => ( <Create {...props}> <SimpleForm toolbar={<PostCreateToolbar />} defaultValue={{ average_note: 0 }} validate={validate} > <TextInput source="title" /> <TextInput source="password" type="password" /> <TextInput source="teaser" options={{ multiLine: true }} /> <RichTextInput source="body" /> <DateInput source="published_at" defaultValue={getDefaultDate} /> <NumberInput source="average_note" /> <BooleanInput source="commentable" defaultValue /> </SimpleForm> </Create> ); const emptyKeycode = []; const validateAverageNote = [required, number, minValue(0)]; export const PostEdit = props => ( <Edit title={<PostTitle />} {...props}> <TabbedForm defaultValue={{ average_note: 0 }}> <FormTab label="post.form.summary"> <DisabledInput source="id" /> <TextInput source="title" validate={required} /> <CheckboxGroupInput source="notifications" choices={[ { id: 12, name: 'Ray Hakt' }, { id: 31, name: 'Ann Gullar' }, { id: 42, name: 'Sean Phonee' }, ]} /> <LongTextInput source="teaser" validate={required} /> <ImageInput multiple source="pictures" accept="image/*"> <ImageField source="src" title="title" /> </ImageInput> </FormTab> <FormTab label="post.form.body"> <RichTextInput source="body" label="" validate={required} addLabel={false} /> </FormTab> <FormTab label="post.form.miscellaneous"> <ReferenceArrayInput source="tags" reference="tags" allowEmpty> <SelectArrayInput optionText="name" options={{ fullWidth: true, newChipKeyCodes: emptyKeycode, }} /> </ReferenceArrayInput> <DateInput source="published_at" options={{ locale: 'pt' }} /> <SelectInput source="category" choices={[ { name: 'Tech', id: 'tech' }, { name: 'Lifestyle', id: 'lifestyle' }, ]} /> <NumberInput source="average_note" validate={validateAverageNote} /> <BooleanInput source="commentable" defaultValue /> <DisabledInput source="views" /> </FormTab> <FormTab label="post.form.comments"> <ReferenceManyField reference="comments" target="post_id" addLabel={false} > <Datagrid> <DateField source="created_at" /> <TextField source="author.name" /> <TextField source="body" /> <EditButton /> </Datagrid> </ReferenceManyField> </FormTab> </TabbedForm> </Edit> ); export const PostShow = props => ( <Show title={<PostTitle />} {...props}> <TabbedShowLayout> <Tab label="post.form.summary"> <TextField source="id" /> <TextField source="title" /> <TextField source="teaser" /> </Tab> <Tab label="post.form.body"> <RichTextField source="body" stripTags={false} label="" addLabel={false} /> </Tab> <Tab label="post.form.miscellaneous"> <ReferenceArrayField reference="tags" source="tags"> <SingleFieldList> <ChipField source="name" /> </SingleFieldList> </ReferenceArrayField> <DateField source="published_at" /> <SelectField source="category" choices={[ { name: 'Tech', id: 'tech' }, { name: 'Lifestyle', id: 'lifestyle' }, ]} /> <NumberField source="average_note" /> <BooleanField source="commentable" /> <TextField source="views" /> </Tab> <Tab label="post.form.comments"> <ReferenceManyField label="resources.posts.fields.comments" reference="comments" target="post_id" sort={{ field: 'created_at', order: 'DESC' }} > <Datagrid selectable={false}> <DateField source="created_at" /> <TextField source="author.name" /> <TextField source="body" /> <EditButton /> </Datagrid> </ReferenceManyField> </Tab> </TabbedShowLayout> </Show> );
js/routes/historyView/historyView.js
GoldenOwlAsia/cooking-app
import React, { Component } from 'react'; import { TouchableOpacity, Image } from 'react-native'; import { Container, Header, Title, Content, Text, Button, Icon } from 'native-base'; import { Grid, Row, Col } from 'react-native-easy-grid'; import myTheme from '../../themes/base-theme'; import styles from './styles'; class HistoryView extends Component { /* 1. constructor */ constructor (props) { super(props); } /* 2. render */ render() { return ( <Container theme={myTheme} style={styles.container}> <Header style = {{backgroundColor : '#8D6437'}}> <Button transparent onPress={this.props.openDrawer}> <Icon name="ios-menu" /> </Button> <Title> HISTORY </Title> </Header> <Content> </Content> </Container> ) } /* Method Action */ pushRoute(route, url,foodName) { this.props.pushRoute({ key: route, index: 1 }, this.props.navigation.key) } } export default HistoryView;
src/app/elements/grids/PrimaryGrid.js
cchamberlain/redux-webpack-boilerplate
import React from 'react' //import Griddle from 'griddle-overhaul-react-redux' //import { context } from 'app/redux/components/griddle' export default props => <div id="grid-goes-here" />// <Griddle context={context('primary')} />
app/routes.js
shibe97/worc
import React, { Component } from 'react'; import { HashRouter as Router, Route } from 'react-router-dom'; import App from './containers/Modules/App'; export default class Routes extends Component { render() { return ( <Router> <Route component={App} path="/" /> </Router> ); } }
src/routes/contact/index.js
siddhant3s/crunchgraph
/** * React Starter Kit (https://www.reactstarterkit.com/) * * Copyright © 2014-2016 Kriasoft, LLC. All rights reserved. * * This source code is licensed under the MIT license found in the * LICENSE.txt file in the root directory of this source tree. */ import React from 'react'; import 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>, }; }, };
example4/index.ios.js
hbarve1/react-native-examples
/** * Sample React Native App * https://github.com/facebook/react-native * @flow */ import React, { Component } from 'react'; import { AppRegistry } from 'react-native'; import Js from "./js"; const example4 = () => <Js/>; export default example4; AppRegistry.registerComponent('example4', () => example4);
sundin/index.android.js
tkfeng/mppCalc
/** * Sample React Native App * https://github.com/facebook/react-native * @flow */ import React, { Component } from 'react'; import { AppRegistry, StyleSheet, Text, View } from 'react-native'; export default class sundin extends Component { render() { return ( <View style={styles.container}> <Text style={styles.welcome}> Welcome to React Native! </Text> <Text style={styles.instructions}> To get started, edit index.android.js </Text> <Text style={styles.instructions}> Double tap R on your keyboard to reload,{'\n'} Shake or press menu button for dev menu </Text> </View> ); } } const styles = StyleSheet.create({ container: { flex: 1, justifyContent: 'center', alignItems: 'center', backgroundColor: '#F5FCFF', }, welcome: { fontSize: 20, textAlign: 'center', margin: 10, }, instructions: { textAlign: 'center', color: '#333333', marginBottom: 5, }, }); AppRegistry.registerComponent('sundin', () => sundin);
client/modules/Todo/__tests__/components/TodoListItem.spec.js
saltykovdg/mern-react-redux-nodejs-express-todo-list
import React from 'react'; import test from 'ava'; import sinon from 'sinon'; import TodoListItem from '../../components/TodoListItem/TodoListItem'; import { mountWithIntl, shallowWithIntl } from '../../../../util/react-intl-test-helper'; import { FormattedMessage } from 'react-intl'; const todo = { text: 'test1', completed: true, cuid: '57ebb7264363d32380e94356' }; const props = { todo, onComplete: () => {}, }; test('renders properly', t => { const wrapper = shallowWithIntl(<TodoListItem {...props} />); t.truthy(wrapper.hasClass('li_style')); t.truthy(wrapper.find('button').find('.btn .btn-link .btn-xs').containsMatchingElement(<FormattedMessage id="todoToggleStatus" />)); t.truthy(wrapper.find('.done_true').containsMatchingElement(todo.text)); }); test('has correct props', t => { const wrapper = mountWithIntl(<TodoListItem {...props} />); t.deepEqual(wrapper.prop('todo'), props.todo); t.is(wrapper.prop('onClick'), props.onClick); t.is(wrapper.prop('onComplete'), props.onComplete); }); test('calls onComplete', t => { const onComplete = sinon.spy(); const wrapper = shallowWithIntl( <TodoListItem todo={todo} onComplete={onComplete} /> ); wrapper.find('.btn .btn-link .btn-xs').first().simulate('click'); t.truthy(onComplete.calledOnce); });
src/icons/AndroidShare.js
fbfeix/react-icons
import React from 'react'; import IconBase from './../components/IconBase/IconBase'; export default class AndroidShare extends React.Component { render() { if(this.props.bare) { return <g> <g id="Icon_17_"> <g> <path d="M448,248L288,96v85.334C138.666,202.667,85.333,309.334,64,416c53.333-74.666,117.333-108.802,224-108.802v87.469L448,248 z"></path> </g> </g> </g>; } return <IconBase> <g id="Icon_17_"> <g> <path d="M448,248L288,96v85.334C138.666,202.667,85.333,309.334,64,416c53.333-74.666,117.333-108.802,224-108.802v87.469L448,248 z"></path> </g> </g> </IconBase>; } };AndroidShare.defaultProps = {bare: false}
frontend/app_v2/src/components/Topics/TopicsPresentation.js
First-Peoples-Cultural-Council/fv-web-ui
import React from 'react' import PropTypes from 'prop-types' import TopicsPresentationTopic from 'components/Topics/TopicsPresentationTopic' import SectionTitle from 'components/SectionTitle' import Slider from 'components/Slider' function TopicsPresentation({ title, topics }) { return ( <section className="py-12 bg-white" data-testid="TopicsPresentationWidget"> <div className="mx-10 mb-4"> <SectionTitle.Presentation title={title} /> </div> <div className="hidden lg:grid gap-y-10 gap-x-14 grid-cols-4 mx-10 mt-5"> {topics.map((topic, index) => { const key = `topic${index}` return <TopicsPresentationTopic key={key} topic={topic} /> })} </div> <div className="mx-10 block lg:hidden"> <Slider.Container items={topics} topics /> </div> </section> ) } // PROPTYPES const { array, string } = PropTypes TopicsPresentation.propTypes = { topics: array, title: string, } export default TopicsPresentation
client/src/app/routes/settings/containers/FeeStructures/FeeStructuresPage.js
zraees/sms-project
/** * Created by griga on 11/30/15. */ import React from 'react' import axios from 'axios' import {SubmissionError} from 'redux-form' import {connect} from 'react-redux' import moment from 'moment' import Loader, {Visibility as LoaderVisibility} from '../../../../components/Loader/Loader' import WidgetGrid from '../../../../components/widgets/WidgetGrid' import JarvisWidget from '../../../../components/widgets/JarvisWidget' import Datatable from '../../../../components/tables/Datatable' import Msg from '../../../../components/i18n/Msg' import Moment from '../../../../components/utils/Moment' import FeeStructureForm from './FeeStructureForm' import EditGeneralInfo from './EditGeneralInfo' import submit, {remove} from './submit' import mapForCombo, {getWebApiRootUrl, instanceAxios} from '../../../../components/utils/functions' class FeeStructuresPages extends React.Component { constructor(props){ super(props); this.state = { feeTypeId: 0 } } componentWillMount() { LoaderVisibility(true); } componentDidMount(){ console.log('componentDidMount --> FeeStructuresPages'); $('#FeeStructureGrid').on('click', 'td', function(event) { if ($(this).find('#dele').length > 0) { var id = $(this).find('#dele').data('tid'); remove(id, $(this)); } }); // call before modal open $('#FeeStructurePopup').on('show.bs.modal', function (e) { var button = $(e.relatedTarget); // Button that triggered the modal var feeTypeId = button.data('id'); // Extract info from data-* attributes this.setState({feeTypeId}); }.bind(this)); // call on modal close $('#FeeStructurePopup').on('hidden.bs.modal', function (e) { this.setState({ feeTypeId: 0 }); var table = $('#FeeStructureGrid').DataTable(); table.clear(); table.ajax.reload(null, false); // user paging is not reset on reload }.bind(this)); LoaderVisibility(false); } render() { var self = this; return ( <div id="content"> <WidgetGrid> {/* START ROW */} <div className="row"> {/* NEW COL START */} <article className="col-sm-12 col-md-12 col-lg-12"> {/* Widget ID (each widget will need unique ID)*/} <JarvisWidget colorbutton={false} editbutton={false} color="blueLight" custombutton={false} deletebutton={false} > <header> <span className="widget-icon"> <i className="fa fa-edit"/> </span> <h2><Msg phrase="FeeStructures" /></h2> </header> {/* widget div*/} <div> {/* widget content */} <div className="widget-body no-padding"> <div className="widget-body-toolbar"> <div className="row"> <div className="col-xs-9 col-sm-5 col-md-5 col-lg-5"> </div> <div className="col-xs-3 col-sm-7 col-md-7 col-lg-7 text-right"> <button className="btn btn-primary" data-toggle="modal" data-target="#FeeStructurePopup"> <i className="fa fa-plus"/> <span className="hidden-mobile"><Msg phrase="AddNewText" /></span> </button> </div> </div> </div> <Loader isLoading={this.props.isLoading} /> <Datatable id="FeeStructureGrid" options={{ ajax: {"url": getWebApiRootUrl() +'/api/FeeStructures/All', "dataSrc": ""}, columnDefs: [ { // The `data` parameter refers to the data for the cell (defined by the // `data` option, which defaults to the column being worked with, in // this case `data: 0`. "render": function ( data, type, row ) { return '<a data-toggle="modal" data-id="' + data + '" data-target="#FeeStructurePopup"><i id="edi" class=\"glyphicon glyphicon-edit\"></i><span class=\"sr-only\">Edit</span></a>'; }, "className": "dt-center", "sorting": false, "targets": 8 } ,{ "render": function ( data, type, row ) { return '<a id="dele" data-tid="' + data + '"><i class=\"glyphicon glyphicon-trash\"></i><span class=\"sr-only\">Edit</span></a>'; }.bind(self), "className": "dt-center", "sorting": false, "targets": 9 } ], columns: [ {data: "FeeStructureID"}, {data: "ClassName"}, {data: "FeeTypeName"}, {data: "FeeCycleName"}, {data: "FeeDueOnFrequencyName"}, {data: "Fee"}, {data: "DiscountValue"}, {data: "NetFee"}, {data: "FeeStructureID"}, {data: "FeeStructureID"} ], buttons: [ 'copy', 'excel', 'pdf' ] }} paginationLength={true} className="table table-striped table-bordered table-hover" width="100%"> <thead> <tr> <th><Msg phrase="IDText"/></th> <th><Msg phrase="ClassText"/></th> <th><Msg phrase="FeeTypes"/></th> <th><Msg phrase="FeeCycleText"/></th> <th><Msg phrase="FeeDueOnFrequencyText"/></th> <th><Msg phrase="FeeText"/></th> <th><Msg phrase="DiscountValueText"/></th> <th><Msg phrase="FeeAmountAfterDiscountText"/></th> <th></th> <th></th> </tr> </thead> </Datatable> </div> {/* end widget content */} </div> {/* end widget div */} </JarvisWidget> {/* end widget */} </article> {/* END COL */} </div> {/* END ROW */} </WidgetGrid> {/* end widget grid */} <div className="modal fade" id="FeeStructurePopup" tabIndex="-1" role="dialog" data-backdrop="static" data-keyboard="false" aria-labelledby="FeeStructurePopupLabel" aria-hidden="true"> <div className="modal-dialog modal-lg"> <div className="modal-content"> <div className="modal-header"> <button type="button" className="close" data-dismiss="modal" aria-hidden="true"> &times; </button> <h4 className="modal-title" id="FeeStructurePopupLabel"> { this.state.feeTypeId > 0 ? <Msg phrase="ManageText" /> : <Msg phrase="AddNewText"/> } </h4> </div> <div className="modal-body"> { this.state.feeTypeId > 0 ? <EditGeneralInfo FeeTypeID={this.state.feeTypeId} onSubmit={submit} /> : <FeeStructureForm FeeTypeID={this.state.feeTypeId} onSubmit={submit} /> } </div> </div> {/* /.modal-content */} </div> {/* /.modal-dialog */} </div> {/* /.modal */} </div> ) } } export default FeeStructuresPages;
src/svg-icons/image/leak-remove.js
pomerantsev/material-ui
import React from 'react'; import pure from 'recompose/pure'; import SvgIcon from '../../SvgIcon'; let ImageLeakRemove = (props) => ( <SvgIcon {...props}> <path d="M10 3H8c0 .37-.04.72-.12 1.06l1.59 1.59C9.81 4.84 10 3.94 10 3zM3 4.27l2.84 2.84C5.03 7.67 4.06 8 3 8v2c1.61 0 3.09-.55 4.27-1.46L8.7 9.97C7.14 11.24 5.16 12 3 12v2c2.71 0 5.19-.99 7.11-2.62l2.5 2.5C10.99 15.81 10 18.29 10 21h2c0-2.16.76-4.14 2.03-5.69l1.43 1.43C14.55 17.91 14 19.39 14 21h2c0-1.06.33-2.03.89-2.84L19.73 21 21 19.73 4.27 3 3 4.27zM14 3h-2c0 1.5-.37 2.91-1.02 4.16l1.46 1.46C13.42 6.98 14 5.06 14 3zm5.94 13.12c.34-.08.69-.12 1.06-.12v-2c-.94 0-1.84.19-2.66.52l1.6 1.6zm-4.56-4.56l1.46 1.46C18.09 12.37 19.5 12 21 12v-2c-2.06 0-3.98.58-5.62 1.56z"/> </SvgIcon> ); ImageLeakRemove = pure(ImageLeakRemove); ImageLeakRemove.displayName = 'ImageLeakRemove'; ImageLeakRemove.muiName = 'SvgIcon'; export default ImageLeakRemove;
src/svg-icons/image/crop-rotate.js
mtsandeep/material-ui
import React from 'react'; import pure from 'recompose/pure'; import SvgIcon from '../../SvgIcon'; let ImageCropRotate = (props) => ( <SvgIcon {...props}> <path d="M7.47 21.49C4.2 19.93 1.86 16.76 1.5 13H0c.51 6.16 5.66 11 11.95 11 .23 0 .44-.02.66-.03L8.8 20.15l-1.33 1.34zM12.05 0c-.23 0-.44.02-.66.04l3.81 3.81 1.33-1.33C19.8 4.07 22.14 7.24 22.5 11H24c-.51-6.16-5.66-11-11.95-11zM16 14h2V8c0-1.11-.9-2-2-2h-6v2h6v6zm-8 2V4H6v2H4v2h2v8c0 1.1.89 2 2 2h8v2h2v-2h2v-2H8z"/> </SvgIcon> ); ImageCropRotate = pure(ImageCropRotate); ImageCropRotate.displayName = 'ImageCropRotate'; ImageCropRotate.muiName = 'SvgIcon'; export default ImageCropRotate;
app/components/categories/CategoryForm.js
jpsierens/budget
// @flow import React from 'react'; type Props = { onAddCategory: () => void } class CategoryForm extends React.Component { state = { category: '' }; props: Props; handleChange() { this.setState({ category: this.input.value }); } submit(e) { e.preventDefault(); this.props.onAddCategory({ name: this.state.category }); this.setState({ category: '' }); } render() { return ( <div> <label>Add a Category</label> { this.state.category } <input ref={(e) => { this.input = e; }} value={this.state.category} onChange={this.handleChange.bind(this)} /> <button onClick={this.submit.bind(this)}> Submit Category </button> </div> ); } } export default CategoryForm;
pkg/interface/publish/src/js/components/lib/note.js
ngzax/urbit
import React, { Component } from 'react'; import { Route, Link } from 'react-router-dom'; import { SidebarSwitcher } from './icons/icon-sidebar-switch'; import { Spinner } from './icons/icon-spinner'; import { Comments } from './comments'; import { NoteNavigation } from './note-navigation'; import moment from 'moment'; import ReactMarkdown from 'react-markdown'; import { cite } from '../../lib/util'; export class Note extends Component { constructor(props) { super(props); this.state = { deleting: false } moment.updateLocale('en', { relativeTime: { past: function(input) { return input === 'just now' ? input : input + ' ago' }, s : 'just now', future : 'in %s', m : '1m', mm : '%dm', h : '1h', hh : '%dh', d : '1d', dd : '%dd', M : '1 month', MM : '%d months', y : '1 year', yy : '%d years', } }); this.scrollElement = React.createRef(); this.onScroll = this.onScroll.bind(this); this.deletePost = this.deletePost.bind(this); } componentWillMount() { let readAction = { read: { who: this.props.ship.slice(1), book: this.props.book, note: this.props.note, } } window.api.action("publish", "publish-action", readAction); window.api.fetchNote(this.props.ship, this.props.book, this.props.note); } componentDidMount() { if (!(this.props.notebooks[this.props.ship]) || !(this.props.notebooks[this.props.ship][this.props.book]) || !(this.props.notebooks[this.props.ship][this.props.book].notes[this.props.note]) || !(this.props.notebooks[this.props.ship][this.props.book].notes[this.props.note].file)) { window.api.fetchNote(this.props.ship, this.props.book, this.props.note); } this.onScroll(); } componentDidUpdate(prevProps) { if (!(this.props.notebooks[this.props.ship]) || !(this.props.notebooks[this.props.ship][this.props.book]) || !(this.props.notebooks[this.props.ship][this.props.book].notes[this.props.note]) || !(this.props.notebooks[this.props.ship][this.props.book].notes[this.props.note].file)) { window.api.fetchNote(this.props.ship, this.props.book, this.props.note); } if ((prevProps.book !== this.props.book) || (prevProps.note !== this.props.note) || (prevProps.ship !== this.props.ship)) { let readAction = { read: { who: this.props.ship.slice(1), book: this.props.book, note: this.props.note, } } window.api.action("publish", "publish-action", readAction); } } onScroll() { let notebook = this.props.notebooks[this.props.ship][this.props.book]; let note = notebook.notes[this.props.note]; if (!note.comments) { return; } let scrollTop = this.scrollElement.scrollTop; let clientHeight = this.scrollElement.clientHeight; let scrollHeight = this.scrollElement.scrollHeight; let atBottom = false; if (scrollHeight - scrollTop - clientHeight < 40) { atBottom = true; } let loadedComments = note.comments.length; let allComments = note["num-comments"]; let fullyLoaded = (loadedComments === allComments); if (atBottom && !fullyLoaded) { window.api.fetchCommentsPage(this.props.ship, this.props.book, this.props.note, loadedComments, 30); } } deletePost() { const { props } = this; let deleteAction = { "del-note": { who: this.props.ship.slice(1), book: this.props.book, note: this.props.note, } } let popout = (props.popout) ? "popout/" : ""; let baseUrl = `/~publish/${popout}notebook/${props.ship}/${props.book}`; this.setState({deleting: true}); window.api.action("publish", "publish-action", deleteAction) .then(() => { props.history.push(baseUrl); }); } render() { const { props } = this; let notebook = props.notebooks[props.ship][props.book] || {}; let comments = notebook.notes[props.note].comments || false; let title = notebook.notes[props.note].title || ""; let author = notebook.notes[props.note].author || ""; let file = notebook.notes[props.note].file || ""; let date = moment(notebook.notes[props.note]["date-created"]).fromNow() || 0; let contact = !!(author.substr(1) in props.contacts) ? props.contacts[author.substr(1)] : false; let name = author; if (contact) { name = (contact.nickname.length > 0) ? contact.nickname : author; } if (name === author) { name = cite(author); } if (!file) { return null; } let newfile = file.slice(file.indexOf(';>')+2); let prevId = notebook.notes[props.note]["prev-note"] || null; let nextId = notebook.notes[props.note]["next-note"] || null; let prev = (prevId === null) ? null : { id: prevId, title: notebook.notes[prevId].title, date: moment(notebook.notes[prevId]["date-created"]).fromNow() } let next = (nextId === null) ? null : { id: nextId, title: notebook.notes[nextId].title, date: moment(notebook.notes[nextId]["date-created"]).fromNow() } let editPost = null; let editUrl = props.location.pathname + "/edit"; if (`~${window.ship}` === author) { editPost = <div className="dib"> <Link className="green2 f9" to={editUrl}>Edit</Link> <p className="dib f9 red2 ml2 pointer" onClick={(() => this.deletePost())}>Delete</p> </div> } let popout = (props.popout) ? "popout/" : ""; let hrefIndex = props.location.pathname.indexOf("/note/"); let publishsubStr = props.location.pathname.substr(hrefIndex); let popoutHref = `/~publish/popout${publishsubStr}`; let hiddenOnPopout = props.popout ? "" : "dib-m dib-l dib-xl"; let baseUrl = `/~publish/${popout}notebook/${props.ship}/${props.book}`; return ( <div className="h-100 overflow-y-scroll" onScroll={this.onScroll} ref={el => { this.scrollElement = el; }}> <div className="h-100 flex flex-column items-center pa4"> <div className="w-100 flex justify-center pb6"> <SidebarSwitcher popout={props.popout} sidebarShown={props.sidebarShown} /> <Link className="f9 w-100 w-90-m w-90-l mw6 tl" to={baseUrl}> {"<- Notebook index"} </Link> <Link to={popoutHref} className={"dn absolute right-1 top-1 " + hiddenOnPopout} target="_blank"> <img src="/~publish/popout.png" height={16} width={16} /> </Link> </div> <div className="w-100 mw6"> <div className="flex flex-column"> <div className="f9 mb1" style={{overflowWrap: "break-word"}}>{title}</div> <div className="flex mb6"> <div className={ "di f9 gray2 mr2 " + (contact.nickname ? null : "mono") } title={author}> {name} </div> <div className="di"> <span className="f9 gray2 dib">{date}</span><span className="ml2 dib">{editPost}</span></div> </div> </div> <div className="md" style={{overflowWrap: "break-word"}}> <ReactMarkdown source={newfile} linkTarget={"_blank"} /> </div> <NoteNavigation popout={props.popout} prev={prev} next={next} ship={props.ship} book={props.book} /> <Comments enabled={notebook.comments} ship={props.ship} book={props.book} note={props.note} comments={comments} contacts={props.contacts} /> <Spinner text="Deleting post..." awaiting={this.state.deleting} classes="absolute bottom-1 right-1 ba b--gray1-d pa2" /> </div> </div> </div> ); } } export default Note
src/components/CircleImage/CircleImage.js
RMCoder198/chat.susi.ai
import React, { Component } from 'react'; import PropTypes from 'prop-types'; /* Utils */ import initials from 'initials'; import addPx from 'add-px'; import contrast from 'contrast'; import './CircleImage.css'; const defaultColors = [ '#2ecc71', // emerald '#3498db', // peter river '#8e44ad', // wisteria '#e67e22', // carrot '#e74c3c', // alizarin '#1abc9c', // turquoise '#2c3e50', // midnight blue ]; function sumChars(str) { let sum = 0; for (let i = 0; i < str.length; i++) { sum += str.charCodeAt(i); } return sum; } export default class CircleImage extends Component { static propTypes = { borderRadius: PropTypes.string, src: PropTypes.string, srcset: PropTypes.string, name: PropTypes.string.isRequired, color: PropTypes.string, colors: PropTypes.array, size: PropTypes.string, style: PropTypes.object, className: PropTypes.string, }; static defaultProps = { colors: defaultColors, }; render() { const { src, srcset, name, color, colors, style, borderRadius = '100%', className, } = this.props; let size = addPx(this.props.size); let styles = { imageStyle: { display: 'block', borderRadius, }, innerStyle: { lineHeight: size, textAlign: 'center', overflow: 'initial', marginRight: 10, borderRadius, }, }; let { imageStyle, innerStyle } = styles; const nameInitials = initials(name); let innerElement, classes = [className, 'CircleImage']; if (size) { imageStyle.width = innerStyle.width = innerStyle.maxWidth = size; imageStyle.height = innerStyle.height = innerStyle.maxHeight = size; } if (src || srcset) { innerElement = ( <img className="CircleImage--img" style={imageStyle} src={src} srcSet={srcset} alt={name} /> ); } else { let backgroundColor = ''; if (color) { backgroundColor = color; } else { // Pick a deterministic color from the list const i = sumChars(name) % colors.length; backgroundColor = colors[i]; } innerStyle.backgroundColor = backgroundColor; classes.push(`CircleImage--${contrast(innerStyle.backgroundColor)}`); innerElement = nameInitials; } return ( <div aria-label={name} className={classes.join(' ')} style={style}> <div className="CircleImage--inner" style={innerStyle}> {innerElement} </div> </div> ); } }
lib/content/new-component.js
Archipelcorp/archrn-cli
"use strict"; module.exports = { comment: "\n/**\n * Generated With Arch CLI\n * https://github.com/Archipelcorp/archrn-cli\n * @flow\n */\n", head: "\n\nimport React, { Component } from 'react';\nimport {\nPlatform,\nStyleSheet,\nText,\nView\n} from 'react-native';\n\n\n", body: "\n render() {\n return (\n <View style={styles.container}>\n <Text style={styles.welcome}>\n Welcome to Your New Component!\n </Text>\n <Text style={styles.instructions}>\n To get started, edit this file\n </Text>\n </View>\n );\n }\n\n", tail: "\n\n}\n\nconst styles = StyleSheet.create({\n container: {\n flex: 1,\n justifyContent: 'center',\n alignItems: 'center',\n backgroundColor: '#F5FCFF',\n },\n welcome: {\n fontSize: 20,\n textAlign: 'center',\n margin: 10,\n },\n}); \n" };
docs/app/Examples/elements/Rail/Variations/RailExampleCloseVery.js
clemensw/stardust
import React from 'react' import { Grid, Image, Rail, Segment } from 'semantic-ui-react' const RailExampleCloseVery = () => ( <Grid centered columns={3}> <Grid.Column> <Segment> <Image src='http://semantic-ui.com/images/wireframe/paragraph.png' /> <Rail close='very' position='left'> <Segment>Left Rail Content</Segment> </Rail> <Rail close='very' position='right'> <Segment>Right Rail Content</Segment> </Rail> </Segment> </Grid.Column> </Grid> ) export default RailExampleCloseVery
app/javascript/mastodon/features/compose/components/action_bar.js
pinfort/mastodon
import React from 'react'; import ImmutablePropTypes from 'react-immutable-proptypes'; import PropTypes from 'prop-types'; import DropdownMenuContainer from '../../../containers/dropdown_menu_container'; import { defineMessages, injectIntl } from 'react-intl'; const messages = defineMessages({ edit_profile: { id: 'account.edit_profile', defaultMessage: 'Edit profile' }, pins: { id: 'navigation_bar.pins', defaultMessage: 'Pinned toots' }, preferences: { id: 'navigation_bar.preferences', defaultMessage: 'Preferences' }, follow_requests: { id: 'navigation_bar.follow_requests', defaultMessage: 'Follow requests' }, favourites: { id: 'navigation_bar.favourites', defaultMessage: 'Favourites' }, lists: { id: 'navigation_bar.lists', defaultMessage: 'Lists' }, blocks: { id: 'navigation_bar.blocks', defaultMessage: 'Blocked users' }, domain_blocks: { id: 'navigation_bar.domain_blocks', defaultMessage: 'Hidden domains' }, mutes: { id: 'navigation_bar.mutes', defaultMessage: 'Muted users' }, filters: { id: 'navigation_bar.filters', defaultMessage: 'Muted words' }, logout: { id: 'navigation_bar.logout', defaultMessage: 'Logout' }, bookmarks: { id: 'navigation_bar.bookmarks', defaultMessage: 'Bookmarks' }, }); export default @injectIntl class ActionBar extends React.PureComponent { static propTypes = { account: ImmutablePropTypes.map.isRequired, onLogout: PropTypes.func.isRequired, intl: PropTypes.object.isRequired, }; handleLogout = () => { this.props.onLogout(); } render () { const { intl } = this.props; let menu = []; menu.push({ text: intl.formatMessage(messages.edit_profile), href: '/settings/profile' }); menu.push({ text: intl.formatMessage(messages.preferences), href: '/settings/preferences' }); menu.push({ text: intl.formatMessage(messages.pins), to: '/pinned' }); menu.push(null); menu.push({ text: intl.formatMessage(messages.follow_requests), to: '/follow_requests' }); menu.push({ text: intl.formatMessage(messages.favourites), to: '/favourites' }); menu.push({ text: intl.formatMessage(messages.bookmarks), to: '/bookmarks' }); menu.push({ text: intl.formatMessage(messages.lists), to: '/lists' }); menu.push(null); menu.push({ text: intl.formatMessage(messages.mutes), to: '/mutes' }); menu.push({ text: intl.formatMessage(messages.blocks), to: '/blocks' }); menu.push({ text: intl.formatMessage(messages.domain_blocks), to: '/domain_blocks' }); menu.push({ text: intl.formatMessage(messages.filters), href: '/filters' }); menu.push(null); menu.push({ text: intl.formatMessage(messages.logout), action: this.handleLogout }); return ( <div className='compose__action-bar'> <div className='compose__action-bar-dropdown'> <DropdownMenuContainer items={menu} icon='chevron-down' size={16} direction='right' /> </div> </div> ); } }
client/routes.js
Captain-Million/Captain-Million
/* eslint-disable global-require */ import React from 'react'; import { Route, IndexRoute } from 'react-router'; import App from './modules/App/App'; import Home from './components/Home'; export default ( <Route path="/" component={App}> <IndexRoute component={Home} /> </Route> );
src/frontend/containers/user/admin/detail.js
PiTeam/garage-pi
import React, { Component } from 'react'; import { connect } from 'react-redux'; import { bindActionCreators } from 'redux'; import TextField from 'material-ui/lib/text-field'; import Paper from 'material-ui/lib/paper'; import Dialog from 'material-ui/lib/dialog'; import { browserHistory, Link } from 'react-router'; import FlatButton from 'material-ui/lib/flat-button'; import RaisedButton from 'material-ui/lib/raised-button'; import CustomCheckbox from 'components/custom-checkbox'; import { deleteUser, updateUser } from 'actions'; import { getAuthPropType, getDoorPropType, getUserPropType } from 'proptypes'; class UserDetail extends Component { constructor(props) { super(props); this._getActionButtons = this._getActionButtons.bind(this); this.handleCloseDeletionConfirmation = this.handleCloseDeletionConfirmation.bind(this); this.handleOpenDeletionConfirmation = this.handleOpenDeletionConfirmation.bind(this); this.handleDelete = this.handleDelete.bind(this); this._handleUpdate = this._handleUpdate.bind(this); this._handleCheck = this._handleCheck.bind(this); this._handleTextFieldChange = this._handleTextFieldChange.bind(this); this._selectUser = this._selectUser.bind(this); this.state = { confirmDeletion: false, user: undefined, userDoors: undefined, }; } componentWillMount() { this._selectUser(this.props); } componentWillReceiveProps(nextProps) { this._selectUser(nextProps); } getStyles() { return { h1: { marginBottom: '1em', }, paper: { padding: '1em', minWidth: '50%', maxWidth: '80%', margin: 'auto', marginBottom: '2em', }, link: { textDecoration: 'none', }, name: { fontSize: '18px', }, backButton: { float: 'left', }, deleteButton: { float: 'right', }, doors: { margin: '2em', marginBottom: '4em', }, activateButton: { bottom: '5em', left: '1em', right: '1em', position: 'absolute', }, bottomButtons: { bottom: '1em', left: '1em', right: '1em', position: 'absolute', }, }; } _selectUser(props) { const user = props.users.get('data').find(u => u.get('id') === props.params.userId); const userDoors = props.doors.get('data').map(door => ( door.set('checked', user.get('doors').indexOf(door.get('id')) !== -1) )); this.setState({ user, userDoors }); } _handleUpdate() { const doors = this.state.userDoors .filter(door => door.get('checked')) .map(door => door.get('id')); this.props.updateUser(this.state.user.set('doors', doors), this.props.auth.get('token')); browserHistory.push('/manage/user'); } _handleTextFieldChange(e) { this.setState({ user: this.state.user.set('name', e.target.value) }); } handleDelete() { this.props.deleteUser(this.state.user, this.props.auth.get('token')); browserHistory.push('/manage/user'); } _handleCheck(id, value) { const index = this.state.userDoors.findIndex(door => door.get('id') === id); const userDoors = this.state.userDoors.update(index, door => door.set('checked', value)); this.setState({ userDoors }); } handleCloseDeletionConfirmation() { return this.setState({ confirmDeletion: false }); } handleOpenDeletionConfirmation() { return this.setState({ confirmDeletion: true }); } _getActionButtons() { return [ <FlatButton key="cancel" label="Cancel" onTouchTap={this.handleCloseDeletionConfirmation} secondary />, <FlatButton key="delete" label="Submit" onTouchTap={this.handleDelete} primary />, ]; } render() { const styles = this.getStyles(); if (!this.state.user) { return <div />; } return ( <div> <h1 style={styles.h1}>{'Manage User Details'}</h1> <TextField floatingLabelText="Username" hintText="Username" onChange={this._handleTextFieldChange} style={styles.name} value={this.state.user.get('name')} /> <div style={styles.doors}> <h3 style={styles.h3}>{'Allowed doors'}</h3> <Paper style={styles.paper}> {this.state.userDoors.map((door, i) => ( <CustomCheckbox checked={door.get('checked')} key={i} label={door.get('name')} name={door.get('key')} item={door} onCheckFn={this._handleCheck} style={styles.checkbox} /> ))} </Paper> <Dialog actions={this._getActionButtons()} modal onRequestClose={this.handleCloseDeletionConfirmation} open={this.state.confirmDeletion} title="Confirm deletion of user" > {'Are you sure you want to delete this user?'} </Dialog> <div style={styles.activateButton}> <Link to={`/manage/user/${this.state.user.get('name')}/activate`}> <RaisedButton label="Activate user by QRCode" secondary /> </Link> </div> <div style={styles.bottomButtons}> <Link to="/manage/user"> <RaisedButton label="Back" style={styles.backButton} /> </Link> <RaisedButton label="Save" onTouchTap={this._handleUpdate} primary /> <RaisedButton label="Delete" onTouchTap={this.handleOpenDeletionConfirmation} primary style={styles.deleteButton} /> </div> </div> </div> ); } } function mapStateToProps(state) { return { users: state.users, doors: state.doors, }; } function mapDispatchToProps(dispatch) { return bindActionCreators({ deleteUser, updateUser }, dispatch); } export default connect(mapStateToProps, mapDispatchToProps)(UserDetail); UserDetail.propTypes = { auth: getAuthPropType(), deleteUser: React.PropTypes.func.isRequired, doors: getDoorPropType(), params: React.PropTypes.shape({ userId: React.PropTypes.string.isRequired, }), updateUser: React.PropTypes.func.isRequired, users: getUserPropType(), };
src/components/bar/listProducts.js
jollopre/beverage_planning
import React, { Component } from 'react'; import PropTypes from 'prop-types'; import ListItemProduct from './listItemProduct'; export default class ListProducts extends Component { render() { const { list } = this.props; return ( <div> {list.map(item => (<ListItemProduct key={item.product.id} productPrice={item} />))} </div> ); } } ListProducts.propTypes = { list: PropTypes.array.isRequired, };
src/components/App.js
nicolascine/site
/** * React Starter Kit (https://www.reactstarterkit.com/) * * Copyright © 2014-present Kriasoft, LLC. All rights reserved. * * This source code is licensed under the MIT license found in the * LICENSE.txt file in the root directory of this source tree. */ import React from 'react'; import PropTypes from 'prop-types'; const ContextType = { // Enables critical path CSS rendering // https://github.com/kriasoft/isomorphic-style-loader insertCss: PropTypes.func.isRequired, // Universal HTTP client fetch: PropTypes.func.isRequired, }; /** * The top-level React component setting context (global) variables * that can be accessed from all the child components. * * https://facebook.github.io/react/docs/context.html * * Usage example: * * const context = { * history: createBrowserHistory(), * store: createStore(), * }; * * ReactDOM.render( * <App context={context}> * <Layout> * <LandingPage /> * </Layout> * </App>, * container, * ); */ class App extends React.PureComponent { static propTypes = { context: PropTypes.shape(ContextType).isRequired, children: PropTypes.element.isRequired, }; static childContextTypes = ContextType; getChildContext() { return this.props.context; } render() { // NOTE: If you need to add or modify header, footer etc. of the app, // please do that inside the Layout component. return React.Children.only(this.props.children); } } export default App;
src/scripts/components/Users/UserModal.js
Joywok/Joywok-Mobility-Framework
import React, { Component } from 'react'; import { Modal, Form, Input } from 'antd'; import styles from './UserModal.css'; const FormItem = Form.Item; class UserEditModal extends Component { constructor(props) { super(props); this.state = { visible: false, }; } showModelHandler = (e) => { if (e) e.stopPropagation(); this.setState({ visible: true, }); }; hideModelHandler = () => { this.setState({ visible: false, }); }; okHandler = () => { const { onOk } = this.props; this.props.form.validateFields((err, values) => { if (!err) { onOk(values); this.hideModelHandler(); } }); }; render() { const { children } = this.props; const { getFieldDecorator } = this.props.form; const { name, email, website } = this.props.record; const formItemLayout = { labelCol: { span: 6 }, wrapperCol: { span: 14 }, }; return ( <span> <span onClick={this.showModelHandler}> { children } </span> <Modal title="Edit User" visible={this.state.visible} onOk={this.okHandler} onCancel={this.hideModelHandler} > <Form horizontal onSubmit={this.okHandler}> <FormItem {...formItemLayout} label="Name" > { getFieldDecorator('name', { initialValue: name, })(<Input />) } </FormItem> <FormItem {...formItemLayout} label="Email" > { getFieldDecorator('email', { initialValue: email, })(<Input />) } </FormItem> <FormItem {...formItemLayout} label="Website" > { getFieldDecorator('website', { initialValue: website, })(<Input />) } </FormItem> </Form> </Modal> </span> ); } } export default Form.create()(UserEditModal);
src/svg-icons/av/add-to-queue.js
ichiohta/material-ui
import React from 'react'; import pure from 'recompose/pure'; import SvgIcon from '../../SvgIcon'; let AvAddToQueue = (props) => ( <SvgIcon {...props}> <path d="M21 3H3c-1.11 0-2 .89-2 2v12c0 1.1.89 2 2 2h5v2h8v-2h5c1.1 0 1.99-.9 1.99-2L23 5c0-1.11-.9-2-2-2zm0 14H3V5h18v12zm-5-7v2h-3v3h-2v-3H8v-2h3V7h2v3h3z"/> </SvgIcon> ); AvAddToQueue = pure(AvAddToQueue); AvAddToQueue.displayName = 'AvAddToQueue'; AvAddToQueue.muiName = 'SvgIcon'; export default AvAddToQueue;
src/svg-icons/action/theaters.js
pomerantsev/material-ui
import React from 'react'; import pure from 'recompose/pure'; import SvgIcon from '../../SvgIcon'; let ActionTheaters = (props) => ( <SvgIcon {...props}> <path d="M18 3v2h-2V3H8v2H6V3H4v18h2v-2h2v2h8v-2h2v2h2V3h-2zM8 17H6v-2h2v2zm0-4H6v-2h2v2zm0-4H6V7h2v2zm10 8h-2v-2h2v2zm0-4h-2v-2h2v2zm0-4h-2V7h2v2z"/> </SvgIcon> ); ActionTheaters = pure(ActionTheaters); ActionTheaters.displayName = 'ActionTheaters'; ActionTheaters.muiName = 'SvgIcon'; export default ActionTheaters;
frontend/src/components/SearchInput.js
daGrevis/msks
import fp from 'lodash/fp' import React from 'react' import '../styles/SearchInput.css' class SearchInput extends React.Component { inputNode = null componentDidMount() { if (fp.isEmpty(this.props.query)) { this.inputNode.focus() } } render() { return ( <div className="SearchInput"> <input className="nick-input" placeholder="Nick" value={this.props.query.nick || ''} onChange={ev => { this.props.inputSearch({ nick: ev.target.value }) }} spellCheck={false} autoCapitalize="none" /> <input ref={node => { this.inputNode = node }} className="text-input" placeholder="Search Text" value={this.props.query.text || ''} onChange={ev => { this.props.inputSearch({ text: ev.target.value }) }} spellCheck={false} autoCapitalize="none" /> </div> ) } } export default SearchInput
src/components/GKM/Category.js
oded-soffrin/gkm_viewer
import React from 'react'; import _ from 'lodash' const Category = ({ category }) => { const items = _.map(category.items, (i) => (<div style={{ display: 'inline-block', padding: '10px' }}>{i.type == 'product' ? i.name : i.text}</div>)) console.log(category.items); return ( <div> <div> {category.type}: {category.text} </div> <div>Items:</div> {items} </div> ) }; /* Item.propTypes = { }; */ export default Category
components/Layout/Header.js
leo60228/HouseRuler
/** * React Static Boilerplate * https://github.com/kriasoft/react-static-boilerplate * * Copyright © 2015-present Kriasoft, LLC. All rights reserved. * * This source code is licensed under the MIT license found in the * LICENSE.txt file in the root directory of this source tree. */ import React from 'react'; import Navigation from './Navigation'; import Link from '../Link'; import s from './Header.css'; class Header extends React.Component { componentDidMount() { window.componentHandler.upgradeElement(this.root); } componentWillUnmount() { window.componentHandler.downgradeElements(this.root); } render() { return ( <header className={`mdl-layout__header ${s.header}`} ref={node => (this.root = node)}> <div className={`mdl-layout__header-row ${s.row}`}> <Link className={`mdl-layout-title ${s.title}`} to="/"> HouseRuler </Link> <div className="mdl-layout-spacer" /> <Navigation /> </div> </header> ); } } export default Header;
src/routes/Counter/components/Counter.js
robertcasanova/personal-website
import React from 'react' export const Counter = (props) => ( <div style={{ margin: '0 auto' }} > <h2>Counter: {props.counter}</h2> <button className='btn btn-default' onClick={props.increment}> Increment </button> {' '} <button className='btn btn-default' onClick={props.doubleAsync}> Double (Async) </button> </div> ) Counter.propTypes = { counter : React.PropTypes.number.isRequired, doubleAsync : React.PropTypes.func.isRequired, increment : React.PropTypes.func.isRequired } export default Counter
dashboard/src/components/dashboard/ServiceRow.js
leapfrogtechnology/chill
import React from 'react'; import moment from 'moment'; import PropTypes from 'prop-types'; import ToolTip from 'react-tooltip'; import { getServiceStatus, getServiceParams } from '../../services/status'; /** * Render each service row. * * @param {Object} data */ const ServiceRow = ({ data }) => { const service = JSON.parse(data.service); const status = JSON.parse(data.status); const tooltipId = `tooltip-service-${service.id}`; const { message, icon } = getServiceParams(getServiceStatus(status)); return ( <div className="components-item"> <div className="col-one component-name">{service.name}</div> <div className="col col-two list-item-tooltip"> <img src={icon} className="status-icon" data-tip aria-hidden="true" data-for={tooltipId} /> </div> <ToolTip place="top" id={tooltipId} type="dark"> <span>{message} since {moment(status.createdAt).fromNow()}</span> </ToolTip> </div> ); }; ServiceRow.propTypes = { data: PropTypes.object }; export default ServiceRow;
packages/react-scripts/fixtures/kitchensink/src/features/syntax/RestAndDefault.js
amido/create-react-app
/** * Copyright (c) 2015-present, Facebook, Inc. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ import React, { Component } from 'react'; import PropTypes from 'prop-types'; function load({ id, ...rest } = { id: 0, user: { id: 42, name: '42' } }) { return [ { id: id + 1, name: '1' }, { id: id + 2, name: '2' }, { id: id + 3, name: '3' }, rest.user, ]; } export default class extends Component { static propTypes = { onReady: PropTypes.func.isRequired, }; constructor(props) { super(props); this.state = { users: [] }; } async componentDidMount() { const users = load(); this.setState({ users }); } componentDidUpdate() { this.props.onReady(); } render() { return ( <div id="feature-rest-and-default"> {this.state.users.map(user => <div key={user.id}>{user.name}</div>)} </div> ); } }
client/src/post/PostList.js
atkien/demo-react
/** * PostList.js * * @description :: Post List: renders HTML elements of `Post List`. * @docs :: http:// */ import React, { Component } from 'react'; import { Link } from 'react-router'; import _ from 'lodash'; import moment from 'moment'; import { Glyphicon, ListGroup, ListGroupItem, Panel } from 'react-bootstrap'; class PostList extends Component { constructor(props) { super(props); this.removePost = this.removePost.bind(this); } componentWillMount() { this.props.fetchPosts(); } // Making sure that the Component updating happens ONLY by the conditions shouldComponentUpdate(nextProps, nextState) { const { posts } = nextProps.postsList; return (posts && _.size(posts) > 0) ? true : false; } removePost() { const postId = this.props.postsList.posts[0].id; this.props.deletePost(postId); window.location.reload(); } renderPosts(posts) { return posts.map((post) => { let createdDate = moment(new Date(post.createdAt)).format('MMM DD, YYYY HH:mm'); return ( <ListGroupItem key={post.id}> <Link style={{color:'black'}} to={"posts/" + post.id + "/detail"}> <h3 className="list-group-item-heading">{post.title}</h3> </Link> <h5 className="list-group-item-heading">by {post.creator}</h5> <h5 className="list-group-item-heading created-date"><Glyphicon glyph='time' /> {createdDate}</h5> </ListGroupItem> ) }); } render() { const { posts, loading, error } = this.props.postsList; const postBlock = (_.size(posts) > 0) ? this.renderPosts(posts) : 'No posts found.'; if(loading) { return <div className="container"><h1>Posts</h1><h3>Loading...</h3></div> } else if(error) { return <div className="alert alert-danger">Error: {error.message}</div> } return ( <div className="container bs-example"> <Panel header="Latest Posts"> <ListGroup> {postBlock} </ListGroup> </Panel> </div> ); } } export default PostList;
app/components/SignIn/index.js
theClubhouse-Augusta/JobWeasel-FrontEnd
/** * * SignIn * */ import React from 'react'; import './style.css'; import './styleM.css'; import LeftIcon from 'react-icons/lib/fa/chevron-left'; import RightIcon from 'react-icons/lib/fa/chevron-right'; export default class SignIn extends React.PureComponent { constructor(props) { super(props); this.state = { email:"", password: "", notificationTwo:"", open: this.props.open } } handleEmail = (event) => { this.setState({ email:event.target.value }) } handlePassword = (event) => { this.setState({ password:event.target.value }) } enterKey = (event) => { var key = event.keyCode; if (key === 13) { this.signIn(); } } signIn =() => { let data = new FormData; let _this = this; data.append('email', this.state.email); data.append('password', this.state.password); fetch('http://localhost:8000/api/signIn', { method:'Post', body:data }) .then(function(response) { return response.json(); }) .then(function(json) { if(json.error) { _this.setState({ notificationTwo: json.error }) } else { _this.setState({ notificationTwo: json.success }) console.log(json.token); sessionStorage.setItem('token', json.token); sessionStorage.setItem('user', JSON.stringify(json.user)); setTimeout(function(){ let user = JSON.parse(sessionStorage.getItem('user')); let url = '/Profile/' + user.id; _this.context.router.history.push(url); }, 500) } }.bind(this)) } render() { if(this.props.open === true) { return ( <div> <div className="signInFullContainer"> <div className="signInUnderlay" onClick={this.props.onClose}> </div> <div className="signInContainer"> <div className="signInInput"> <h3>Sign in to Job Weasel</h3> <input type="text" className="emailSignIn" value={this.state.email} onChange={this.handleEmail} placeholder="E-mail"/> <input type="password" className="passwordSignIn" value={this.state.password} onKeyDown={this.enterKey} onChange={this.handlePassword} placeholder="Password"/> <input type="submit" className="signInButton button" placeholder="Sign-In" onClick={this.signIn} /> <p className="submitNote">{this.state.notificationTwo}</p> </div> </div> </div> </div> ); } else { return (<div className="renuiDialogOverlayHidden"></div> ); } } } SignIn.contextTypes = { router: React.PropTypes.object };
app/screens/StartupScreen.js
MPDL/LabCam
import React, { Component } from 'react'; import { View, Image, StyleSheet } from 'react-native'; import CamColors from '../common/CamColors'; import LaunchIcon from '../images/launchScreen.png'; const styles = StyleSheet.create({ container: { flex: 1, justifyContent: 'center', alignItems: 'center', backgroundColor: CamColors.colorWithAlpha('green2', 1), }, pic: { width: 280, height: 200, resizeMode: 'cover', }, }); class StartupContainer extends Component { render() { return ( <View style={styles.container}> <Image style={styles.pic} source={LaunchIcon} /> </View> ); } } export default StartupContainer;
public/js/components/comments/CommentBox.react.js
MadushikaPerera/Coupley
import React from 'react'; import CommentAction from '../../actions/ActivityFeed/CommentAction'; import CommentList from './CommentList.react'; import CommentForm from './CommentForm.react'; var CommentBox = React.createClass({ render: function() { return ( <div> <CommentList /> </div> ); } }); export default CommentBox;
src/server.js
w10036w/ReactTest
/*! React Starter Kit | MIT License | http://www.reactstarterkit.com/ */ import 'babel-core/polyfill'; import path from 'path'; import express from 'express'; import React from 'react'; import ReactDOM from 'react-dom/server'; import Router from './routes'; import Html from './components/Html'; const server = global.server = express(); server.set('port', (process.env.PORT || 5000)); server.use(express.static(path.join(__dirname, 'public'))); // // Register API middleware // ----------------------------------------------------------------------------- server.use('/api/content', require('./api/content')); // // Register server-side rendering middleware // ----------------------------------------------------------------------------- server.get('*', async (req, res, next) => { try { let statusCode = 200; const data = { title: '', description: '', css: '', body: '' }; const css = []; const context = { onInsertCss: value => css.push(value), onSetTitle: value => data.title = value, onSetMeta: (key, value) => data[key] = value, onPageNotFound: () => statusCode = 404, }; await Router.dispatch({ path: req.path, context }, (state, component) => { data.body = ReactDOM.renderToString(component); data.css = css.join(''); }); const html = ReactDOM.renderToStaticMarkup(<Html {...data} />); res.status(statusCode).send('<!doctype html>\n' + html); } catch (err) { next(err); } }); // // Launch the server // ----------------------------------------------------------------------------- server.listen(server.get('port'), () => { /* eslint-disable no-console */ console.log('The server is running at http://localhost:' + server.get('port')); if (process.send) { process.send('online'); } });
client-src/components/home/Home.js
minimus/final-task
import React from 'react' import SearchBar from '../../containers/searchbar/SearchBarContainer' import logo from './logo.png' import './home.css' export default function Home() { return ( <section className="home-container"> <div className="home-elements-container"> <div className="logo-container"> <img id="logo" src={logo} srcSet="images/logo-retina.png 2x" alt="HappySearch" title="HappySearch" /> </div> <SearchBar /> </div> </section> ) }
app/containers/ProcessViewPage/components/CoilImmersion/index.js
BrewPi/brewpi-ui
import React from 'react'; import styles from './styles.css'; import { Liquids } from '../Liquids'; import { pickLiquid } from '../Flows'; const SvgCoil = require('./svg/coil.svg?tag=g'); const SvgLiquidCoil = require('./svg/liquid_coil.svg?tag=g'); import { SvgParent } from '../SvgParent'; export class CoilImmersion extends React.Component { static flows = () => ([ [{ t: 'b', b: 't' }, { t: 'b', b: 't' }], [{ t: 'r', r: 't' }, { t: 'l', l: 't' }], ]); render() { let liquid; if (this.props.flows !== undefined) { liquid = pickLiquid(this.props.flows[0][0]); } return ( <SvgParent viewBox={'0 0 100 100'}> <SvgLiquidCoil className={styles.liquid} style={Liquids.strokeStyle(liquid)} /> <SvgCoil className={styles.coil} /> </SvgParent> ); } } CoilImmersion.propTypes = { flows: React.PropTypes.arrayOf( React.PropTypes.arrayOf( React.PropTypes.arrayOf( React.PropTypes.object ) ) ), };
stories/examples/ClipboardExample.js
TeamWertarbyte/material-ui-chip-input
import React from 'react' import ChipInput from '../../src/ChipInput' class ClipboardExample extends React.Component { constructor (props) { super(props) this.state = { chips: [] } } handleAdd (...chips) { this.setState({ chips: [...this.state.chips, ...chips] }) } handleDelete (deletedChip) { this.setState({ chips: this.state.chips.filter((c) => c !== deletedChip) }) } render () { return ( <ChipInput {...this.props} hintText='Paste anything here (try with line breaks)' value={this.state.chips} onPaste={(event) => { const clipboardText = event.clipboardData.getData('Text') event.preventDefault() this.handleAdd(...clipboardText.split('\n').filter((t) => t.length > 0)) if (this.props.onPaste) { this.props.onPaste(event) } }} onAdd={(chip) => this.handleAdd(chip)} onDelete={(deletedChip) => this.handleDelete(deletedChip)} fullWidth /> ) } } export default ClipboardExample
src/svg-icons/content/content-paste.js
andrejunges/material-ui
import React from 'react'; import pure from 'recompose/pure'; import SvgIcon from '../../SvgIcon'; let ContentContentPaste = (props) => ( <SvgIcon {...props}> <path d="M19 2h-4.18C14.4.84 13.3 0 12 0c-1.3 0-2.4.84-2.82 2H5c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm-7 0c.55 0 1 .45 1 1s-.45 1-1 1-1-.45-1-1 .45-1 1-1zm7 18H5V4h2v3h10V4h2v16z"/> </SvgIcon> ); ContentContentPaste = pure(ContentContentPaste); ContentContentPaste.displayName = 'ContentContentPaste'; ContentContentPaste.muiName = 'SvgIcon'; export default ContentContentPaste;
examples/todos/src/components/App.js
bvasko/redux
import React from 'react' import Footer from './Footer' import AddTodo from '../containers/AddTodo' import VisibleTodoList from '../containers/VisibleTodoList' const App = () => ( <div> <AddTodo /> <VisibleTodoList /> <Footer /> </div> ) export default App
src/components/PaginationItem.js
nullgr4vity/react-redux-table
import React from 'react'; class PaginationItem extends React.Component { constructor(props) { super(props); this.onClick = this.onClick.bind(this); } onClick() { if (this.props.status !== PaginationItem.PLACEBO) { return; } this.props.onClick(this.props.pid); } render() { const { value, status } = this.props; return ( <li className={status} onClick={this.onClick}> <a>{value}</a> </li> ); } } PaginationItem.PREV_LABEL = '\u00ab'; PaginationItem.NEXT_LABEL = '\u00bb'; PaginationItem.DISABLED = 'disabled'; PaginationItem.ACTIVE = 'active'; PaginationItem.PLACEBO = ''; PaginationItem.propTypes = { value: React.PropTypes.string, status: React.PropTypes.string, onClick: React.PropTypes.func }; PaginationItem.defaultProps = { type: PaginationItem.ITEM, status: PaginationItem.PLACEBO, onClick: () => {} }; export default PaginationItem;
app/components/Spinner/index.js
theterra/newsb
import React from 'react'; import SpinnerStyle from './SpinnerStyle'; class Spinner extends React.Component { // eslint-disable-line react/prefer-stateless-function render() { const { color, statusText} = this.props; return ( <SpinnerStyle color={color}><i></i><i></i></SpinnerStyle> ); } } export default Spinner;
src/routes/appbar/index.js
ChrisWC/MaterL
import React from 'react'; import AppbarRoute from './Appbar'; import fetch from '../../core/fetch'; export default { path: '/appbar', async action() { return <AppbarRoute />; }, };
django/webcode/webcode/frontend/node_modules/react-bootstrap/es/Jumbotron.js
OpenKGB/webcode
import _extends from 'babel-runtime/helpers/extends'; import _objectWithoutProperties from 'babel-runtime/helpers/objectWithoutProperties'; import _classCallCheck from 'babel-runtime/helpers/classCallCheck'; import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn'; import _inherits from 'babel-runtime/helpers/inherits'; import React from 'react'; import classNames from 'classnames'; import elementType from 'prop-types-extra/lib/elementType'; import { bsClass, getClassSet, splitBsProps } from './utils/bootstrapUtils'; var propTypes = { componentClass: elementType }; var defaultProps = { componentClass: 'div' }; var Jumbotron = function (_React$Component) { _inherits(Jumbotron, _React$Component); function Jumbotron() { _classCallCheck(this, Jumbotron); return _possibleConstructorReturn(this, _React$Component.apply(this, arguments)); } Jumbotron.prototype.render = function render() { var _props = this.props, Component = _props.componentClass, className = _props.className, props = _objectWithoutProperties(_props, ['componentClass', 'className']); var _splitBsProps = splitBsProps(props), bsProps = _splitBsProps[0], elementProps = _splitBsProps[1]; var classes = getClassSet(bsProps); return React.createElement(Component, _extends({}, elementProps, { className: classNames(className, classes) })); }; return Jumbotron; }(React.Component); Jumbotron.propTypes = propTypes; Jumbotron.defaultProps = defaultProps; export default bsClass('jumbotron', Jumbotron);
src/components/containers/insurance/taipingyang-insurance-container.js
HuangXingBin/goldenEast
import React from 'react'; import { Button, AutoComplete ,DatePicker } from 'antd'; import TaiPingYangInsuranceView from '../../views/insurance/taipingyang-insurance-view'; import { connect } from 'react-redux'; import SearchInput from '../../views/SearchInput'; import store from '../../../store'; import { updataTaiPingYangInsuranceSearch } from '../../../actions/app-interaction-actions'; import { getTaiPingYangInsuranceData } from '../../../api/app-interaction-api'; const RangePicker = DatePicker.RangePicker; var TaiPingYangInsuranceContainer = React.createClass({ getInitialState() { return { loading: false, } }, componentDidMount() { const _this = this; this.setState({ loading: true }); getTaiPingYangInsuranceData({},function(info){ _this.setState({ loading: false }); },function(info){ _this.setState({ loading: false }); }); }, componentWillUnmount(){ // 清理搜索条件 store.dispatch(updataTaiPingYangInsuranceSearch({ 'search[find]' : '', 'search[d_begin]' : '', 'search[d_end]' : '', 'page' : 1 })); }, onChange(value) { store.dispatch(updataTaiPingYangInsuranceSearch({ 'search[find]' : value, 'page' : 1 })); }, submitSearch() { const _this = this; this.setState({ loading: true }); getTaiPingYangInsuranceData(this.props.searchState,function(info){ _this.setState({ loading: false }); },function(info){ _this.setState({ loading: false }); }); }, onDateChange(dates, dateStrings) { store.dispatch(updataTaiPingYangInsuranceSearch({ 'search[d_begin]' : dateStrings[0], 'search[d_end]' : dateStrings[1], 'page' : 1 })); // 启动搜索 this.submitSearch(); }, onPageChange(page) { store.dispatch(updataTaiPingYangInsuranceSearch({ page : page })); // 启动搜索 this.submitSearch(); }, render(){ const { data } = this.props.dataState; console.log('dataSource', data); return ( <div> <div className="userListHeader border-b"> <SearchInput onChange={this.onChange} search={this.submitSearch} /> <div className="number-info"> <span>{data.total_money_sum}</span> <p>交易总额</p> </div> &nbsp; <div className="number-info"> <span>{data.total_users_sum}</span> <p>总人数</p> </div> </div> <div className="data-picker-bar"> <label>交易日期:</label> <RangePicker style={{ width: '200px' }} onChange={this.onDateChange} /> </div> <TaiPingYangInsuranceView defaultPageSize={12} total={data.total} currentPage={data.this_page} dataSource={data.list} onPageChange={this.onPageChange} loading={this.state.loading} /> </div> ) } }); const mapStateToProps = function (store) { return { dataState : store.taiPingYangInsuranceState.dataState, searchState : store.taiPingYangInsuranceState.searchState } }; export default connect(mapStateToProps)(TaiPingYangInsuranceContainer);
client/app-entry.js
nebulae-io/coteries
import React from 'react'; import ReactDom from 'react-dom'; import { createStore, applyMiddleware, combineReducers, bindActionCreators, compose } from 'redux'; import { Provider } from 'react-redux'; import { Router, history } from 'react-router'; import reduxThunk from 'redux-thunk'; import reduxPromise from 'redux-promise'; import { devTools, persistState } from 'redux-devtools'; import { DevTools, DebugPanel, LogMonitor } from 'redux-devtools/lib/react'; import reducers from './reducers'; import rootRoute from './app/routes'; console.log(reducers); import styles from './style.scss'; const reducer = combineReducers(reducers); const initialState = window.__INITIAL_STATE__; const store = compose( applyMiddleware(reduxThunk, reduxPromise) //,devTools() //,persistState(window.location.href.match(/[?&]debug_session=([^&]+)\b/)) )(createStore)(reducer, initialState); ReactDom.render( <Provider store={store}> <Router routes={rootRoute} history={history} /> </Provider> ,document.querySelector('#react-app-container') );
src/tk/tkrouter.js
JohnCrash/react-tiku
import React from 'react'; import {Route,Redirect,IndexRoute} from 'react-router'; import Master from 'Master' const AppRoutes = ( <Route path='/' component={Master}> </Route> ); export default AppRoutes;
app/components/shared/CollapsableArea.js
fotinakis/buildkite-frontend
import classNames from 'classnames'; import React from 'react'; import PropTypes from 'prop-types'; import styled from 'styled-components'; import { v4 as uuid } from 'uuid'; import RevealableDownChevron from './Icon/RevealableDownChevron'; const TransitionMaxHeight = styled.div` transition: max-height 400ms; `; // Helps to create collapsable area's, such as optional sets of form fields. // It's up to the responsibility of the caller to set the tabIndex to -1 for // any focusable elements (such as text inputs) when the area is collapsed export default class CollapsableArea extends React.Component { static propTypes = { children: PropTypes.node.isRequired, collapsed: PropTypes.bool, label: PropTypes.string.isRequired, onToggle: PropTypes.func.isRequired, // TODO: maxHeight is a bit of a hack, and might break for responsive // pages. We could instead use JS to calculate the height, and remove this // property altogether. maxHeight: PropTypes.number.isRequired }; constructor(props) { super(props); this.state = { uuid: uuid(), animating: false }; } static defaultProps = { collapsed: true } render() { return ( <div> <button type="button" className="unstyled-button bold lime hover-dark-lime outline-none" aria-expanded={!this.props.collapsed} aria-controls={this.state.uuid} onClick={this.handleButtonClick} > {this.props.label} <RevealableDownChevron revealed={!this.props.collapsed} style={{ marginLeft: 6, marginTop: -1 }} /> </button> <TransitionMaxHeight className={classNames("relative", { // We don't want to hide any input outlines when the form is expanded "overflow-hidden": this.props.collapsed || this.state.animating })} aria-expanded={!this.props.collapsed} id={this.state.uuid} style={{ maxHeight: this.props.collapsed ? 0 : this.props.maxHeight }} onTransitionEnd={this.handleOptionsHeightTransitionEnd} > <div className="pt1"> {this.props.children} </div> </TransitionMaxHeight> </div> ); } handleButtonClick = (event) => { event.preventDefault(); this.setState({ animating: true }); this.props.onToggle(event); } handleOptionsHeightTransitionEnd = () => { this.setState({ animating: false }); } }
fields/types/name/NameColumn.js
kwangkim/keystone
import React from 'react'; import ItemsTableCell from '../../../admin/src/components/ItemsTableCell'; import ItemsTableValue from '../../../admin/src/components/ItemsTableValue'; var NameColumn = React.createClass({ displayName: 'NameColumn', propTypes: { col: React.PropTypes.object, data: React.PropTypes.object, linkTo: React.PropTypes.string, }, renderValue () { var value = this.props.data.fields[this.props.col.path]; if (!value || (!value.first && !value.last)) return '(no name)'; return [value.first, value.last].filter(i => i).join(' '); }, render () { return ( <ItemsTableCell> <ItemsTableValue href={this.props.linkTo} padded interior field={this.props.col.type}> {this.renderValue()} </ItemsTableValue> </ItemsTableCell> ); } }); module.exports = NameColumn;
lib/Containers/App.js
Ezeebube5/Nairasense
import React, { Component } from 'react'; import { Provider } from 'react-redux'; import createStore from '../Redux'; import '../Config'; import DebugConfig from '../Config/DebugConfig'; import RootContainer from './RootContainer'; // create our store const store = createStore(); /** * Provides an entry point into our application. Both index.ios.js and index.android.js * call this component first. * * We create our Redux store here, put it into a provider and then bring in our * RootContainer. * * We separate like this to play nice with React Native's hot reloading. */ class App extends Component { render() { return ( <Provider store={store}> <RootContainer /> </Provider> ); } } // allow reactotron overlay for fast design in dev mode export default DebugConfig.useReactotron ? console.tron.overlay(App) : App;
packages/docs/components/Examples/anchor/gettingStarted.js
draft-js-plugins/draft-js-plugins
// It is important to import the Editor which accepts plugins. import Editor from '@draft-js-plugins/editor'; import createLinkPlugin from '@draft-js-plugins/anchor'; import createInlineToolbarPlugin from '@draft-js-plugins/inline-toolbar'; import { ItalicButton, BoldButton, UnderlineButton, } from '@draft-js-plugins/buttons'; import React from 'react'; // Here's your chance to pass in a configuration object (see below). const linkPlugin = createLinkPlugin(); // Pass the `linkPlugin.LinkButton` into the structure of the inline toolbar. const inlineToolbarPlugin = createInlineToolbarPlugin({ structure: [BoldButton, ItalicButton, UnderlineButton, linkPlugin.LinkButton], }); const { InlineToolbar } = inlineToolbarPlugin; const plugins = [inlineToolbarPlugin, linkPlugin]; const MyEditor = ({ editorState, onChange }) => ( <div> <Editor editorState={editorState} onChange={onChange} plugins={plugins} /> <InlineToolbar /> </div> ); export default MyEditor;
frontend/app/components/ItemIcon/IconLetter.js
First-Peoples-Cultural-Council/fv-web-ui
import React from 'react' import './IconLetter.css' /** * @summary IconLetter * @version 1.0.1 * @component * * @param {object} props * * @returns {node} jsx markup */ function IconLetter() { return ( <svg className="IconLetter" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 34 36"> <g transform="translate(-0.175 0.344)"> <ellipse className="IconLetter__bg" cx="17" cy="18" rx="17" ry="18" transform="translate(0.175 -0.344)" /> <text className="IconLetter__text" transform="translate(8.175 20.656)"> <tspan x="0" y="0"> Aa </tspan> </text> </g> </svg> ) } export default IconLetter
src/flat-button/test.js
twilson63/t63
import React from 'react' import test from 'tape' import { shallow } from 'enzyme' import FlatButton from './' test('<FlatButton />', t => { const wrapper = shallow(<FlatButton>Foo</FlatButton>) t.equal(wrapper.text(), 'Foo') t.end() }) test('<FlatButton onClick />', t => { let beep = 'beep' const wrapper = shallow( <FlatButton onClick={e => (beep = 'boop')}>Foo</FlatButton> ) wrapper.simulate('click') t.equal(beep, 'boop') t.end() }) test('<FlatButton className />', t => { const className = 'green bg-washed-green b--green' const wrapper = shallow(<FlatButton className={className}>Foo</FlatButton>) t.equal( 'ripple\n hover-bg-light-gray black-80\n dib\n f6\n flex items-center justify-around\n outline-0 border-block br1 pv2 ph3 bg-transparent bn ttu fw5 green bg-washed-green b--green', wrapper.props().className ) t.end() })
src/containers/Widgets/Widgets.js
hirzanalhakim/testKumparan
import React, { Component } from 'react'; import PropTypes from 'prop-types'; import Helmet from 'react-helmet'; import { connect } from 'react-redux'; import * as widgetActions from 'redux/modules/widgets'; import WidgetForm from 'components/WidgetForm/WidgetForm'; import { asyncConnect } from 'redux-connect'; const { isLoaded, load: loadWidgets } = widgetActions; @asyncConnect([{ deferred: !!__SERVER__, promise: ({ store: { dispatch, getState } }) => { if (!isLoaded(getState())) { return dispatch(loadWidgets()); } } }]) @connect( state => ({ widgets: state.widgets.data, editing: state.widgets.editing, error: state.widgets.error, loading: state.widgets.loading }), { ...widgetActions }) export default class Widgets extends Component { static propTypes = { widgets: PropTypes.array, error: PropTypes.string, loading: PropTypes.bool, editing: PropTypes.object.isRequired, load: PropTypes.func.isRequired, editStart: PropTypes.func.isRequired }; static defaultProps = { widgets: null, error: null, loading: false } render() { const handleEdit = widget => { const { editStart } = this.props; return () => editStart(String(widget.id)); }; const { widgets, error, editing, loading, load } = this.props; const styles = require('./Widgets.scss'); return ( <div className={`${styles.widgets} container`}> <h1> Widgets <button className={`${styles.refreshBtn} btn btn-success`} onClick={load}> <i className={`fa fa-refresh ${loading ? ' fa-spin' : ''}`} />{' '}Reload Widgets </button> </h1> <Helmet title="Widgets" /> <p> If you hit refresh on your browser, the data loading will take place on the server before the page is returned. If you navigated here from another page, the data was fetched from the client after the route transition. This uses the decorator method <code>@asyncConnect</code> with the <code>deferred: !!__SERVER__</code> flag. To block a route transition until some data is loaded, remove the <code>deferred:!!__SERVER__</code> flag. To always render before loading data, even on the server, use <code>componentDidMount</code>. </p> <p> This widgets are stored in your session, so feel free to edit it and refresh. </p> {error && <div className="alert alert-danger" role="alert"> <span className="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span>{' '}{error} </div>} {widgets && widgets.length && <table className="table table-striped"> <thead> <tr> <th className={styles.idCol}>ID</th> <th className={styles.colorCol}>Color</th> <th className={styles.sprocketsCol}>Sprockets</th> <th className={styles.ownerCol}>Owner</th> <th className={styles.buttonCol}></th> </tr> </thead> <tbody> { /* eslint-disable react/jsx-indent */ widgets.map(widget => (editing[widget.id] ? <WidgetForm form={String(widget.id)} key={String(widget.id)} initialValues={widget} /> : <tr key={widget.id}> <td className={styles.idCol}>{widget.id}</td> <td className={styles.colorCol}>{widget.color}</td> <td className={styles.sprocketsCol}>{widget.sprocketCount}</td> <td className={styles.ownerCol}>{widget.owner}</td> <td className={styles.buttonCol}> <button className="btn btn-primary" onClick={handleEdit(widget)}> <i className="fa fa-pencil" /> Edit </button> </td> </tr>) ) /* eslint-enable react/jsx-indent */ } </tbody> </table>} </div> ); } }
src/List/ListItem.js
skystebnicki/chamel
import React from 'react'; import PropTypes from 'prop-types'; import TouchRipple from '../ripples/TouchRipple'; import classnames from 'classnames'; import ThemeService from '../styles/ChamelThemeService'; import Checkbox from '../Toggle/Checkbox'; /** * Functional component for any button * * @param props * @param context * @returns {ReactDOM} * @constructor */ const ListItem = (props, context) => { let theme = context.chamelTheme && context.chamelTheme.list ? context.chamelTheme.list : ThemeService.defaultTheme.list; let classes = classnames(theme.listItem, { [theme.listItemSelected]: props.selected, [theme.listItemEmphasized]: props.emphasized, }); // Set ontap functions const onTap = props.onTap ? props.onTap : e => {}; const onLeftElementTap = props.onLeftElementTap || onTap; // If we have a left element add it let leftElement = null; if (props.leftElement) { const leftIcon = props.selected && props.selectedShowCheckbox ? ( <Checkbox checked={true} /> ) : ( props.leftElement ); leftElement = ( <div onClick={onLeftElementTap} className={theme.listItemLeft}> {leftIcon} </div> ); } // If we have a right element add it const rightElement = props.rightElement ? ( <div className={theme.listItemRight}>{props.rightElement}</div> ) : null; return ( <div className={classes}> <TouchRipple> <div className={theme.listItemContent}> {leftElement} <div className={theme.listItemData} onClick={onTap}> <div className={theme.listItemPrimary}>{props.primaryText}</div> <div className={theme.listItemSecondary}>{props.secondaryText}</div> </div> {rightElement} </div> </TouchRipple> </div> ); }; /** * Set accepted properties */ ListItem.propTypes = { /** * Primary text/title of the item */ primaryText: PropTypes.string, /** * Secondary text for the item - often a snippet of the body */ secondaryText: PropTypes.string, /** * Optional children to render into the item */ children: PropTypes.node, /** * Optional flag that can be set to indicate this item is selected */ selected: PropTypes.bool, /** * Show a checkbox if this item is slected (or on mouse hover to indicate it can be) */ selectedShowCheckbox: PropTypes.bool, /** * Used to highlight an entry - often used to mark a new entry */ emphasized: PropTypes.bool, /** * Node element to render on the left side */ leftElement: PropTypes.node, /** * Node element to render on the right side */ rightElement: PropTypes.node, /** * Event called when the primary action is tapped or Clicked */ onTap: PropTypes.func, /** * Event called when the left element is tapped or Clicked */ onLeftElementTap: PropTypes.func, }; /** * Set property defaults */ ListItem.defaultProps = { primaryText: null, secondaryText: null, leftElement: null, rightElement: null, selected: false, emphasized: false, }; /** * An alternate theme may be passed down by a provider */ ListItem.contextTypes = { chamelTheme: PropTypes.object, }; export default ListItem;
src/routes/TestRoute/TestRoute.js
taforyou/testtesttest-yo
import React from 'react' export const TestRoute = () => ( <div className='container'> <h1>Test Route</h1> <p>Test Route</p> <p>Test Route 111</p> </div> ) export default TestRoute
src/svg-icons/maps/local-airport.js
frnk94/material-ui
import React from 'react'; import pure from 'recompose/pure'; import SvgIcon from '../../SvgIcon'; let MapsLocalAirport = (props) => ( <SvgIcon {...props}> <path d="M21 16v-2l-8-5V3.5c0-.83-.67-1.5-1.5-1.5S10 2.67 10 3.5V9l-8 5v2l8-2.5V19l-2 1.5V22l3.5-1 3.5 1v-1.5L13 19v-5.5l8 2.5z"/> </SvgIcon> ); MapsLocalAirport = pure(MapsLocalAirport); MapsLocalAirport.displayName = 'MapsLocalAirport'; MapsLocalAirport.muiName = 'SvgIcon'; export default MapsLocalAirport;
src/Grid.js
gianpaj/react-bootstrap
import React from 'react'; import classNames from 'classnames'; import CustomPropTypes from './utils/CustomPropTypes'; const Grid = React.createClass({ propTypes: { /** * Turn any fixed-width grid layout into a full-width layout by this property. * * Adds `container-fluid` class. */ fluid: React.PropTypes.bool, /** * You can use a custom element for this component */ componentClass: CustomPropTypes.elementType }, getDefaultProps() { return { componentClass: 'div', fluid: false }; }, render() { let ComponentClass = this.props.componentClass; let className = this.props.fluid ? 'container-fluid' : 'container'; return ( <ComponentClass {...this.props} className={classNames(this.props.className, className)}> {this.props.children} </ComponentClass> ); } }); export default Grid;
site/src/components/Learn.js
appbaseio/reactivesearch
import React, { Component } from 'react'; import { ThemeProvider } from 'emotion-theming'; import { Link } from 'react-router-dom'; import { css } from 'emotion'; import PropTypes from 'prop-types'; import { Navbar, Logo, Button, H1, Title, Grid } from '@appbaseio/designkit'; import { Base, Layout, SecondaryLink, Section, titleText, stepCard, showMobileFlex, } from '../styles'; import H2 from '../styles/H2'; import SupportGrid from '../components/SupportGrid'; import BannerRow from '../components/BannerRow'; import Footer from '../components/Footer'; import queries from '../styles/mediaQueries'; const navTitle = css` ${queries.small` font-size: 20px; `}; `; const title = { marginTop: '10px', }; class Learn extends Component { componentDidMount() { window.scrollTo(0, 0); } render() { const { config, theme } = this.props; const isVue = config.name === 'vue'; return ( <ThemeProvider theme={{ primaryColor: '#0033FF', }} > <Base> <Navbar bold> <Navbar.Logo> <Logo css={navTitle} href={config.header.logo.href}> <Logo.Icon css="color: #fff;"> <img src={config.header.logo.src} alt="Icon" /> </Logo.Icon> <Logo.Light>{config.header.logo.title.light}</Logo.Light> <Logo.Dark>{config.header.logo.title.dark}</Logo.Dark> {config.header.logo.title.description && ( <span css="margin-left: 7px !important"> <Logo.Light>{config.header.logo.title.description}</Logo.Light> </span> )} </Logo> </Navbar.Logo> <Navbar.List> {config.header.links.map((l, i) => ( <li className={l.href.endsWith('/quickstart') ? 'active' : undefined} /* eslint-disable-next-line */ key={i} > {/* eslint-disable-next-line */} <Link style={{ color: '#424242' }} to={l.href}> {l.description.toUpperCase()} </Link> </li> ))} <li className={showMobileFlex}> <a href={config.urls.github}>GITHUB</a> </li> <li className="button"> <Button style={{ backgroundColor: theme.secondary, color: isVue ? theme.textDark : undefined, }} href={config.urls.support} bold uppercase > <img src={isVue ? '../../reactivesearch/images/supportDark.svg' : '../../reactivesearch/images/support.svg'} style={{ marginRight: 8 }} alt="support" />{' '} SUPPORT </Button> </li> </Navbar.List> </Navbar> <Section> <Layout style={{ marginTop: '50px' }}> <H1>{config.title}</H1> <p className={titleText}>{config.description}</p> <Grid size={3} mdSize={2} smSize={1} gutter="12px" smGutter="0px" style={{ marginTop: 60, }} > {config.installationSteps.map((step, i) => (Object.keys(step).length ? ( // eslint-disable-next-line <div key={i} className={stepCard}> <span className="count" style={{ color: theme.primaryDark }}> {i + 1} </span> <div> <Title style={title}>{step.title}</Title> {/* eslint-disable-next-line */} {step.descriptions && step.descriptions.map((d, i) => <p key={i}>{d}</p>)} </div> {/* eslint-disable-next-line */} {step.codes && ( <div className="full"> {step.codes.map((code, index) => ( // eslint-disable-next-line <pre key={index}> <code>{code}</code> </pre> ))} </div> )} <div> {step.links && step.links.map((link, index2) => ( <SecondaryLink // eslint-disable-next-line key={index2} primary rel="noopener noreferrer" href={link.href} target="_blank" style={{ color: theme.primaryDark, marginLeft: index2 > 0 ? '1rem' : undefined, }} > {link.title} </SecondaryLink> ))} </div> </div> ) : ( <div /> )))} </Grid> </Layout> </Section> <BannerRow configName={config.name} config={config.banner} theme={theme} /> <Section> <Layout> <H2>Need Help?</H2> <p>Resources to get help with Reactive Search.</p> <SupportGrid configName={config.name} /> </Layout> </Section> <Footer configName={config.name} footerConfig={config.footer} /> </Base> </ThemeProvider> ); } } Learn.propTypes = { config: PropTypes.object.isRequired, theme: PropTypes.object.isRequired, }; export default Learn;
app/javascript/mastodon/features/account_timeline/components/header.js
TheInventrix/mastodon
import React from 'react'; import ImmutablePropTypes from 'react-immutable-proptypes'; import PropTypes from 'prop-types'; import InnerHeader from '../../account/components/header'; import ActionBar from '../../account/components/action_bar'; import MissingIndicator from '../../../components/missing_indicator'; import ImmutablePureComponent from 'react-immutable-pure-component'; import MovedNote from './moved_note'; import { FormattedMessage } from 'react-intl'; import { NavLink } from 'react-router-dom'; export default class Header extends ImmutablePureComponent { static propTypes = { account: ImmutablePropTypes.map, onFollow: PropTypes.func.isRequired, onBlock: PropTypes.func.isRequired, onMention: PropTypes.func.isRequired, onDirect: PropTypes.func.isRequired, onReblogToggle: PropTypes.func.isRequired, onReport: PropTypes.func.isRequired, onMute: PropTypes.func.isRequired, onBlockDomain: PropTypes.func.isRequired, onUnblockDomain: PropTypes.func.isRequired, onEndorseToggle: PropTypes.func.isRequired, hideTabs: PropTypes.bool, }; static contextTypes = { router: PropTypes.object, }; handleFollow = () => { this.props.onFollow(this.props.account); } handleBlock = () => { this.props.onBlock(this.props.account); } handleMention = () => { this.props.onMention(this.props.account, this.context.router.history); } handleDirect = () => { this.props.onDirect(this.props.account, this.context.router.history); } handleReport = () => { this.props.onReport(this.props.account); } handleReblogToggle = () => { this.props.onReblogToggle(this.props.account); } handleMute = () => { this.props.onMute(this.props.account); } handleBlockDomain = () => { const domain = this.props.account.get('acct').split('@')[1]; if (!domain) return; this.props.onBlockDomain(domain); } handleUnblockDomain = () => { const domain = this.props.account.get('acct').split('@')[1]; if (!domain) return; this.props.onUnblockDomain(domain); } handleEndorseToggle = () => { this.props.onEndorseToggle(this.props.account); } render () { const { account, hideTabs } = this.props; if (account === null) { return <MissingIndicator />; } return ( <div className='account-timeline__header'> {account.get('moved') && <MovedNote from={account} to={account.get('moved')} />} <InnerHeader account={account} onFollow={this.handleFollow} onBlock={this.handleBlock} /> <ActionBar account={account} onBlock={this.handleBlock} onMention={this.handleMention} onDirect={this.handleDirect} onReblogToggle={this.handleReblogToggle} onReport={this.handleReport} onMute={this.handleMute} onBlockDomain={this.handleBlockDomain} onUnblockDomain={this.handleUnblockDomain} onEndorseToggle={this.handleEndorseToggle} /> {!hideTabs && ( <div className='account__section-headline'> <NavLink exact to={`/accounts/${account.get('id')}`}><FormattedMessage id='account.posts' defaultMessage='Toots' /></NavLink> <NavLink exact to={`/accounts/${account.get('id')}/with_replies`}><FormattedMessage id='account.posts_with_replies' defaultMessage='Toots and replies' /></NavLink> <NavLink exact to={`/accounts/${account.get('id')}/media`}><FormattedMessage id='account.media' defaultMessage='Media' /></NavLink> </div> )} </div> ); } }
collect-webapp/frontend/src/datamanagement/components/recordeditor/fields/CoordinateField.js
openforis/collect
import React from 'react' import { connect } from 'react-redux' import { MenuItem, Select, TextField as MuiTextField } from '@mui/material' import { CoordinateAttributeDefinition } from 'model/Survey' import InputNumber from 'common/components/InputNumber' import L from 'utils/Labels' import Objects from 'utils/Objects' import AbstractField from './AbstractField' import CompositeAttributeFormItem from './CompositeAttributeFormItem' import { COORDINATE_FIELD_WIDTH_PX } from './FieldsSizes' import DirtyFieldSpinner from './DirtyFieldSpinner' class CoordinateField extends AbstractField { constructor() { super() this.onChangeSrs = this.onChangeSrs.bind(this) } onChangeField({ field, fieldValue }) { const { value: valueState } = this.state const { fieldDef } = this.props const { showSrsField } = fieldDef.attributeDefinition const value = { ...valueState, [field]: fieldValue } const { x = null, y = null, srs = null } = value const srss = this.getSpatialReferenceSystems() if (srss.length === 1 || !showSrsField) { if (x !== null && y !== null && srs === null) { // Set default SRS (1st one) value['srs'] = srss[0].id } else if (x === null && y === null) { // SRS field is readonly, reset it value['srs'] = null } } this.updateValue({ value }) } onChangeSrs(event) { this.onChangeField({ field: 'srs', fieldValue: event.target.value }) } getSpatialReferenceSystems() { return this.props.parentEntity.definition.survey.spatialReferenceSystems } render() { const { inTable, fieldDef, parentEntity, user } = this.props const { dirty, value } = this.state const { record } = parentEntity const { srs = '' } = value || {} const { attributeDefinition } = fieldDef const { availableFieldNames } = attributeDefinition const readOnly = !user.canEditRecordAttribute({ record, attributeDefinition }) const numericField = ({ field }) => ( <InputNumber key={field} decimalScale={10} value={Objects.getProp(field, '')(value)} readOnly={readOnly} onChange={(fieldValue) => this.onChangeField({ field, fieldValue })} width={COORDINATE_FIELD_WIDTH_PX} /> ) const inputFields = availableFieldNames.map((field) => { if (field === CoordinateAttributeDefinition.Fields.SRS) { const srss = this.getSpatialReferenceSystems() const style = { width: COORDINATE_FIELD_WIDTH_PX } return srss.length === 1 ? ( <MuiTextField key="srs" variant="outlined" value={srss[0].label} disabled style={style} /> ) : ( <Select key="srs" value={srs} variant="outlined" disabled={readOnly} onChange={this.onChangeSrs} style={style} > <MenuItem key="empty" value=""> <em>{L.l('common.selectOne')}</em> </MenuItem> {srss.map((srs) => { const itemLabel = `${srs.label}${srs.label === srs.id ? '' : ` (${srs.id})`}` return ( <MenuItem key={srs.id} value={srs.id}> {itemLabel} </MenuItem> ) })} </Select> ) } return numericField({ field }) }) const getFormItem = ({ field, inputField }) => ( <CompositeAttributeFormItem key={field} field={field} label={ attributeDefinition.getFieldLabel(field) || L.l(`dataManagement.dataEntry.attribute.coordinate.${field}`) } labelWidth={100} inputField={inputField} /> ) return ( <> <div style={{ flexDirection: inTable ? 'row' : 'column' }} className="form-item-composite-wrapper"> {inTable ? inputFields : availableFieldNames.map((field, index) => getFormItem({ field, inputField: inputFields[index] }))} </div> {dirty && <DirtyFieldSpinner />} </> ) } } const mapStateToProps = (state) => { const { session } = state const { loggedUser: user } = session return { user } } export default connect(mapStateToProps)(CoordinateField)
src/svg-icons/maps/add-location.js
lawrence-yu/material-ui
import React from 'react'; import pure from 'recompose/pure'; import SvgIcon from '../../SvgIcon'; let MapsAddLocation = (props) => ( <SvgIcon {...props}> <path d="M12 2C8.14 2 5 5.14 5 9c0 5.25 7 13 7 13s7-7.75 7-13c0-3.86-3.14-7-7-7zm4 8h-3v3h-2v-3H8V8h3V5h2v3h3v2z"/> </SvgIcon> ); MapsAddLocation = pure(MapsAddLocation); MapsAddLocation.displayName = 'MapsAddLocation'; MapsAddLocation.muiName = 'SvgIcon'; export default MapsAddLocation;
js/components/App/Footer.js
scaphold-io/react-relay-starter-kit
import React from 'react'; import Relay from 'react-relay'; import {Row, Col} from 'react-bootstrap'; import FontAwesome from 'react-fontawesome'; class Footer extends React.Component { render() { return ( <Row> <Col> <p style={styles.footer}>Made with <FontAwesome name='heart'/> from the Scaphold team</p> </Col> </Row> ); } } export default Relay.createContainer(Footer, { fragments: { } }); const styles = { footer: { textAlign: 'center', paddingTop: 19, color: '#777', borderTop: '1px, solid, #e5e5e5' } };
src/app/components/Store/StoreHome.js
akzuki/BoardgameAPI
import React from 'react'; import { StoreHeader } from './StoreHeader'; import { Footer } from '../Footer'; export class StoreHome extends React.Component { render() { return ( <div> <StoreHeader/> <div className="content"> {this.props.children} </div> <Footer/> </div> ); } }
src/components/UserRegistrationForm.js
dkadrios/zendrum-stompblock-client
import React from 'react' import PropTypes from 'prop-types' import { connect } from 'react-redux' import { bindActionCreators } from 'redux' import { Field, reduxForm } from 'redux-form' import { withStyles } from '@material-ui/core' import FormInput from './FormInput' import * as userActions from '../action-creators/user' import { fieldRequired, fieldMaxLength64, fieldEmail } from '../utils' const styles = { container: { display: 'flex', flexWrap: 'wrap', border: '2px groove #ccc', borderRadius: 5, backgroundColor: '#f3f3f3', maxWidth: 480, margin: '15px 0 40px', paddingBottom: 20, }, } const UserRegistrationForm = ({ error, handleSubmit, classes }) => ( <form onSubmit={handleSubmit} className={classes.container} > <Field name="firstName" type="text" component={FormInput} label="First Name" validate={[fieldRequired, fieldMaxLength64]} /> <Field name="lastName" type="text" component={FormInput} label="Last Name" validate={[fieldRequired, fieldMaxLength64]} /> <Field name="email" type="email" component={FormInput} label="Email" validate={[fieldRequired, fieldEmail]} /> {error && <strong>{error}</strong>} </form> ) UserRegistrationForm.propTypes = { handleSubmit: PropTypes.func.isRequired, error: PropTypes.string, classes: PropTypes.object.isRequired, } UserRegistrationForm.defaultProps = { error: '' } const mapStateToProps = ({ user }) => ({ initialValues: user }) const mapDispatchToProps = dispatch => bindActionCreators(userActions, dispatch) const formOptions = { form: 'userRegistrationForm', enableReinitialize: true, onSubmit: (values, dispatch) => dispatch(userActions.submitRegistration(values)), } /* eslint-disable */ export default connect( mapStateToProps, mapDispatchToProps, )(reduxForm(formOptions)(withStyles(styles)(UserRegistrationForm)))
frontend/src/Movie/Details/Titles/MovieTitlesTableContent.js
Radarr/Radarr
import PropTypes from 'prop-types'; import React, { Component } from 'react'; import LoadingIndicator from 'Components/Loading/LoadingIndicator'; import Table from 'Components/Table/Table'; import TableBody from 'Components/Table/TableBody'; import translate from 'Utilities/String/translate'; import MovieTitlesRow from './MovieTitlesRow'; import styles from './MovieTitlesTableContent.css'; const columns = [ { name: 'altTitle', label: translate('AlternativeTitle'), isVisible: true }, { name: 'language', label: translate('Language'), isVisible: true }, { name: 'sourceType', label: translate('Type'), isVisible: true } ]; class MovieTitlesTableContent extends Component { // // Render render() { const { isFetching, isPopulated, error, items } = this.props; const hasItems = !!items.length; return ( <div> { isFetching && <LoadingIndicator /> } { !isFetching && !!error && <div className={styles.blankpad}> {translate('UnableToLoadAltTitle')} </div> } { isPopulated && !hasItems && !error && <div className={styles.blankpad}> {translate('NoAltTitle')} </div> } { isPopulated && hasItems && !error && <Table columns={columns}> <TableBody> { items.reverse().map((item) => { return ( <MovieTitlesRow key={item.id} {...item} /> ); }) } </TableBody> </Table> } </div> ); } } MovieTitlesTableContent.propTypes = { isFetching: PropTypes.bool.isRequired, isPopulated: PropTypes.bool.isRequired, error: PropTypes.object, items: PropTypes.arrayOf(PropTypes.object).isRequired }; export default MovieTitlesTableContent;
demo/component/Treemap.js
sdoomz/recharts
import React, { Component } from 'react'; import { Treemap, Tooltip } from 'recharts'; import DemoTreemapItem from './DemoTreemapItem'; import _ from 'lodash'; import { changeNumberOfData as changeData } from './utils'; const data = [{ name: 'analytics', children: [ { name: 'cluster', children: [ { name: 'AgglomerativeCluster', size: 3938 }, { name: 'CommunityStructure', size: 3812 }, { name: 'HierarchicalCluster', size: 6714 }, { name: 'MergeEdge', size: 743 }, ], }, { name: 'graph', children: [ { name: 'BetweennessCentrality', size: 3534 }, { name: 'LinkDistance', size: 5731 }, { name: 'MaxFlowMinCut', size: 7840 }, { name: 'ShortestPaths', size: 5914 }, { name: 'SpanningTree', size: 3416 }, ], }, { name: 'optimization', children: [ { name: 'AspectRatioBanker', size: 7074 }, ], }, ], }, { name: 'animate', children: [ { name: 'Easing', size: 17010 }, { name: 'FunctionSequence', size: 5842 }, { name: 'interpolate', children: [ { name: 'ArrayInterpolator', size: 1983 }, { name: 'ColorInterpolator', size: 2047 }, { name: 'DateInterpolator', size: 1375 }, { name: 'Interpolator', size: 8746 }, { name: 'MatrixInterpolator', size: 2202 }, { name: 'NumberInterpolator', size: 1382 }, { name: 'ObjectInterpolator', size: 1629 }, { name: 'PointInterpolator', size: 1675 }, { name: 'RectangleInterpolator', size: 2042 }, ], }, { name: 'ISchedulable', size: 1041 }, { name: 'Parallel', size: 5176 }, { name: 'Pause', size: 449 }, { name: 'Scheduler', size: 5593 }, { name: 'Sequence', size: 5534 }, { name: 'Transition', size: 9201 }, { name: 'Transitioner', size: 19975 }, { name: 'TransitionEvent', size: 1116 }, { name: 'Tween', size: 6006 }, ], }, { name: 'data', children: [ { name: 'converters', children: [ { name: 'Converters', size: 721 }, { name: 'DelimitedTextConverter', size: 4294 }, { name: 'GraphMLConverter', size: 9800 }, { name: 'IDataConverter', size: 1314 }, { name: 'JSONConverter', size: 2220 }, ], }, { name: 'DataField', size: 1759 }, { name: 'DataSchema', size: 2165 }, { name: 'DataSet', size: 586 }, { name: 'DataSource', size: 3331 }, { name: 'DataTable', size: 772 }, { name: 'DataUtil', size: 3322 }, ], }, { name: 'display', children: [ { name: 'DirtySprite', size: 8833 }, { name: 'LineSprite', size: 1732 }, { name: 'RectSprite', size: 3623 }, { name: 'TextSprite', size: 10066 }, ], }, { name: 'flex', children: [ { name: 'FlareVis', size: 4116 }, ], }, { name: 'physics', children: [ { name: 'DragForce', size: 1082 }, { name: 'GravityForce', size: 1336 }, { name: 'IForce', size: 319 }, { name: 'NBodyForce', size: 10498 }, { name: 'Particle', size: 2822 }, { name: 'Simulation', size: 9983 }, { name: 'Spring', size: 2213 }, { name: 'SpringForce', size: 1681 }, ], }, { name: 'query', children: [ { name: 'AggregateExpression', size: 1616 }, { name: 'And', size: 1027 }, { name: 'Arithmetic', size: 3891 }, { name: 'Average', size: 891 }, { name: 'BinaryExpression', size: 2893 }, { name: 'Comparison', size: 5103 }, { name: 'CompositeExpression', size: 3677 }, { name: 'Count', size: 781 }, { name: 'DateUtil', size: 4141 }, { name: 'Distinct', size: 933 }, { name: 'Expression', size: 5130 }, { name: 'ExpressionIterator', size: 3617 }, { name: 'Fn', size: 3240 }, { name: 'If', size: 2732 }, { name: 'IsA', size: 2039 }, { name: 'Literal', size: 1214 }, { name: 'Match', size: 3748 }, { name: 'Maximum', size: 843 }, { name: 'methods', children: [ { name: 'add', size: 593 }, { name: 'and', size: 330 }, { name: 'average', size: 287 }, { name: 'count', size: 277 }, { name: 'distinct', size: 292 }, { name: 'div', size: 595 }, { name: 'eq', size: 594 }, { name: 'fn', size: 460 }, { name: 'gt', size: 603 }, { name: 'gte', size: 625 }, { name: 'iff', size: 748 }, { name: 'isa', size: 461 }, { name: 'lt', size: 597 }, { name: 'lte', size: 619 }, { name: 'max', size: 283 }, { name: 'min', size: 283 }, { name: 'mod', size: 591 }, { name: 'mul', size: 603 }, { name: 'neq', size: 599 }, { name: 'not', size: 386 }, { name: 'or', size: 323 }, { name: 'orderby', size: 307 }, { name: 'range', size: 772 }, { name: 'select', size: 296 }, { name: 'stddev', size: 363 }, { name: 'sub', size: 600 }, { name: 'sum', size: 280 }, { name: 'update', size: 307 }, { name: 'variance', size: 335 }, { name: 'where', size: 299 }, { name: 'xor', size: 354 }, { name: '_', size: 264 }, ], }, { name: 'Minimum', size: 843 }, { name: 'Not', size: 1554 }, { name: 'Or', size: 970 }, { name: 'Query', size: 13896 }, { name: 'Range', size: 1594 }, { name: 'StringUtil', size: 4130 }, { name: 'Sum', size: 791 }, { name: 'Variable', size: 1124 }, { name: 'Variance', size: 1876 }, { name: 'Xor', size: 1101 }, ], }, { name: 'scale', children: [ { name: 'IScaleMap', size: 2105 }, { name: 'LinearScale', size: 1316 }, { name: 'LogScale', size: 3151 }, { name: 'OrdinalScale', size: 3770 }, { name: 'QuantileScale', size: 2435 }, { name: 'QuantitativeScale', size: 4839 }, { name: 'RootScale', size: 1756 }, { name: 'Scale', size: 4268 }, { name: 'ScaleType', size: 1821 }, { name: 'TimeScale', size: 5833 }, ], }, { name: 'util', children: [ { name: 'Arrays', size: 8258 }, { name: 'Colors', size: 10001 }, { name: 'Dates', size: 8217 }, { name: 'Displays', size: 12555 }, { name: 'Filter', size: 2324 }, { name: 'Geometry', size: 10993 }, { name: 'heap', children: [ { name: 'FibonacciHeap', size: 9354 }, { name: 'HeapNode', size: 1233 }, ], }, { name: 'IEvaluable', size: 335 }, { name: 'IPredicate', size: 383 }, { name: 'IValueProxy', size: 874 }, { name: 'math', children: [ { name: 'DenseMatrix', size: 3165 }, { name: 'IMatrix', size: 2815 }, { name: 'SparseMatrix', size: 3366 }, ], }, { name: 'Maths', size: 17705 }, { name: 'Orientation', size: 1486 }, { name: 'palette', children: [ { name: 'ColorPalette', size: 6367 }, { name: 'Palette', size: 1229 }, { name: 'ShapePalette', size: 2059 }, { name: 'SizePalette', size: 2291 }, ], }, { name: 'Property', size: 5559 }, { name: 'Shapes', size: 19118 }, { name: 'Sort', size: 6887 }, { name: 'Stats', size: 6557 }, { name: 'Strings', size: 22026 }, ], }, { name: 'vis', children: [ { name: 'axis', children: [ { name: 'Axes', size: 1302 }, { name: 'Axis', size: 24593 }, { name: 'AxisGridLine', size: 652 }, { name: 'AxisLabel', size: 636 }, { name: 'CartesianAxes', size: 6703 }, ], }, { name: 'controls', children: [ { name: 'AnchorControl', size: 2138 }, { name: 'ClickControl', size: 3824 }, { name: 'Control', size: 1353 }, { name: 'ControlList', size: 4665 }, { name: 'DragControl', size: 2649 }, { name: 'ExpandControl', size: 2832 }, { name: 'HoverControl', size: 4896 }, { name: 'IControl', size: 763 }, { name: 'PanZoomControl', size: 5222 }, { name: 'SelectionControl', size: 7862 }, { name: 'TooltipControl', size: 8435 }, ], }, { name: 'data', children: [ { name: 'Data', size: 20544 }, { name: 'DataList', size: 19788 }, { name: 'DataSprite', size: 10349 }, { name: 'EdgeSprite', size: 3301 }, { name: 'NodeSprite', size: 19382 }, { name: 'render', children: [ { name: 'ArrowType', size: 698 }, { name: 'EdgeRenderer', size: 5569 }, { name: 'IRenderer', size: 353 }, { name: 'ShapeRenderer', size: 2247 }, ], }, { name: 'ScaleBinding', size: 11275 }, { name: 'Tree', size: 7147 }, { name: 'TreeBuilder', size: 9930 }, ], }, { name: 'events', children: [ { name: 'DataEvent', size: 2313 }, { name: 'SelectionEvent', size: 1880 }, { name: 'TooltipEvent', size: 1701 }, { name: 'VisualizationEvent', size: 1117 }, ], }, { name: 'legend', children: [ { name: 'Legend', size: 20859 }, { name: 'LegendItem', size: 4614 }, { name: 'LegendRange', size: 10530 }, ], }, { name: 'operator', children: [ { name: 'distortion', children: [ { name: 'BifocalDistortion', size: 4461 }, { name: 'Distortion', size: 6314 }, { name: 'FisheyeDistortion', size: 3444 }, ], }, { name: 'encoder', children: [ { name: 'ColorEncoder', size: 3179 }, { name: 'Encoder', size: 4060 }, { name: 'PropertyEncoder', size: 4138 }, { name: 'ShapeEncoder', size: 1690 }, { name: 'SizeEncoder', size: 1830 }, ], }, { name: 'filter', children: [ { name: 'FisheyeTreeFilter', size: 5219 }, { name: 'GraphDistanceFilter', size: 3165 }, { name: 'VisibilityFilter', size: 3509 }, ], }, { name: 'IOperator', size: 1286 }, { name: 'label', children: [ { name: 'Labeler', size: 9956 }, { name: 'RadialLabeler', size: 3899 }, { name: 'StackedAreaLabeler', size: 3202 }, ], }, { name: 'layout', children: [ { name: 'AxisLayout', size: 6725 }, { name: 'BundledEdgeRouter', size: 3727 }, { name: 'CircleLayout', size: 9317 }, { name: 'CirclePackingLayout', size: 12003 }, { name: 'DendrogramLayout', size: 4853 }, { name: 'ForceDirectedLayout', size: 8411 }, { name: 'IcicleTreeLayout', size: 4864 }, { name: 'IndentedTreeLayout', size: 3174 }, { name: 'Layout', size: 7881 }, { name: 'NodeLinkTreeLayout', size: 12870 }, { name: 'PieLayout', size: 2728 }, { name: 'RadialTreeLayout', size: 12348 }, { name: 'RandomLayout', size: 870 }, { name: 'StackedAreaLayout', size: 9121 }, { name: 'TreeMapLayout', size: 9191 }, ], }, { name: 'Operator', size: 2490 }, { name: 'OperatorList', size: 5248 }, { name: 'OperatorSequence', size: 4190 }, { name: 'OperatorSwitch', size: 2581 }, { name: 'SortOperator', size: 2023 }, ], }, { name: 'Visualization', size: 16540 }, ], }][2].children; class DemoTreemap extends Component { static displayName = 'DemoTreemap'; state = { data, }; render() { const ColorPlatte = ['#8889DD', '#9597E4', '#8DC77B', '#A5D297', '#E2CF45', '#F8C12D']; return ( <div className="treemap-charts"> <br/> <div className="treemap-chart-wrapper"> <Treemap width={500} height={250} data={this.state.data} dataKey="size" isUpdateAnimationActive={false} /> </div> <br /> <p>Treemap</p> <a href="javascript:void(0)" className="btn" onClick={() => { this.setState({ data: changeData(data), }); }} > change data </a> <div className="treemap-chart-wrapper"> <Treemap width={500} height={250} data={this.state.data} isAnimationActive={false} dataKey="size" ratio={1} content={<DemoTreemapItem bgColors={ColorPlatte} />} > <Tooltip/> </Treemap> </div> </div> ); } } export default DemoTreemap;
rojak-ui-web/src/app/home/SearchForm.js
pyk/rojak
import React from 'react' class SearchForm extends React.Component { static propTypes = { keyword: React.PropTypes.string, onKeywordChange: React.PropTypes.func.isRequired } constructor (props) { super(props) this.state = { keyword: '' } this.throttleKeyChange = null } componentDidMount () { const { keyword } = this.props keyword && this.setState({ keyword }) } componentWillReceiveProps (nextProps) { const { keyword } = this.props if (nextProps.keyword !== keyword) { this.setState({ keyword: nextProps.keyword }) } } get handleKeywordChange () { const { onKeywordChange } = this.props return (e) => { const keyword = e.target.value this.setState({ keyword }) if (this.throttleKeyChange) { clearTimeout(this.throttleKeyChange) } this.throttleKeyChange = setTimeout(() => { onKeywordChange(keyword) }, 300) } } render () { const { keyword } = this.state return ( <form className="uk-form"> <input type="text" placeholder="cari dari nama kandidat, pasangan, atau media" className="uk-form-large uk-form-width-large" value={keyword} onChange={this.handleKeywordChange} style={{ padding: '10px 15px', borderRadius: '0px' }} /> </form> ) } } export default SearchForm
src/Homepage.js
mrinalkrishnanm/kyogre
import React from 'react'; class Homepage extends React.Component{ constructor(){ super(); } render(){ return( <h1> Diary App</h1> ); } } module.exports = Homepage;
src/parser/deathknight/frost/modules/features/checklist/Module.js
sMteX/WoWAnalyzer
import React from 'react'; import BaseModule from 'parser/shared/modules/features/Checklist/Module'; import CastEfficiency from 'parser/shared/modules/CastEfficiency'; import Combatants from 'parser/shared/modules/Combatants'; import PreparationRuleAnalyzer from 'parser/shared/modules/features/Checklist/PreparationRuleAnalyzer'; import AlwaysBeCasting from '../AlwaysBeCasting'; import RunicPowerDetails from '../../runicpower/RunicPowerDetails'; import RuneTracker from '../RuneTracker'; import Component from './Component'; class Checklist extends BaseModule { static dependencies = { combatants: Combatants, castEfficiency: CastEfficiency, alwaysBeCasting: AlwaysBeCasting, preparationRuleAnalyzer: PreparationRuleAnalyzer, runicPowerDetails: RunicPowerDetails, runeTracker: RuneTracker, }; render() { return ( <Component combatant={this.combatants.selected} castEfficiency={this.castEfficiency} thresholds={{ ...this.preparationRuleAnalyzer.thresholds, runeEfficiency: this.runeTracker.suggestionThresholdsEfficiency, runicPowerEfficiency: this.runicPowerDetails.efficiencySuggestionThresholds, downtimeSuggestionThresholds: this.alwaysBeCasting.downtimeSuggestionThresholds, }} /> ); } } export default Checklist;
websocket/client/Client/node_modules/babel-plugin-react-transform/test/fixtures/code-ignore/actual.js
prayuditb/tryout-01
import React from 'react'; const First = React.createNotClass({ displayName: 'First' }); class Second extends React.NotComponent {}
app/src/components/MusicBot/Container.js
RekkyRek/tic
import '../../assets/css/MusicBot/Container.sass'; import React, { Component } from 'react'; class MusicBot extends React.Component { constructor(props) { super(props); this.state = { } } componentWillMount() { } componentDidMount() { } render() { return ( <div className="musicContainer"> <p>Meme</p> </div> ); } } export default MusicBot;
src/components/layout/content/NewSnippet.js
Gisto/Gisto
import React from 'react'; import PropTypes from 'prop-types'; import { connect } from 'react-redux'; import styled from 'styled-components'; import { filter, findIndex, get, head, isEmpty, keys, map, set, replace, startsWith, debounce, truncate } from 'lodash/fp'; import uuid from 'uuid'; import { HashRouter as Router, Link } from 'react-router-dom'; import * as snippetActions from 'actions/snippets'; import { DEFAULT_SNIPPET_DESCRIPTION } from 'constants/config'; import { syntaxMap } from 'constants/editor'; import { prepareFiles } from 'utils/snippets'; import { gaPage } from 'utils/ga'; import { getSetting } from 'utils/settings'; import { randomString } from 'utils/string'; import { hexToRGBA } from 'utils/color'; import Input from 'components/common/controls/Input'; import Editor from 'components/common/controls/Editor'; import Icon from 'components/common/Icon'; import ExternalLink from 'components/common/ExternalLink'; import Button from 'components/common/controls/Button'; import Checkbox from 'components/common/controls/Checkbox'; import DropZone from 'components/common/DropZone'; import Select from 'react-dropdown-select'; import { getTags } from 'selectors/snippets'; export class NewSnippet extends React.Component { state = { public: getSetting('defaultNewIsPublic', false), description: '', files: [], tags: [] }; componentDidMount() { gaPage('Add new'); this.addFile(); } setDescription = debounce(300, (description) => { this.setState({ description }); }); setFileData = (value, id, type) => { const { files } = this.state; const indexofFile = findIndex({ uuid: id }, files); const newFiles = set([indexofFile, type], value, files); this.setState({ files: newFiles }); }; setFileDataDebounced = debounce(300, this.setFileData); togglePublic = () => { this.setState((prevState) => ({ public: !prevState.public })); }; addFile = (name, content = '') => { const fileStructure = { uuid: uuid.v4(), name: name || randomString(5), language: getSetting('setings-default-new-snippet-language', 'Text'), content }; this.setState((prevState) => ({ files: [...prevState.files, fileStructure] })); }; deleteFile = (id) => { const { files } = this.state; const updatedFiles = filter((file) => file.uuid !== id, files); this.setState({ files: updatedFiles }); }; save = () => { this.props.createSnippet({ description: `${this.state.description || DEFAULT_SNIPPET_DESCRIPTION} ${map( 'value', this.state.tags ).join(' ')}`, isPublic: this.state.public, files: prepareFiles(this.state.files) }); }; seTags = (tagList) => { const tags = map((tag) => { if (!startsWith('#', tag.value)) { return set('value', `#${tag.value}`, tag); } return tag; }, tagList); this.setState({ tags }); }; mapArrayToSelectObject = (array) => map((key) => ({ label: key, value: key }), array); customDropdownRenderer = ({ props, state, methods }) => { const regexp = new RegExp(state.search, 'i'); return ( <div> <SearchAndToggle color={ props.color }> <input type="text" value={ state.search } autoFocus onChange={ methods.setSearch } placeholder="Find language"/> </SearchAndToggle> <Items> {props.options .filter((item) => regexp.test(item[props.searchBy] || item[props.labelField])) .map((option) => { if (!props.keepSelectedInList && methods.isSelected(option)) { return null; } return ( <Item disabled={ option.disabled } key={ option[props.valueField] } onClick={ option.disabled ? null : () => methods.addItem(option) }> <ItemLabel>{option[props.labelField]}</ItemLabel> </Item> ); })} </Items> </div> ); }; render() { const { theme, tags } = this.props; const languageFromSettings = getSetting('setings-default-new-snippet-language', 'Text'); return ( <Wrapper> <Side> <SideInner> <DropZone onAddFile={ this.addFile }/> <H1> <strong>New {this.state.public ? 'public' : 'private'} snippet:</strong>{' '} {this.state.description} </H1> <DescriptionSection> <StyledInput type="text" onChange={ (event) => this.setDescription(event.target.value) } placeholder={ `Description (default ${DEFAULT_SNIPPET_DESCRIPTION})` }/> <StyledSelect multi create style={ { zIndex: 2 } } createNewLabel="add '{search}' tag" values={ this.state.tags } options={ map( (tag) => ({ label: startsWith('#', tag) ? replace('#', '', tag) : tag, value: tag }), tags ) } color={ theme.baseAppColor } keepSelectedInList={ false } dropdownHeight="200px" addPlaceholder="+ Add more" placeholder="Add tags" onChange={ (values) => this.seTags(values) }/> </DescriptionSection> <Section> <StyledCheckbox checked={ this.state.public } value={ getSetting('defaultNewIsPublic', false) } onChange={ () => this.togglePublic() }/> &nbsp; <span> Public snippet &nbsp; <ExternalLink href="https://help.github.com/articles/about-gists/#types-of-gists"> <Icon type="info" size="16" color={ theme.baseAppColor }/> </ExternalLink> </span> </Section> <ButtonsSection> <Router> <StyledButton icon="arrow-left" invert> <StyledLink to="/">Back to list</StyledLink> </StyledButton> </Router> <StyledButton invert icon="add" onClick={ () => this.addFile() }> Add file </StyledButton> <StyledButton icon="success" onClick={ () => this.save() } disabled={ isEmpty(this.state.files) }> Save </StyledButton> </ButtonsSection> </SideInner> </Side> <Files> {map( (file) => ( <FileSection key={ file.uuid }> <div> <StyledFileName type="text" value={ file.name } onChange={ (event) => this.setFileDataDebounced(event.target.value, file.uuid, 'name') } placeholder="file.ext"/> <StyledSelect values={ [ { label: languageFromSettings, value: languageFromSettings } ] } color={ theme.baseAppColor } contentRenderer={ ({ state }) => ( <div>{state.values && state.values[0].label}</div> ) } dropdownRenderer={ this.customDropdownRenderer } placeholder="Select language" options={ this.mapArrayToSelectObject(keys(syntaxMap)) } onChange={ (value) => this.setFileDataDebounced(get('value', head(value)), file.uuid, 'language') }/> <StyledDeleteButton icon="delete" invert onClick={ () => this.deleteFile(file.uuid) }> {truncate({ length: 15 }, file.name) || 'this file'} </StyledDeleteButton> </div> <br/> <br/> <Editor file={ file } isNew id={ file.uuid } onChange={ (value) => this.setFileDataDebounced(value, file.uuid, 'content') }/> </FileSection> ), this.state.files )} </Files> </Wrapper> ); } } const mapStateToProps = (state) => ({ theme: get(['ui', 'settings', 'theme'], state), tags: getTags(state) }); NewSnippet.propTypes = { createSnippet: PropTypes.func, theme: PropTypes.object, tags: PropTypes.array }; export default connect( mapStateToProps, { createSnippet: snippetActions.createSnippet } )(NewSnippet); const Wrapper = styled.div` display: flex; `; const Side = styled.div` width: 310px; height: calc(100vh - 137px); position: relative; `; const SideInner = styled.div` position: fixed; width: 275px; height: calc(100vh - 137px); `; const Files = styled.div` width: calc(100% - 137px); margin: -20px 0 0 30px; `; const StyledInput = styled(Input)` margin: 0; text-indent: 10px; width: 100%; z-index: 1; `; const StyledFileName = styled(StyledInput)` width: 40%; flex: 1; margin: 0 20px 0 0; `; const StyledCheckbox = styled(Checkbox)` margin: 0 10px 0 0; `; const Section = styled.div` margin: 20px 0; flex-direction: column; `; const DescriptionSection = styled(Section)` display: flex; `; const FileSection = styled(Section)` border: 1px solid ${(props) => props.theme.baseAppColor}; padding: 20px; border-radius: 3px; > div { display: flex; justify-content: space-between; align-items: center; height: 0; margin: 10px 0; } &:last-of-type { height: calc(100vh - 178px); } `; const StyledButton = styled(Button)``; const StyledDeleteButton = styled(StyledButton)` line-height: 21px; margin: 0 0 0 20px; width: auto; color: ${(props) => props.theme.colorDanger}; border-color: ${(props) => props.theme.colorDanger}; span { background-color: ${(props) => props.theme.colorDanger}; } `; const H1 = styled.h1` font-weight: 300; font-size: 22px; `; const ButtonsSection = styled.section` position: absolute; bottom: 0; padding: 20px 0 0; margin: 0; display: flex; justify-content: space-between; width: 100%; z-index: 1; `; const StyledLink = styled(Link)` color: ${(props) => props.theme.baseAppColor}; text-decoration: none; line-height: 25px; `; const StyledSelect = styled(Select)` background: #fff; border: none !important; border-bottom: 1px solid ${(props) => props.theme.baseAppColor} !important; border-radius: 0 !important; padding: 0 10px; min-height: 28px !important; z-index: 2; margin: 20px 0; width: 267px !important; `; const SearchAndToggle = styled.div` display: flex; flex-direction: column; input { margin: 10px 10px 0; line-height: 30px; padding: 0 10px; border: 1px solid #ccc; border-radius: 3px; :focus { outline: none; } } `; const Items = styled.div` overflow: auto; min-height: 10px; max-height: 200px; `; const Item = styled.div` display: flex; align-items: baseline; ${({ disabled }) => disabled && 'text-decoration: line-through;'}; cursor: pointer; :hover { background: ${(props) => hexToRGBA(props.theme.baseAppColor, 0.1)}; } :first-child { margin-top: 10px; } :last-child { margin-bottom: 10px; } `; const ItemLabel = styled.div` margin: 5px 10px; `;
examples/src/components/SelectedValuesField.js
PetrGlad/react-select
import React from 'react'; import Select from 'react-select'; function logChange() { console.log.apply(console, [].concat(['Select value changed:'], Array.prototype.slice.apply(arguments))); } var SelectedValuesField = React.createClass({ displayName: 'SelectedValuesField', propTypes: { allowCreate: React.PropTypes.bool, hint: React.PropTypes.string, label: React.PropTypes.string, options: React.PropTypes.array, }, onLabelClick (data, event) { console.log(data, event); }, renderHint () { if (!this.props.hint) return null; return ( <div className="hint">{this.props.hint}</div> ); }, render () { return ( <div className="section"> <h3 className="section-heading">{this.props.label}</h3> <Select allowCreate={this.props.allowCreate} onOptionLabelClick={this.onLabelClick} value={this.props.options.slice(1,3)} multi={true} placeholder="Select your favourite(s)" options={this.props.options} onChange={logChange} /> {this.renderHint()} </div> ); } }); module.exports = SelectedValuesField;
src/routes/Home/components/HomeView.js
foglerek/yn-mafia
import React from 'react' import MafiaImage from '../assets/werewolf.jpg' import classes from './HomeView.scss' import { IndexLink, Link } from 'react-router' // import classes from './Start.scss' import { FormGroup, FormControl, ControlLabel, ButtonToolbar, Button } from 'react-bootstrap'; import { connect } from 'react-redux'; import { bindActionCreators } from 'redux'; import io from 'socket.io-client'; export default React.createClass({ getInitialState() { return { name: '' }; }, addUser() { console.log(this.state.name); this.props.joinGame(this.state.name); }, handleNameChange(e) { this.setState({name: e.target.value}); }, componentWillMount() { }, render() { return (<div> <h4>Welcome!</h4> <img alt='This is a werewolf, because Mafia game!' className={classes.duck} src={MafiaImage} /> <FormGroup> <FormControl type="text" placeholder="Pick a name" onChange={this.handleNameChange} /> </FormGroup> <Button onClick={this.addUser} bsStyle="primary">Join Game</Button> </div>); } }); function mapDispatchToProps(dispatch) { return { ...bindActionCreators({ }), dispatch }; }
src/components/section.js
openregister/specification
import React from 'react'; import PropTypes from 'prop-types'; const Section = ({id, content, children}) => { return ( <section id={`sec-${id}`}> <div dangerouslySetInnerHTML={{__html: content}} /> {children} </section> ); }; Section.propTypes = { id: PropTypes.string.isRequired, content: PropTypes.string.isRequired, children: PropTypes.array }; export default Section;
client/src/app/routes/settings/containers/Students/SpecialServicesForm.js
zraees/sms-project
import React from 'react' import { reset } from 'redux-form' import axios from 'axios' import classNames from 'classnames' import { Field, reduxForm } from 'redux-form' import WidgetGrid from '../../../../components/widgets/WidgetGrid' import Datatable from '../../../../components/tables/Datatable' import {RFField, RFRadioButtonList, RFTextArea } from '../../../../components/ui' import {required, email, number} from '../../../../components/forms/validation/CustomValidation' import AlertMessage from '../../../../components/common/AlertMessage' import {submitStudentSpecialSevices, removeStudentSpecialSevices} from './submit' import {mapForRadioList} from '../../../../components/utils/functions' import { upper } from '../../../../components/utils/normalize' import Msg from '../../../../components/i18n/Msg' class SpecialServicesForm extends React.Component { constructor(props){ super(props); this.state = { studentId: 0, yesNoOptions: [], activeTab: "add", disabledDetails: true } this.handleHasReceivedServiceChange = this.handleHasReceivedServiceChange.bind(this); } componentDidMount(){ axios.get('assets/api/common/YesNo.json') .then(res=>{ const yesNoOptions = mapForRadioList(res.data); this.setState({yesNoOptions}); }); this.setState({studentId: this.props.studentId}); this.props.change('studentId', this.props.studentId); // function provided by redux-form $('#specialServicesGrid').on('click', 'td', function(event) { if ($(this).find('#dele').length > 0) { //alert( $(this).find('#dele').data('tid')); var id = $(this).find('#dele').data('tid'); removeStudentSpecialSevices(id, $(this)); } }); } handleHasReceivedServiceChange(obj, value){ if(value=="Yes"){ this.setState({disabledDetails:true}); } else{ this.setState({disabledDetails:false}); } } // render() { const { handleSubmit, pristine, reset, submitting, touched, error, warning } = this.props const { studentId, activeTab, disabledDetails, yesNoOptions } = this.state; return ( <WidgetGrid> <div className="tabbable tabs"> <ul className="nav nav-tabs"> <li id="tabAddLink" className="active"> <a id="tabAddSpecialService" data-toggle="tab" href="#A11A2"><Msg phrase="AddText" /></a> </li> <li id="tabListLink"> <a id="tabListSpecialService" data-toggle="tab" href="#B11B2"><Msg phrase="ListText" /></a> </li> </ul> <div className="tab-content"> <div className="tab-pane active" id="A11A2"> <form id="form-special-services" className="smart-form" onSubmit={handleSubmit((values)=>{submitStudentSpecialSevices(values, studentId)})}> <fieldset> <div className="row"> <section className="remove-col-padding col-sm-12 col-md-12 col-lg-12"> <Field name="specialServiceName" labelClassName="input" labelIconClassName="icon-append fa fa-book" component={RFTextArea} maxLength="500" type="text" label="SpecialServiceNameText" placeholder="Please enter special service that your child ever evaluated. e.g: Speech/Language therapy, counseling, wears hearing aids or others"/> </section> </div> <div className="row"> <section className="remove-col-padding col-sm-6 col-md-6 col-lg-6"> <Field component={RFRadioButtonList} name="hasReceivedService" required={true} label="ChooseYesIfReceivedSpeicalServiceText" onChange={this.handleHasReceivedServiceChange} options={yesNoOptions} /> </section> <section className="remove-col-padding col-sm-6 col-md-6 col-lg-6"> </section> </div> <div className="row"> <section className="remove-col-padding col-sm-12 col-md-12 col-lg-12"> <Field name="details" labelClassName="input" labelIconClassName="icon-append fa fa-book" component={RFTextArea} maxLength="500" type="text" label="DetailsText" placeholder="Please enter details about the special service"/> </section> </div> {(error!==undefined && <AlertMessage type="w" icon="alert-danger" message={error} />)} <Field component="input" type="hidden" name="studentId" /> <footer> <button type="button" disabled={pristine || submitting} onClick={reset} className="btn btn-primary"> <Msg phrase="ResetText"/> </button> <button type="submit" disabled={pristine || submitting} className="btn btn-primary"> <Msg phrase="SaveText"/> </button> </footer> </fieldset> </form> </div> <div className="tab-pane table-responsive" id="B11B2"> <Datatable id="specialServicesGrid" options={{ ajax: {"url": getWebApiRootUrl() +'/api/StudentSiblings/' + studentId, "dataSrc": ""}, columnDefs: [ { "render": function ( data, type, row ) { return '<a id="dele" data-tid="' + data + '"><i class=\"glyphicon glyphicon-trash\"></i><span class=\"sr-only\">Edit</span></a>'; }.bind(self), "className": "dt-center", "sorting": false, "targets": 6 } ], columns: [ {data: "SpecialServiceName"}, {data: "Details"}, {data: "StudentSpecialServiceID"} ], buttons: [ 'copy', 'excel', 'pdf' ] }} paginationLength={true} className="table table-striped table-bordered table-hover" width="100%"> <thead> <tr> <th data-hide="mobile-p"><Msg phrase="SpecialServiceNameText"/></th> <th data-class="expand"><Msg phrase="DetailsText"/></th> <th data-hide="mobile-p"></th> </tr> </thead> </Datatable> </div> </div> </div> </WidgetGrid> ) } } const afterSubmit = function(result, dispatch) { dispatch(reset('SpecialServicesForm')); } export default reduxForm({ form: 'SpecialServicesForm', // a unique identifier for this form onSubmitSuccess: afterSubmit, keepDirtyOnReinitialize: false })(SpecialServicesForm)
src/components/HeaderLoggedOut.js
vitorbarbosa19/ziro-online
import React from 'react' import Headroom from 'react-headroom' import Link from 'gatsby-link' import { Image } from 'cloudinary-react' import { buttonStyleBright } from '../styles/styles' import normalizeTitle from '../utils/normalizeTitle' export default (props) => ( <Headroom style={{ background: '#303E4D', boxShadow: '0 1px 6px 1px rgba(0,0,0,0.3)' }}> <div style={{ margin: '0 auto', maxWidth: '400px', padding: '1.2rem', display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}> <Link to='/' style={{ display: 'flex', alignItems: 'center' }}> <Image style={{ margin: '0' }} cloudName='ziro' width='80' publicId='logo-original_lork1u' version='1508000699' format='png' secure='true' /> </Link> {props.page === '/' ? <Link to='/' style={{ color: '#fff', fontFamily: 'hind vadodara', fontSize: '16px', display: 'flex', alignItems: 'center' }}> Catálogo </Link> : null} {props.page === '/' ? null : <div style={{ display: 'flex' }}> <a onClick={props.goBack} href='#' style={{ color: '#fff', fontFamily: 'hind vadodara', fontSize: '16px', display: 'flex', alignItems: 'center' }}> <Image style={{ margin: '0 3px 0 0' }} cloudName='ziro' width='12' publicId='back-arrow_xdfk21' version='1508000698' format='png' secure='true' /> {normalizeTitle(props.page)} </a> </div>} {props.page === '/login' ? null : <Link to='/login' style={buttonStyleBright}> Login </Link> } </div> </Headroom> )
hologram/app/index.js
dollars0427/hologram-widget
import 'core-js/fn/array/find-index'; import React from 'react'; import ReactDOM from 'react-dom'; import {Provider} from 'react-redux'; import {applyMiddleware, createStore} from 'redux'; import logger from 'redux-logger'; import previewsReducers from './reducers/'; import PreviewCom from './components/Preview'; import {addFiles} from './actions'; window.hologram = function (element, option) { let store = createStore(previewsReducers, {}, applyMiddleware( logger )); ReactDOM.render( <div> <Provider store={store}> <PreviewCom {... option}/> </Provider> </div>, element ); return { store, addFiles, } }
src/js/components/icons/base/Splits.js
odedre/grommet-final
/** * @description Splits SVG Icon. * @property {string} a11yTitle - Accessibility Title. If not set uses the default title of the status icon. * @property {string} colorIndex - The color identifier to use for the stroke color. * If not specified, this component will default to muiTheme.palette.textColor. * @property {xsmall|small|medium|large|xlarge|huge} size - The icon size. Defaults to small. * @property {boolean} responsive - Allows you to redefine what the coordinates. * @example * <svg width="24" height="24" ><path d="M1,22 L23,22 L23,2 L1,2 L1,22 Z M8,2 L8,22 L8,2 Z M16,2 L16,22 L16,2 Z"/></svg> */ // (C) Copyright 2014-2015 Hewlett Packard Enterprise Development LP import React, { Component } from 'react'; import PropTypes from 'prop-types'; import classnames from 'classnames'; import CSSClassnames from '../../../utils/CSSClassnames'; import Intl from '../../../utils/Intl'; import Props from '../../../utils/Props'; const CLASS_ROOT = CSSClassnames.CONTROL_ICON; const COLOR_INDEX = CSSClassnames.COLOR_INDEX; export default class Icon extends Component { render () { const { className, colorIndex } = this.props; let { a11yTitle, size, responsive } = this.props; let { intl } = this.context; const classes = classnames( CLASS_ROOT, `${CLASS_ROOT}-splits`, className, { [`${CLASS_ROOT}--${size}`]: size, [`${CLASS_ROOT}--responsive`]: responsive, [`${COLOR_INDEX}-${colorIndex}`]: colorIndex } ); a11yTitle = a11yTitle || Intl.getMessage(intl, 'splits'); const restProps = Props.omit(this.props, Object.keys(Icon.propTypes)); return <svg {...restProps} version="1.1" viewBox="0 0 24 24" width="24px" height="24px" role="img" className={classes} aria-label={a11yTitle}><path fill="none" stroke="#000" strokeWidth="2" d="M1,22 L23,22 L23,2 L1,2 L1,22 Z M8,2 L8,22 L8,2 Z M16,2 L16,22 L16,2 Z"/></svg>; } }; Icon.contextTypes = { intl: PropTypes.object }; Icon.defaultProps = { responsive: true }; Icon.displayName = 'Splits'; Icon.icon = true; Icon.propTypes = { a11yTitle: PropTypes.string, colorIndex: PropTypes.string, size: PropTypes.oneOf(['xsmall', 'small', 'medium', 'large', 'xlarge', 'huge']), responsive: PropTypes.bool };
components/Layout/Header.js
raffidil/garnanain
/** * React Static Boilerplate * https://github.com/kriasoft/react-static-boilerplate * * Copyright © 2015-present Kriasoft, LLC. All rights reserved. * * This source code is licensed under the MIT license found in the * LICENSE.txt file in the root directory of this source tree. */ import React from 'react'; import Navigation from './Navigation'; import Link from '../Link'; import s from './Header.css'; import logo from './logo.svg'; class Header extends React.Component { componentDidMount() { window.componentHandler.upgradeElement(this.root); } componentWillUnmount() { window.componentHandler.downgradeElements(this.root); } render() { return ( <header className={`mdl-layout__header ${s.header}`} ref={node => (this.root = node)}> <div className={`mdl-layout__header-row ${s.row}`}> <img className={s.logo} src={logo} alt="Smiley face" height="42" width="42" /> <Link style={{marginLeft: '70px'}} className={`mdl-layout-title ${s.title}`} to="/"> Ն. Ջ. Հայ Մ. Մ. «Արարատ» Միութեան Ուսանողական Միաւոր </Link> <div className="mdl-layout-spacer"/> <Navigation/> </div> </header> ); } } export default Header;
examples/create-react-app/src/App.js
jzhang300/carbon-components-react
import 'carbon-components/scss/globals/scss/styles.scss'; import React, { Component } from 'react'; import { Accordion, AccordionItem } from 'carbon-components-react'; import logo from './logo.svg'; import './App.scss'; class App extends Component { render() { return ( <div> <div className="App"> <header className="App-header"> <img src={logo} className="App-logo" alt="logo" /> <h1 className="App-title">Welcome to React, with Carbon!</h1> </header> <p className="App-intro"> To get started, edit <code>src/App.js</code> and save to reload. </p> </div> <article className="App__demo"> <h3 className="App__demo-title">Carbon Components</h3> <Accordion> <AccordionItem title="Example"> <p> This is a Component imported from Carbon and styled with the CSS from the main Carbon Components GitHub repo! </p> </AccordionItem> <AccordionItem title="Questions?"> <p> Hi there!{' '} <span aria-label="Hand wave" role="img"> 👋{' '} </span>{' '} if you have any questions about this demo, or are running into any issues setting this up in your own development environment, please feel free to reach out to us on Slack or make an issue on the GitHub Repository. </p> </AccordionItem> </Accordion> </article> </div> ); } } export default App;
examples/js/cell-edit/blur-to-save-table.js
pvoznyuk/react-bootstrap-table
/* eslint max-len: 0 */ import React from 'react'; import { BootstrapTable, TableHeaderColumn } from 'react-bootstrap-table'; const products = []; function addProducts(quantity) { const startId = products.length; for (let i = 0; i < quantity; i++) { const id = startId + i; products.push({ id: id, name: 'Item name ' + id, price: 2100 + i }); } } addProducts(5); const cellEditProp = { mode: 'click', blurToSave: true }; export default class BlurToSaveTable extends React.Component { render() { return ( <BootstrapTable data={ products } cellEdit={ cellEditProp }> <TableHeaderColumn dataField='id' isKey={ true }>Product ID</TableHeaderColumn> <TableHeaderColumn dataField='name'>Product Name</TableHeaderColumn> <TableHeaderColumn dataField='price'>Product Price</TableHeaderColumn> </BootstrapTable> ); } }