path
stringlengths
5
195
repo_name
stringlengths
5
79
content
stringlengths
25
1.01M
style-guide/src/pages/404.js
opentable/design-tokens
import React from 'react'; import styles from '../styles/index.module.scss'; import SectionHeader from '../components/section-header'; import withLayout from '../hocs/withLayout'; export default withLayout(() => { return ( <div className={styles.mainContainer}> <SectionHeader text="Whoops" /> <p>404</p> </div> ); });
src/modules/Components/User/Views/Resources/Internships.js
rtellez700/MESA_Connect_2.0
import React, { Component } from 'react'; class Internships extends Component { render() { return ( <div className="display--in-center"> <h1> Hello from Internships.js! </h1> </div> ); } } module.exports = Internships;
src/components/Github.js
qkevinto/kevinto.me
import React from 'react'; import formatDistanceToNow from 'date-fns/formatDistanceToNow'; import SocialActivity from './SocialActivity'; export default class Github extends React.Component { constructor() { super(); this.state = { appURL: 'https://github.com/', loading: true, error: false, username: 'qkevinto', network: 'GitHub', }; } componentDidMount() { fetch(`https://api.github.com/users/${this.state.username}/events`) .then(response => response.json()) .then(response => { const latestEvent = response[0]; /** * Maps a bunch of eventTypes that GitHub returns into some readable * and more coherent strings. */ const eventType = { 'CommitCommentEvent': 'Commented on a commit in', 'CreateEvent': 'Created', 'DeleteEvent': 'Deleted', 'ForkEvent': 'Forked', 'GollumEvent': 'Changed Wiki for', 'IssueCommentEvent': 'Changed issue comment in', 'IssuesEvent': 'Changed an issue in', 'MemberEvent': 'Changed members in', 'PublicEvent': 'Made public: ', 'PullRequestEvent': 'Made a pull request to', 'PullRequestReviewCommentEvent': 'Commented on a pull request in', 'PushEvent': 'Pushed changes to', 'ReleaseEvent': 'Created a new release for', 'WatchEvent': 'Starred' }; this.setState({ loading: false, content: `${eventType[latestEvent.type]} ${latestEvent.repo.name}`, link: `${this.state.appURL}${latestEvent.repo.name}`, metaPrimary: formatDistanceToNow(new Date(latestEvent.created_at), {addSuffix: true}) }); }) .catch((error) => { throw new Error(error); this.setState({ error: true }); }); } render() { return ( <SocialActivity loading={this.state.loading} error={this.state.error} link={this.state.link} username={this.state.username} network={this.state.network} content={this.state.content} link={this.state.link} metaPrimary={this.state.metaPrimary}></SocialActivity> ); } }
src/containers/pages/create-deck/after-class-selection/right-container/topbar-assets/decklength.js
vFujin/HearthLounge
import React from 'react'; import PropTypes from 'prop-types'; const Decklength = ({deck, maxLength = 30}) => { return ( <div className="deck-length"> <p>{deck.length} / {maxLength}</p> </div> ) }; Decklength.propTypes = { deck: PropTypes.arrayOf(PropTypes.object), maxLength: PropTypes.number, showLabel: PropTypes.string }; Decklength.defaultProps = { deck: [], maxLength: 30 }; export default Decklength;
app/javascript/mastodon/features/list_timeline/index.js
pixiv/mastodon
import React from 'react'; import { connect } from 'react-redux'; import PropTypes from 'prop-types'; import ImmutablePropTypes from 'react-immutable-proptypes'; import StatusListContainer from '../ui/containers/status_list_container'; import Column from '../../components/column'; import { addColumn, removeColumn, moveColumn } from '../../actions/columns'; import { FormattedMessage, defineMessages, injectIntl } from 'react-intl'; import { connectListStream } from '../../actions/streaming'; import { expandListTimeline } from '../../actions/timelines'; import { fetchList, deleteList } from '../../actions/lists'; import { openModal } from '../../actions/modal'; import MissingIndicator from '../../components/missing_indicator'; import LoadingIndicator from '../../components/loading_indicator'; import ColumnHeader from '../../../pawoo/components/animated_timeline_column_header'; const messages = defineMessages({ deleteMessage: { id: 'confirmations.delete_list.message', defaultMessage: 'Are you sure you want to permanently delete this list?' }, deleteConfirm: { id: 'confirmations.delete_list.confirm', defaultMessage: 'Delete' }, }); const mapStateToProps = (state, props) => ({ list: state.getIn(['lists', props.params.id]), hasUnread: state.getIn(['timelines', `list:${props.params.id}`, 'unread']) > 0, }); @connect(mapStateToProps) @injectIntl export default class ListTimeline extends React.PureComponent { static contextTypes = { router: PropTypes.object, pawooPushHistory: PropTypes.func, }; static propTypes = { params: PropTypes.object.isRequired, dispatch: PropTypes.func.isRequired, columnId: PropTypes.string, hasUnread: PropTypes.bool, multiColumn: PropTypes.bool, list: PropTypes.oneOfType([ImmutablePropTypes.map, PropTypes.bool]), intl: PropTypes.object.isRequired, pawoo: ImmutablePropTypes.map.isRequired, }; handlePin = () => { const { columnId, dispatch } = this.props; if (columnId) { dispatch(removeColumn(columnId)); } else { dispatch(addColumn('LIST', { id: this.props.params.id })); this.context.pawooPushHistory('/', true); } } handleMove = (dir) => { const { columnId, dispatch } = this.props; dispatch(moveColumn(columnId, dir)); } handleHeaderClick = () => { this.column.scrollTop(); } componentDidMount () { const { dispatch } = this.props; const { id } = this.props.params; dispatch(fetchList(id)); dispatch(expandListTimeline(id)); this.disconnect = dispatch(connectListStream(id)); } componentWillUnmount () { if (this.disconnect) { this.disconnect(); this.disconnect = null; } } setRef = c => { this.column = c; } handleLoadMore = maxId => { const { id } = this.props.params; this.props.dispatch(expandListTimeline(id, { maxId })); } handleEditClick = () => { this.props.dispatch(openModal('LIST_EDITOR', { listId: this.props.params.id })); } handleDeleteClick = () => { const { dispatch, columnId, intl } = this.props; const { id } = this.props.params; dispatch(openModal('CONFIRM', { message: intl.formatMessage(messages.deleteMessage), confirm: intl.formatMessage(messages.deleteConfirm), onConfirm: () => { dispatch(deleteList(id)); if (!!columnId) { dispatch(removeColumn(columnId)); } else { this.context.pawooPushHistory('/lists'); } }, })); } render () { const { hasUnread, columnId, multiColumn, list, pawoo } = this.props; const { id } = this.props.params; const pinned = !!columnId; const title = list ? list.get('title') : id; if (typeof list === 'undefined') { return ( <Column> <div className='scrollable'> <LoadingIndicator /> </div> </Column> ); } else if (list === false) { return ( <Column> <div className='scrollable'> <MissingIndicator /> </div> </Column> ); } return ( <Column ref={this.setRef}> <ColumnHeader icon='bars' active={hasUnread} title={title} onPin={this.handlePin} onMove={this.handleMove} onClick={this.handleHeaderClick} pinned={pinned} multiColumn={multiColumn} pawoo={pawoo} pawooUrl={`/timelines/list/${id}`} timelineId={`list:${id}`} > <div className='column-header__links'> <button className='text-btn column-header__setting-btn' tabIndex='0' onClick={this.handleEditClick}> <i className='fa fa-pencil' /> <FormattedMessage id='lists.edit' defaultMessage='Edit list' /> </button> <button className='text-btn column-header__setting-btn' tabIndex='0' onClick={this.handleDeleteClick}> <i className='fa fa-trash' /> <FormattedMessage id='lists.delete' defaultMessage='Delete list' /> </button> </div> <hr /> </ColumnHeader> <StatusListContainer scrollKey={`list_timeline-${columnId}`} timelineId={`list:${id}`} onLoadMore={this.handleLoadMore} emptyMessage={<FormattedMessage id='empty_column.list' defaultMessage='There is nothing in this list yet. When members of this list post new statuses, they will appear here.' />} /> </Column> ); } }
src/routes/home/ActiveOpt/ActiveOpt.js
globalART19/OrderedOptions
/** * 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 withStyles from 'isomorphic-style-loader/lib/withStyles'; import s from './ActiveOpt.css'; // import Link from '../Link'; import ActiveOptTable from '../ActiveOptTable'; // const activeOptList = [ // { stock: 'TSLA', stockPrice: 167.45, optDetails: 'TSLA170217C00165000', optValue: 54.95, gainLoss: 12 }, // { stock: 'MSFT', stockPrice: 64.00, optDetails: 'MSFT170217C00064000', optValue: 0.30, gainLoss: -0.02 }, // ]; class ActiveOpt extends React.Component { constructor(props) { super(props); this.state = { // activeOptList: [], stock: '', stockPrice: null, optDetails: '', optValue: null, gainLoss: null, }; } render() { // const activeOptList = [ // { stock: 'TSLA', stockPrice: 167.45, // optDetails: 'TSLA170217C00165000', optValue: 54.95, gainLoss: 12 }, // { stock: 'MSFT', stockPrice: 64.00, // optDetails: 'MSFT170217C00064000', optValue: 0.30, gainLoss: -0.02 }, // ]; return ( <div className={s.root}> <div className={s.container}> <h3>Active Options</h3> <div> <ActiveOptTable /> {/* activeOptList={activeOptList} */} </div> </div> </div> ); } } // class ActiveOptTable extends React.Component { // // render() { // const rows = []; // activeOptList.forEach((activeOptListItem) => { // rows.push(<ActiveOptRow activeOptListItem={activeOptListItem} key={activeOptListItem.stock} />); // }); // return ( // <table> // <thead> // <tr> // <th className="Stock">Stock</th> // <th className="Stock-price">Stock Price</th> // <th className="Opt-details">Option Details</th> // <th className="Opt-value">Opt Value</th> // <th className="Gain-loss">+/-</th> // </tr> // </thead> // <tbody> // {/* <tr>Covered Calls: </tr> */} // {rows} // </tbody> // </table> // ); // } // } // // class ActiveOptRow extends React.Component { // render() { // const { activeOptListItem } = this.props; // return ( // <tr> // <td>{activeOptListItem.stock}</td> // <td>{activeOptListItem.stockPrice}</td> // <td>{activeOptListItem.optDetails}</td> // <td>{activeOptListItem.optValue}</td> // <td>{activeOptListItem.gainLoss}</td> // </tr> // ); // } // } export default withStyles(s)(ActiveOpt);
src/Contact/index.js
pulse-opensource/pulselabs-homepage
import React from 'react'; export default function() { return <div>CONTACT</div>; }
src/index.js
CianCoders/react-stroke-7
import React from 'react' /** * A React component for the font-awesome icon library. * * * @param {Boolean} [border=false] Whether or not to show a border radius * @param {String} [className] An extra set of CSS classes to add to the component * @param {Boolean} [fixedWidth=false] Make buttons fixed width * @param {String} [flip=false] Flip the icon's orientation. * @param {Boolean} [inverse=false]Inverse the icon's color * @param {Boolean} [li=false] Icon replaces `<li>` bullets (has to be used inside `<ul className='pe-ul'>` tags) * @param {String} name Name of the icon to use * @param {Number} [rotate] The degress to rotate the icon by * @param {String} [size] The icon scaling size * @param {Boolean} [spin=false] Spin the icon * @param {Boolean} [va=false] Align at the middle of the text * @param {String} [stack] Stack an icon on top of another * @module Stroke7 * @type {ReactClass} */ export default React.createClass({ displayName: 'Stroke7', propTypes: { border: React.PropTypes.bool, className: React.PropTypes.string, fixedWidth: React.PropTypes.bool, flip: React.PropTypes.oneOf([ 'horizontal', 'vertical' ]), inverse: React.PropTypes.bool, li: React.PropTypes.bool, name: React.PropTypes.string.isRequired, rotate: React.PropTypes.oneOf([ 90, 180, 270 ]), size: React.PropTypes.oneOf([ 'lg', '2x', '3x', '4x', '5x' ]), spin: React.PropTypes.bool, stack: React.PropTypes.oneOf([ '1x', '2x' ]), va: React.PropTypes.bool, }, render() { let { border, fixedWidth, flip, inverse, name, rotate, size, spin, stack, li, va, ...props, } = this.props let className = 'pe-7s-' + name if (size) { className += ' pe-' + size } if (spin) { className += ' pe-spin' } if (border) { className += ' pe-border' } if (fixedWidth) { className += ' pe-fw' } if (inverse) { className += ' pe-inverse' } if (flip) { className += ' pe-flip-' + flip } if (rotate) { className += ' pe-rotate-' + rotate } if (stack) { className += ' pe-stack-' + stack } if (va) { className += ' pe-va' } if (li) { className += ' pe-li' } if (this.props.className) { className += ' ' + this.props.className } return ( <span {...props} className={className} /> ) }, })
app/imports/ui/app/RouteWithSubRoutes.js
raiden-network/raiden-token
import React from 'react'; import { Route } from 'react-router-dom'; const RouteWithSubRoutes = (route) => ( React.createElement(Route, { path: route.path, render: props => ( React.createElement(route.component, { ...route, ...props }) ) }) ); export default RouteWithSubRoutes;
src/svg-icons/action/description.js
frnk94/material-ui
import React from 'react'; import pure from 'recompose/pure'; import SvgIcon from '../../SvgIcon'; let ActionDescription = (props) => ( <SvgIcon {...props}> <path d="M14 2H6c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6zm2 16H8v-2h8v2zm0-4H8v-2h8v2zm-3-5V3.5L18.5 9H13z"/> </SvgIcon> ); ActionDescription = pure(ActionDescription); ActionDescription.displayName = 'ActionDescription'; ActionDescription.muiName = 'SvgIcon'; export default ActionDescription;
src/models/notices/AbstractNoticeModel.js
Pavel-DV/ChronoMint
import React from 'react' import {Record as record} from 'immutable' import {dateFormatOptions} from '../../config' // noinspection JSUnusedLocalSymbols const abstractNoticeModel = defaultValues => class AbstractNoticeModel extends record({ time: Date.now(), ...defaultValues }) { constructor (data) { if (new.target === AbstractNoticeModel) { throw new TypeError('Cannot construct AbstractNoticeModel instance directly') } super(data) } message () { throw new Error('should be overridden') }; date () { let date = new Date(this.get('time')) return date.toLocaleDateString(undefined, dateFormatOptions) + ' ' + date.toTimeString().substr(0, 5) }; historyBlock () { return ( <span> {this.message()} <small style={{display: 'block', marginTop: '-25px'}}>{this.date()}</small> </span> ) } fullHistoryBlock () { return ( <div> {this.message()} <p style={{marginBottom: '0'}}> <small>{this.date()}</small> </p> </div> ) } } export { abstractNoticeModel } export default abstractNoticeModel()
src/static/routes.js
qwertypomy/rental
import React from 'react'; import { Route, IndexRoute } from 'react-router'; import App from './app'; import { HomeView, LoginView, RegisterView, ProfileView, NotFoundView } from './containers'; import requireAuthentication from './utils/requireAuthentication'; export default( <Route path="/" component={App}> <IndexRoute component={HomeView} /> <Route path="login" component={LoginView} /> <Route path="register" component={RegisterView} /> <Route path="profile" component={requireAuthentication(ProfileView)} /> <Route path="*" component={NotFoundView} /> </Route> );
imaginarySet/src/index.js
HJBowers/imaginary-shrew
import React from 'react'; import ReactDOM from 'react-dom'; import App from './App'; import './index.css'; ReactDOM.render( <App />, document.getElementById('root') );
examples/todomvc/index.js
gogobook/redux
import React from 'react'; import App from './containers/App'; import 'todomvc-app-css/index.css'; React.render( <App />, document.getElementById('root') );
src/components/Overlay/Content.js
u-wave/web
import cx from 'clsx'; import React from 'react'; import PropTypes from 'prop-types'; const OverlayContent = ({ className, children, }) => ( <div className={cx('Overlay-content', className)}> {children} </div> ); OverlayContent.propTypes = { className: PropTypes.string, children: PropTypes.node.isRequired, }; export default OverlayContent;
src/components/NavigationBrick/index.js
line64/landricks-components
import React, { Component } from 'react'; import Fontawesome from 'react-fontawesome'; import styler from './styler'; export default class NavigationBrick extends Component { constructor(props){ super(props); this.state = { open : false } } renderItem(item, index, style){ return( <li onClick={ ()=> this.setState({ open : false })} style={ item.highlight ? style.itemHighlight : style.item } key={ index }> { (item.href) ? <a style={ style.itemLink } href={ item.href } >{ item.label }</a> : null } { (item.onClick) ? <button style={ style.itemLink } onClick={ () => item.onClick() } >{ item.label }</button> : null } </li> ) } renderItems(style, items) { if (!items) return null; return items.map((item, index) => { return this.renderItem(item, index, style) }); } renderNavigation(style, items, isCollapsed) { return ( <ul style={{ ...style.navigationContainer, ...(isCollapsed ? style.collapsedContainer : {}) }}> { this.renderItems(style, items) } </ul> ); } renderLogo(style) { let { logo, brand } = this.props; return ( <span style={ style.collapsedHeader }> { logo ? ( <img style={ style.logo } src={ logo } /> ) : null } { brand ? ( <span style={ style.brand }>{ brand }</span> ) : null } </span> ); } renderFullWidth(style) { return( <nav style={ style.box }> <div style={ style.boxContent }> <ul style={ style.logoContainer }> { this.renderLogo(style) } </ul> { this.renderNavigation(style, this.props.items, false) } </div> </nav> ) } renderCollapsed(style) { return( <nav style={style.collapsed.box}> <Fontawesome name={ (this.state.open) ? 'times' : 'bars' } style={ style.menuIcon } onClick={ ()=> this.setState({ open : !this.state.open }) } /> { this.renderLogo(style) } { this.renderCollapsedContent(style) } </nav> ) } renderCollapsedContent(style){ let visible = { ...style.menuContent, ...(this.state.open ? style.menuOpen : '') }; return ( <div style={ visible }> { this.renderNavigation(style, this.props.items, true) } </div> ); } render(){ let style = styler(this.props); let { viewport } = this.props; return (viewport == 'xs' || viewport == 'sm') ? this.renderCollapsed(style) : this.renderFullWidth(style); } }
src/svg-icons/device/network-cell.js
manchesergit/material-ui
import React from 'react'; import pure from 'recompose/pure'; import SvgIcon from '../../SvgIcon'; let DeviceNetworkCell = (props) => ( <SvgIcon {...props}> <path fillOpacity=".3" d="M2 22h20V2z"/><path d="M17 7L2 22h15z"/> </SvgIcon> ); DeviceNetworkCell = pure(DeviceNetworkCell); DeviceNetworkCell.displayName = 'DeviceNetworkCell'; DeviceNetworkCell.muiName = 'SvgIcon'; export default DeviceNetworkCell;
src/user/EditUser.js
codyloyd/teamup
import React from 'react' import UserForm from './userForm' class EditUser extends React.Component { render () { return ( <div> <UserForm onSubmit={console.log} /> </div> ) } } export default EditUser
__fixtures__/RootComponent.js
divyagnan/react-simple-theme
import React from 'react' /* eslint-disable react/prefer-stateless-function, react/prop-types */ export default class RootComponent extends React.Component { render() { return ( <div> Hi, Im the root Component! <button onClick={() => this.props.changeTheme('theme2')}>Change Theme</button> </div> ) } }
client/analytics/components/partials/LeftSideBar.js
Haaarp/geo
import React from 'react'; import axios from 'axios'; import { bindActionCreators } from 'redux'; import { connect } from 'react-redux'; import { analytics, common } from './../../actions'; import * as MenuType from './../../constants/popupType'; import LeftSideBarHeader from './sideBar/LeftSideBarHeader'; import LeftSideBar from 'konux/common/components/LeftSideBar'; import Scrollbars from 'konux/common/components/Scrollbars'; import Filter from './filter'; class SideBarPullLeft extends React.Component { constructor(props){ super(props); this.cancelToken = axios.CancelToken.source(); } render(){ return( <LeftSideBar> <LeftSideBarHeader /> <Scrollbars renderTrackHorizontal="track-horizontal" renderTrackVertical="track-vertical" renderView="filter-list-view"> <Filter /> </Scrollbars> </LeftSideBar> ); } } export default SideBarPullLeft;
frontend/src/components/icons/Home.js
webrecorder/webrecorder
import React from 'react'; function Home() { return ( <svg width="21px" height="17px" viewBox="0 0 21 17" version="1.1" xmlns="http://www.w3.org/2000/svg"> <g stroke="none" strokeWidth="1" fill="none" fillRule="evenodd"> <g id="Index-of-Collection" transform="translate(-29.000000, -14.000000)" fill="#3E3E3E"> <g id="Home-ICO"> <path d="M46.1562091,29.2812493 C46.1562091,29.5156239 46.0741782,29.7148419 45.9101159,29.8789042 C45.7460536,30.0429664 45.5468357,30.1249973 45.3124611,30.1249973 L41.2343458,30.1249973 C41.1171588,30.1249973 41.0175493,30.0839816 40.9355184,30.0019507 C40.8534875,29.9199199 40.8124718,29.8203104 40.8124718,29.7031233 L40.8124718,25.7656327 C40.8124718,25.6484457 40.7714561,25.5488362 40.6894253,25.4668053 C40.6073944,25.3847744 40.5077849,25.3437587 40.3905978,25.3437587 L37.8593539,25.3437587 C37.7421668,25.3437587 37.6425573,25.3847744 37.5605265,25.4668053 C37.4784956,25.5488362 37.4374799,25.6484457 37.4374799,25.7656327 L37.4374799,29.7031233 C37.4374799,29.8203104 37.3964642,29.9199199 37.3144333,30.0019507 C37.2324024,30.0839816 37.1327929,30.1249973 37.0156059,30.1249973 L32.9374906,30.1249973 C32.703116,30.1249973 32.5038981,30.0429664 32.3398358,29.8789042 C32.1757735,29.7148419 32.0937426,29.5156239 32.0937426,29.2812493 L32.0937426,24.2539176 C32.0937426,24.1132929 32.1406173,23.9961059 32.2343673,23.9023559 L38.8437265,18.4883063 C38.9374765,18.417994 39.0312259,18.3828378 39.1249759,18.3828378 C39.2187258,18.3828378 39.3124752,18.417994 39.4062252,18.4883063 L46.0155844,23.9023559 C46.1093344,23.9961059 46.1562091,24.1132929 46.1562091,24.2539176 L46.1562091,29.2812493 Z M49.1093271,22.1093914 C49.1796394,22.1797038 49.2206551,22.2734537 49.2323736,22.3906408 C49.2440922,22.5078278 49.2147956,22.6132963 49.1444832,22.7070463 L48.2655791,23.7968874 C48.1952667,23.8906374 48.1015168,23.9375121 47.9843297,23.9375121 C47.8671427,23.9375121 47.7616742,23.9023559 47.6679242,23.8320436 L39.4062252,17.0469035 C39.3124752,16.9765912 39.2187258,16.941435 39.1249759,16.941435 C39.0312259,16.941435 38.9374765,16.9765912 38.8437265,17.0469035 L30.5820275,23.8320436 C30.4882775,23.9023559 30.382809,23.9375121 30.265622,23.9375121 C30.1484349,23.9375121 30.054685,23.8906374 29.9843727,23.7968874 L29.1054685,22.7070463 C29.0351562,22.6132963 29.0058595,22.5078278 29.0175781,22.3906408 C29.0292966,22.2734537 29.0703123,22.1797038 29.1406247,22.1093914 L38.0702909,14.7617527 C38.3749778,14.503941 38.7265395,14.3750349 39.1249759,14.3750349 C39.5234122,14.3750349 39.886693,14.503941 40.214817,14.7617527 L43.3437158,17.363309 L43.3437158,14.7969089 C43.3437158,14.6797218 43.3847315,14.5801123 43.4667624,14.4980815 C43.5487933,14.4160506 43.6484028,14.3750349 43.7655898,14.3750349 L45.7343351,14.3750349 C45.8515221,14.3750349 45.9511316,14.4160506 46.0331625,14.4980815 C46.1151934,14.5801123 46.1562091,14.6797218 46.1562091,14.7969089 L46.1562091,19.683616 L49.1093271,22.1093914 Z" /> </g> </g> </g> </svg> ); } export default Home;
examples/sidebar/app.js
sprjr/react-router
import React from 'react'; import { Router, Route, Link } from 'react-router'; import data from './data'; var Category = React.createClass({ render() { var category = data.lookupCategory(this.props.params.category); return ( <div> <h1>{category.name}</h1> {this.props.children || ( <p>{category.description}</p> )} </div> ); } }); var CategorySidebar = React.createClass({ render() { var category = data.lookupCategory(this.props.params.category); return ( <div> <Link to="/">◀︎ Back</Link> <h2>{category.name} Items</h2> <ul> {category.items.map((item, index) => ( <li key={index}> <Link to={`/category/${category.name}/${item.name}`}>{item.name}</Link> </li> ))} </ul> </div> ); } }); var Item = React.createClass({ render() { var { category, item } = this.props.params; var menuItem = data.lookupItem(category, item); return ( <div> <h1>{menuItem.name}</h1> <p>${menuItem.price}</p> </div> ); } }); var Index = React.createClass({ render() { return ( <div> <h1>Sidebar</h1> <p> Routes can have multiple components, so that all portions of your UI can participate in the routing. </p> </div> ); } }); var IndexSidebar = React.createClass({ render() { return ( <div> <h2>Categories</h2> <ul> {data.getAll().map((category, index) => ( <li key={index}> <Link to={`/category/${category.name}`}>{category.name}</Link> </li> ))} </ul> </div> ); } }); var App = React.createClass({ render() { var { children } = this.props; return ( <div> <div className="Sidebar"> {children ? children.sidebar : <IndexSidebar />} </div> <div className="Content"> {children ? children.content : <Index />} </div> </div> ); } }); React.render(( <Router> <Route path="/" component={App}> <Route path="category/:category" components={{content: Category, sidebar: CategorySidebar}}> <Route path=":item" component={Item} /> </Route> </Route> </Router> ), document.getElementById('example'));
packages/core/__deprecated__/Link/sandbox.js
romelperez/arwes
import React from 'react'; import Arwes from '../Arwes'; import Link from './index'; export default () => ( <Arwes> <div style={{ padding: 20 }}> This is an <Link href='#'>Intergalactic Link</Link>. </div> </Arwes> );
src/svg-icons/editor/show-chart.js
matthewoates/material-ui
import React from 'react'; import pure from 'recompose/pure'; import SvgIcon from '../../SvgIcon'; let EditorShowChart = (props) => ( <SvgIcon {...props}> <path d="M3.5 18.49l6-6.01 4 4L22 6.92l-1.41-1.41-7.09 7.97-4-4L2 16.99z"/> </SvgIcon> ); EditorShowChart = pure(EditorShowChart); EditorShowChart.displayName = 'EditorShowChart'; EditorShowChart.muiName = 'SvgIcon'; export default EditorShowChart;
frontend/src/components/users/root.js
1905410/Misago
import React from 'react'; // jshint ignore:line import { connect } from 'react-redux'; import DropdownToggle from 'misago/components/dropdown-toggle'; // jshint ignore:line import { TabsNav, CompactNav } from 'misago/components/users/navs'; // jshint ignore:line import ActivePosters from 'misago/components/users/active-posters/root'; // jshint ignore:line import Rank from 'misago/components/users/rank/root'; import WithDropdown from 'misago/components/with-dropdown'; import misago from 'misago/index'; export default class extends WithDropdown { render() { /* jshint ignore:start */ return <div className="page page-users-lists"> <div className="page-header tabbed"> <div className="container"> <h1 className="pull-left">{gettext("Users")}</h1> <DropdownToggle toggleNav={this.toggleNav} dropdown={this.state.dropdown} /> </div> <div className="page-tabs hidden-xs hidden-sm"> <div className="container"> <TabsNav lists={misago.get('USERS_LISTS')} baseUrl={misago.get('USERS_LIST_URL')} /> </div> </div> </div> <div className={this.getCompactNavClassName()}> <CompactNav lists={misago.get('USERS_LISTS')} baseUrl={misago.get('USERS_LIST_URL')} hideNav={this.hideNav} /> </div> {this.props.children} </div>; /* jshint ignore:end */ } } export function select(store) { return { 'tick': store.tick.tick, 'user': store.auth.user, 'users': store.users }; } export function paths() { let paths = []; misago.get('USERS_LISTS').forEach(function(item) { if (item.component === 'rank') { paths.push({ path: misago.get('USERS_LIST_URL') + item.slug + '/:page/', component: connect(select)(Rank), rank: item }); paths.push({ path: misago.get('USERS_LIST_URL') + item.slug + '/', component: connect(select)(Rank), rank: item }); } else if (item.component === 'active-posters'){ paths.push({ path: misago.get('USERS_LIST_URL') + item.component + '/', component: connect(select)(ActivePosters), extra: { name: item.name } }); } }); return paths; }
src/components/Counter.js
nivanson/hapi-universal-redux
import React from 'react'; import Radium from 'radium'; const styles = { base: { paddingBottom: 25 }, counter: { fontSize: '5em', color: 'white', marginLeft: 20 }, inputContainer: { height: 80, width: 40, float: 'left', marginTop: 15 }, button: { height: 38, width: 40, borderRadius: 0, border: '1px #0df solid', padding: '10px', background: 'none', color: 'white', margin: '0 5px', float: 'left' } }; @Radium export default class Counter extends React.Component { static propTypes = { counter: React.PropTypes.number.isRequired, plus: React.PropTypes.func.isRequired, minus: React.PropTypes.func.isRequired } render() { const count = this.props.counter.toString(); const {plus, minus} = this.props; const {base, counter, inputContainer, button} = styles; return ( <div style={base}> <span style={counter}>{count}</span> <div style={inputContainer}> <button style={button} onClick={plus}>+</button> <button style={button} onClick={minus}>-</button> </div> </div> ); } }
fluxible-router/client.js
JonnyCheng/flux-examples
/** * Copyright 2014, Yahoo! Inc. * Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. */ /*global App, document, window */ import React from 'react'; import debug from 'debug'; import app from './app'; import { createElementWithContext } from 'fluxible-addons-react'; const bootstrapDebug = debug('Example'); const dehydratedState = window.App; // Sent from the server window.React = React; // For chrome dev tool support debug.enable('*'); bootstrapDebug('rehydrating app'); app.rehydrate(dehydratedState, function (err, context) { if (err) { throw err; } window.context = context; const mountNode = document.getElementById('app'); bootstrapDebug('React Rendering'); React.render(createElementWithContext(context), mountNode, () => { bootstrapDebug('React Rendered'); }); });
tp-3/marisol/src/components/pages/materias/listado/MateriaListado.js
solp/sovos-reactivo-2017
import React from 'react'; const MateriaListado = () => { return ( <div> <h2>Listado de Materia </h2> <p> aqui va la lista </p> </div> ); }; export default MateriaListado;
tests/progress.js
goto-bus-stop/bulmare
import React from 'react' import test from 'tape' import { shallow } from 'enzyme' import { Progress } from '../src' test('Progress renders a progress bar with class "progress"', (t) => { t.equal( shallow(<Progress />).html(), shallow(<progress className='progress' />).html() ) t.end() }) test('Progress bars support sizes', (t) => { t.ok(shallow(<Progress small />).hasClass('is-small')) t.ok(shallow(<Progress medium />).hasClass('is-medium')) t.ok(shallow(<Progress large />).hasClass('is-large')) t.end() })
app/javascript/mastodon/features/ui/components/column_header.js
ashfurrow/mastodon
import React from 'react'; import PropTypes from 'prop-types'; import classNames from 'classnames'; import Icon from 'mastodon/components/icon'; export default class ColumnHeader extends React.PureComponent { static propTypes = { icon: PropTypes.string, type: PropTypes.string, active: PropTypes.bool, onClick: PropTypes.func, columnHeaderId: PropTypes.string, }; handleClick = () => { this.props.onClick(); } render () { const { icon, type, active, columnHeaderId } = this.props; let iconElement = ''; if (icon) { iconElement = <Icon id={icon} fixedWidth className='column-header__icon' />; } return ( <h1 className={classNames('column-header', { active })} id={columnHeaderId || null}> <button onClick={this.handleClick}> {iconElement} {type} </button> </h1> ); } }
static/src/index.js
mortbauer/webapp
require('expose?$!expose?jQuery!jquery'); require("bootstrap-webpack"); import React from 'react'; import { render } from 'react-dom'; import { browserHistory } from 'react-router' import { syncHistoryWithStore } from 'react-router-redux' import injectTapEventPlugin from 'react-tap-event-plugin'; import 'style.scss'; import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider'; import configureStore from './store/configureStore'; import Root from './containers/Root'; import * as ActionTypes from './constants/index'; injectTapEventPlugin(); const store = configureStore(); const history = syncHistoryWithStore(browserHistory, store) render( <MuiThemeProvider> <Root store={store} history={history}/> </MuiThemeProvider>, document.getElementById('root') );
examples/counter/containers/CounterApp.js
TKHuang/redux
import React, { Component } from 'react'; import { bindActionCreators } from 'redux'; import { connect } from 'redux/react'; import Counter from '../components/Counter'; import * as CounterActions from '../actions/CounterActions'; @connect(state => ({ counter: state.counter })) export default class CounterApp extends Component { render() { const { counter, dispatch } = this.props; return ( <Counter counter={counter} {...bindActionCreators(CounterActions, dispatch)} /> ); } }
fields/types/boolean/BooleanFilter.js
Tangcuyu/keystone
import React from 'react'; import { SegmentedControl } from 'elemental'; const TOGGLE_OPTIONS = [ { label: 'Is Checked', value: true }, { label: 'Is NOT Checked', value: false }, ]; function getDefaultValue () { return { value: true, }; } var BooleanFilter = React.createClass({ propTypes: { filter: React.PropTypes.shape({ value: React.PropTypes.bool, }), }, statics: { getDefaultValue: getDefaultValue, }, getDefaultProps () { return { filter: getDefaultValue(), }; }, updateValue (value) { this.props.onChange({ value }); }, render () { return <SegmentedControl equalWidthSegments options={TOGGLE_OPTIONS} value={this.props.filter.value} onChange={this.updateValue} />; }, }); module.exports = BooleanFilter;
tests/react_experimental/useTransition_hook.js
facebook/flow
// @flow import React from 'react'; React.useTransition(); // Ok React.useTransition({}); // Error: no arguments are expected by function type const [isPending, startTransition] = React.useTransition(); // OK (isPending: boolean); // Ok (startTransition: (() => void) => void); // Ok (isPending: (() => void) => void); // Error: boolean is incompatible with function type (startTransition: boolean); // Error: function type is incompatible with boolean startTransition(() => {}); // Ok startTransition(); // Error: function requires another argument
src/Input.story.js
prometheusresearch/react-ui
/** * @flow */ import React from 'react'; import {storiesOf} from '@kadira/storybook'; import Input from './Input'; storiesOf('<Input />', module) .add('Default state', () => <Input />) .add('Error state', () => <Input error />) .add('Disabled state', () => <Input disabled />) .add('No border variant', () => <Input noBorder />);
src/routes/Workspace/components/Stage/Stage.js
dkushner/ArborJs-Playground
import React from 'react'; import THREE from 'three'; import registerExtras from 'three-orbit-controls'; import classes from './Stage.scss'; import { Renderer, Scene, PerspectiveCamera, AxisHelper, Line } from 'react-three'; const OrbitControls = registerExtras(THREE); class Stage extends React.Component { static propTypes = { width: React.PropTypes.number, height: React.PropTypes.number, points: React.PropTypes.array }; render() { const { width, height, points } = this.props; const cameraProps = { fov: 75, aspect: width / height, near: 1, far: 5000, position: new THREE.Vector3(0, 0, 600), lookat: new THREE.Vector3(0, 0, 0) }; const material = new THREE.LineDashedMaterial({ linewidth: 3, vertexColors: THREE.VertexColors }); const geometry = new THREE.Geometry(); geometry.vertices = points.map((point) => { return point.position; }); geometry.colors = points.map((point) => { return point.color; }); return ( <Renderer width={width} height={height}> <Scene width={width} height={height} camera="camera" orbitControls={OrbitControls}> <PerspectiveCamera name="camera" {...cameraProps} /> <AxisHelper size={20} /> <Line geometry={geometry} material={material} mode={THREE.LinePieces}/> </Scene> </Renderer> ); } } export default Stage;
app/javascript/mastodon/features/home_timeline/index.js
TheInventrix/mastodon
import React from 'react'; import { connect } from 'react-redux'; import { expandHomeTimeline } from '../../actions/timelines'; import PropTypes from 'prop-types'; import StatusListContainer from '../ui/containers/status_list_container'; import Column from '../../components/column'; import ColumnHeader from '../../components/column_header'; import { addColumn, removeColumn, moveColumn } from '../../actions/columns'; import { defineMessages, injectIntl, FormattedMessage } from 'react-intl'; import ColumnSettingsContainer from './containers/column_settings_container'; import { Link } from 'react-router-dom'; const messages = defineMessages({ title: { id: 'column.home', defaultMessage: 'Home' }, }); const mapStateToProps = state => ({ hasUnread: state.getIn(['timelines', 'home', 'unread']) > 0, isPartial: state.getIn(['timelines', 'home', 'items', 0], null) === null, }); export default @connect(mapStateToProps) @injectIntl class HomeTimeline extends React.PureComponent { static propTypes = { dispatch: PropTypes.func.isRequired, shouldUpdateScroll: PropTypes.func, intl: PropTypes.object.isRequired, hasUnread: PropTypes.bool, isPartial: PropTypes.bool, columnId: PropTypes.string, multiColumn: PropTypes.bool, }; handlePin = () => { const { columnId, dispatch } = this.props; if (columnId) { dispatch(removeColumn(columnId)); } else { dispatch(addColumn('HOME', {})); } } handleMove = (dir) => { const { columnId, dispatch } = this.props; dispatch(moveColumn(columnId, dir)); } handleHeaderClick = () => { this.column.scrollTop(); } setRef = c => { this.column = c; } handleLoadMore = maxId => { this.props.dispatch(expandHomeTimeline({ maxId })); } componentDidMount () { this._checkIfReloadNeeded(false, this.props.isPartial); } componentDidUpdate (prevProps) { this._checkIfReloadNeeded(prevProps.isPartial, this.props.isPartial); } componentWillUnmount () { this._stopPolling(); } _checkIfReloadNeeded (wasPartial, isPartial) { const { dispatch } = this.props; if (wasPartial === isPartial) { return; } else if (!wasPartial && isPartial) { this.polling = setInterval(() => { dispatch(expandHomeTimeline()); }, 3000); } else if (wasPartial && !isPartial) { this._stopPolling(); } } _stopPolling () { if (this.polling) { clearInterval(this.polling); this.polling = null; } } render () { const { intl, shouldUpdateScroll, hasUnread, columnId, multiColumn } = this.props; const pinned = !!columnId; return ( <Column ref={this.setRef} label={intl.formatMessage(messages.title)}> <ColumnHeader icon='podcast' active={hasUnread} title={intl.formatMessage(messages.title)} onPin={this.handlePin} onMove={this.handleMove} onClick={this.handleHeaderClick} pinned={pinned} multiColumn={multiColumn} > <ColumnSettingsContainer /> </ColumnHeader> <StatusListContainer trackScroll={!pinned} scrollKey={`home_timeline-${columnId}`} onLoadMore={this.handleLoadMore} timelineId='home' emptyMessage={<FormattedMessage id='empty_column.home' defaultMessage='Your home timeline is empty! Visit {public} or use search to get started and meet other users.' values={{ public: <Link to='/timelines/public'><FormattedMessage id='empty_column.home.public_timeline' defaultMessage='the public timeline' /></Link> }} />} shouldUpdateScroll={shouldUpdateScroll} /> </Column> ); } }
src/components/FormJoinRace/ShirtSizes.js
matapang/virtualraceph2
import React from 'react'; import PropTypes from 'prop-types'; import { FormControl, InputGroup } from 'react-bootstrap'; import Select from '../Select'; const SHIRT_SIZES = [ "2XS (17 x 24 inches)", "XS (18 x 25 inches)", "S (19 x 25 inches)", "M (20 x 27 inches)", "L (21 x 28 inches)", "XL (22 x 29 inches)", "2XL (23 x 30 inches)", "Custom" ]; class ShirtSizes extends React.Component { state = { changeToText: false } handleChange = (e) => { if (e.target.value == 'Custom') { this.setState({ changeToText: true }) } if (this.props.onChange) { this.props.onChange(e); } } render() { const { changeToText } = this.state; return ( changeToText ? <InputGroup> <FormControl type="text" onChange={this.handleChange} /> <InputGroup.Addon> <i className="fa fa-arrow-left" onClick={()=>this.setState({changeToText:false})} /> </InputGroup.Addon> </InputGroup> : <Select data={SHIRT_SIZES} onChange={this.handleChange} /> ); } } ShirtSizes.propTypes = { onChange:PropTypes.func } export default ShirtSizes;
src/components/form/FormStories.js
timLoewel/sites
import React from 'react'; import {storiesOf, action, linkTo} from '@kadira/react-native-storybook'; import CenterView from '../basics/CenterView'; import FormTextInput from './FormTextInput'; storiesOf('Form', module) .addDecorator(getStory => ( <CenterView >{getStory()}</CenterView> )) .add('initial', () => ( <FormTextInput placeholder="Placeholder" title="MyFormInput" input={{onChange : ()=>1}}/> ));
react/redux-start/react-redux-todos/src/containers/FilterLink.js
kobeCan/practices
import React from 'react'; import { connect } from 'react-redux'; import Link from '../components/Link'; import { setFilterLink } from '../actions'; const mapStateToProps = (state, ownProps) => { return { active: ownProps.filter === state.visibilityFilter } } const mapDispatchToProps = (dispatch, ownProps) => ({ onClick: () => dispatch(setFilterLink(ownProps.filter)) }) let FilterLink = connect(mapStateToProps, mapDispatchToProps)(Link); export default FilterLink
src/client/components/component.react.js
srhmgn/markdowner
import React from 'react'; import shallowEqual from 'react-pure-render/shallowEqual'; // import diff from 'immutablediff'; /** * Purified React.Component. Goodness. * http://facebook.github.io/react/docs/advanced-performance.html */ class Component extends React.Component { shouldComponentUpdate(nextProps, nextState) { // TODO: Make whole React Pure, add something like dangerouslySetLocalState. // https://github.com/gaearon/react-pure-render#known-issues // https://twitter.com/steida/status/600395820295450624 if (this.context.router) { const changed = this.pureComponentLastPath !== this.context.router.getCurrentPath(); this.pureComponentLastPath = this.context.router.getCurrentPath(); if (changed) return true; } const shouldUpdate = !shallowEqual(this.props, nextProps) || !shallowEqual(this.state, nextState); // if (shouldUpdate) // this._logShouldUpdateComponents(nextProps, nextState) return shouldUpdate; } // // Helper to check which component was changed and why. // _logShouldUpdateComponents(nextProps, nextState) { // const name = this.constructor.displayName || this.constructor.name // console.log(`${name} shouldUpdate`) // // const propsDiff = diff(this.props, nextProps).toJS() // // const stateDiff = diff(this.state, nextState).toJS() // // if (propsDiff.length) console.log('props', propsDiff) // // if (stateDiff.length) console.log('state', stateDiff) // } } Component.contextTypes = { router: React.PropTypes.func }; export default Component;
example/browser.js
cloudflare/react-gateway
import React from 'react'; import Application from './Application'; import ReactDOM from 'react-dom'; ReactDOM.render(<Application/>, document.getElementById('root'));
packages/icons/src/md/notification/AirlineSeatReclineNormal.js
suitejs/suitejs
import React from 'react'; import IconBase from '@suitejs/icon-base'; function MdAirlineSeatReclineNormal(props) { return ( <IconBase viewBox="0 0 48 48" {...props}> <path d="M15.17 11.83a4.008 4.008 0 0 1 0-5.66 4.008 4.008 0 0 1 5.66 0 4.008 4.008 0 0 1 0 5.66 4.008 4.008 0 0 1-5.66 0zM12 33V15H8v18c0 5.52 4.48 10 10 10h12v-4H18c-3.31 0-6-2.69-6-6zm28 8.13L29.87 31H23v-7.36c2.79 2.3 7.21 4.31 11 4.32v-4.32c-3.32.04-7.22-1.74-9.34-4.08l-2.8-3.1a4.51 4.51 0 0 0-1.37-1.01c-.59-.29-1.25-.46-1.93-.46h-.05C16.02 15 14 17.01 14 19.5V31c0 3.31 2.69 6 6 6h10.13l7 7L40 41.13z" /> </IconBase> ); } export default MdAirlineSeatReclineNormal;
src/client/main.js
redcom/aperitive
// @flow import React from 'react'; import { createBatchingNetworkInterface } from 'apollo-client'; import { Client } from 'subscriptions-transport-ws'; import { ApolloProvider } from 'react-apollo'; import { Router, browserHistory } from 'react-router'; import createApolloClient from '../apollo_client'; import addGraphQLSubscriptions from './subscriptions'; import routes from '../routes'; import { app as settings} from '../../package.json'; import '../ui/styles.scss'; const wsClient = new Client(window.location.origin.replace(/^http/, 'ws') .replace(':' + settings.webpackDevPort, ':' + settings.apiPort)); const networkInterface = createBatchingNetworkInterface({ opts: { credentials: "same-origin", }, batchInterval: 500, uri: "/graphql", }); const networkInterfaceWithSubscriptions = addGraphQLSubscriptions( networkInterface, wsClient, ); const client = createApolloClient(networkInterfaceWithSubscriptions); export default class Main extends React.Component { render() { return ( <ApolloProvider client={client}> <Router history={browserHistory}> {routes} </Router> </ApolloProvider> ); } }
packages/react-scripts/fixtures/kitchensink/src/features/syntax/ArraySpread.js
RobzDoom/frame_trap
/** * Copyright (c) 2015-present, Facebook, Inc. * All rights reserved. * * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. */ import React, { Component } from 'react'; import PropTypes from 'prop-types'; function load(users) { return [ { id: 1, name: '1' }, { id: 2, name: '2' }, { id: 3, name: '3' }, ...users, ]; } export default class extends Component { static propTypes = { onReady: PropTypes.func.isRequired, }; constructor(props) { super(props); this.state = { users: [] }; } async componentDidMount() { const users = load([{ id: 42, name: '42' }]); this.setState({ users }); } componentDidUpdate() { this.props.onReady(); } render() { return ( <div id="feature-array-spread"> {this.state.users.map(user => <div key={user.id}>{user.name}</div>)} </div> ); } }
index.android.js
alphonso-db/alphonso-native
/** * 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 myapp 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('myapp', () => myapp);
wrappers/json.js
gregcorby/gregcorby.com
import React from 'react' module.exports = React.createClass({ propTypes () { return { route: React.PropTypes.object, } }, render () { const data = this.props.route.page.data return ( <div> <h1>{data.title}</h1> <p>Raw view of json file</p> <pre dangerouslySetInnerHTML={{ __html: JSON.stringify(data, null, 4) }} /> </div> ) }, })
share/components/Common/Button.js
caojs/password-manager-server
import React from 'react'; import classNames from 'classnames'; import { injectProps } from '../../helpers/decorators'; import style from './Button.css'; export default class Button extends React.Component { @injectProps render({ children, className, ...rest }) { let btnClass = classNames(style.button, className); console.log(rest); return ( <button className={btnClass} { ...rest }> {children} </button> ); } }
client/components/Flass/Upload/QuestionInsertion/Quiz/QuizMultipleChoice/QuizMultipleChoiceComponent.js
Nexters/flass
import _ from 'lodash'; import { List } from 'immutable'; import React, { Component } from 'react'; import PropTypes from 'prop-types'; import autobind from 'autobind-decorator'; import QuizSingleChoiceComponent from './QuizSingleChoice/QuizSingleChoiceComponent'; import AddQuizIcon from './icons/invalid-name@2x.png'; import { QuizMultipleChoice } from './QuizMultipleChoiceStyled'; const { func, number } = PropTypes; const propTypes = { cancelAddingQuestion: func.isRequired, completeAddingQuestion: func.isRequired, saveMultipleChoiceQuestion: func.isRequired, decreaseNumOfQuestion: func.isRequired, setPlayingState: func.isRequired, numOfQuestion: number.isRequired }; const defaultProps = {}; const NUMBERING_KEYWORD = ['첫 번째', '두 번째', '세 번째', '네 번째']; const MAX_NUM_OF_CHOICES = 4; const COMPONENT_INITIAL_STATE = { numOfChoice: 1, checkedQuizIndex: -1, isTitleInputDirty: false, TitleInputValue: '문제를 입력하세요.', SingleChoiceValues: [{ isAnswer: false, choiceTextValue: '' }] }; const EMPTY_STRING = ''; class QuizMultipleChoiceComponent extends Component { constructor(props) { super(props); this.state = COMPONENT_INITIAL_STATE; } render() { const { TitleInputValue, numOfChoice, isTitleInputDirty } = this.state; const { numOfQuestion } = this.props; return ( <QuizMultipleChoice.Wrapper> <QuizMultipleChoice.Header> <QuizMultipleChoice.QuestionNumber> { this.renderQuestionNumber(numOfQuestion) } </QuizMultipleChoice.QuestionNumber> <QuizMultipleChoice.QuestionTitleWrapper> <QuizMultipleChoice.QuestionTitle type="text" value={ TitleInputValue } onClick={ this.onTitleInputClick } onChange={ this.onTitleInputChange } isTitleInputDirty={ isTitleInputDirty } /> <QuizMultipleChoice.underline /> </QuizMultipleChoice.QuestionTitleWrapper> </QuizMultipleChoice.Header> <QuizMultipleChoice.Body> { this.renderChoices() } { this.renderAddButton(numOfChoice) } </QuizMultipleChoice.Body> <QuizMultipleChoice.Footer> <QuizMultipleChoice.Button right onClick={ this.onRegisterBtnClick }> <span> 입력 </span> </QuizMultipleChoice.Button> <QuizMultipleChoice.Button right gray onClick={ this.onCancelBtnClick }> <span> 삭제 </span> </QuizMultipleChoice.Button> </QuizMultipleChoice.Footer> </QuizMultipleChoice.Wrapper> ); } @autobind renderQuestionNumber(indexOfQuestion) { return `Q${indexOfQuestion}`; } @autobind onTitleInputClick() { if (!this.state.isTitleInputDirty) { this.setState({ isTitleInputDirty: true, TitleInputValue: EMPTY_STRING }); } } @autobind onTitleInputChange(e) { this.setState({ TitleInputValue: e.target.value }); } @autobind renderChoices() { const { numOfChoice, SingleChoiceValues } = this.state; const choices = []; for (let i = 0; i < numOfChoice; i += 1) { const { choiceTextValue } = SingleChoiceValues[i]; choices.push(<QuizSingleChoiceComponent numberingKeyword={ NUMBERING_KEYWORD[i] } key={ i } choiceIndex={ i } choiceTextValue={ choiceTextValue } isChecked={ this.isCheckedQuizIndexSameWithIndex(i) } onCheckboxClick={ this.onCheckboxClick } onChoiceInputChange={ this.onSingleChoiceInputChange } onSingleChoiceDeleteBtnClick={ this.onSingleChoiceDeleteBtnClick } />); } return choices; } @autobind isCheckedQuizIndexSameWithIndex(index) { return this.state.checkedQuizIndex === index; } @autobind onCheckboxClick(quizIndex) { this.setState({ checkedQuizIndex: quizIndex }); this.updateIsAnswerValueOnSingleChoiceArray(quizIndex); } updateIsAnswerValueOnSingleChoiceArray(choiceIndex) { const { checkedQuizIndex } = this.state; if (checkedQuizIndex !== -1) { const updatedSingleChoiceArray = List(this.state.SingleChoiceValues) .update(checkedQuizIndex, choice => ({ ...choice, isAnswer: false })) .update(choiceIndex, choice => ({ ...choice, isAnswer: true })) .toArray(); this.setState({ SingleChoiceValues: updatedSingleChoiceArray }); } else { const updatedSingleChoiceArray = List(this.state.SingleChoiceValues) .update(choiceIndex, choice => ({ ...choice, isAnswer: true })) .toArray(); this.setState({ SingleChoiceValues: updatedSingleChoiceArray }); } } @autobind onSingleChoiceInputChange(choiceIndex, choiceTextValue) { const updatedSingleChoiceArray = List(this.state.SingleChoiceValues) .update(choiceIndex, choice => ({ ...choice, choiceTextValue })) .toArray(); this.setState({ SingleChoiceValues: updatedSingleChoiceArray }); } @autobind onAddChoiceBtnClick() { const { numOfChoice, SingleChoiceValues } = this.state; if (this.state.numOfChoice < MAX_NUM_OF_CHOICES) { this.updateNumAndValuesOfChoice(numOfChoice, SingleChoiceValues); } else { alert('선택지 수는 4개를 넘을 수 없습니다.'); } } updateNumAndValuesOfChoice(numOfChoice, SingleChoiceValues) { const newSingleChoiceValue = { isAnswer: false, choiceTextValue: EMPTY_STRING }; this.setState({ numOfChoice: numOfChoice + 1, SingleChoiceValues: _.concat(SingleChoiceValues, newSingleChoiceValue) }); } @autobind onCancelBtnClick() { if (this.props.numOfQuestion > 1) { this.props.decreaseNumOfQuestion(); } this.props.cancelAddingQuestion(); this.props.setPlayingState(true); } @autobind onRegisterBtnClick() { const { numOfChoice, checkedQuizIndex, TitleInputValue, SingleChoiceValues } = this.state; if (this.isMultiChoiceFormFilled()) { this.props.setPlayingState(true); this.props.saveMultipleChoiceQuestion({ numOfChoice, checkedQuizIndex, TitleInputValue, SingleChoiceValues }); this.props.completeAddingQuestion(); } } isMultiChoiceFormFilled() { if (!this.isMultiChoiceTitleInputFilled()) { alert('제목이 비었습니다.'); return false; } if (!this.isMultiChoiceBodyInputFilled()) { alert('선택지가 입력되지않았습니다.'); return false; } if (!this.isCheckboxChecked()) { alert('정답을 체크해주세요.'); return false; } return true; } isMultiChoiceTitleInputFilled() { return ( this.state.TitleInputValue !== COMPONENT_INITIAL_STATE.TitleInputValue && this.state.TitleInputValue !== EMPTY_STRING && this.state.isTitleInputDirty ); } isMultiChoiceBodyInputFilled() { return this.state.SingleChoiceValues .filter(singleChoice => singleChoice.choiceTextValue !== EMPTY_STRING) .length === this.state.SingleChoiceValues.length; } isCheckboxChecked() { return this.state.checkedQuizIndex !== -1; } @autobind renderAddButton(numOfChoice) { if (numOfChoice < MAX_NUM_OF_CHOICES) { return ( <QuizMultipleChoice.AddButton> <QuizMultipleChoice.Icon onClick={ this.onAddChoiceBtnClick } srcSet={ AddQuizIcon } alt="Add quiz button" /> <QuizMultipleChoice.AddButtonText> { `${NUMBERING_KEYWORD[numOfChoice]} 문항을 입력하세요.` } </QuizMultipleChoice.AddButtonText> </QuizMultipleChoice.AddButton> ); } return null; } @autobind onSingleChoiceDeleteBtnClick(indexOfChoice) { const { SingleChoiceValues, numOfChoice } = this.state; const updatedSingleChoicesValue = List(SingleChoiceValues).delete(indexOfChoice).toArray(); this.setState({ SingleChoiceValues: updatedSingleChoicesValue, numOfChoice: numOfChoice - 1 }); } } QuizMultipleChoiceComponent.propTypes = propTypes; QuizMultipleChoiceComponent.defaultProps = defaultProps; export default QuizMultipleChoiceComponent;
src/components/common/header/ExplorerAppMenu.js
mitmedialab/MediaCloud-Web-Tools
import PropTypes from 'prop-types'; import React from 'react'; import { injectIntl } from 'react-intl'; import { connect } from 'react-redux'; import { push } from 'react-router-redux'; import AppMenu from './AppMenu'; import { urlToExplorer } from '../../../lib/urlUtil'; import { getAppName } from '../../../config'; const localMessages = { menuTitle: { id: 'explorer.menu.title', defaultMessage: 'Explorer' }, }; const ExplorerAppMenu = (props) => { let menu; return ( <AppMenu titleMsg={localMessages.menuTitle} showMenu={false} onTitleClick={() => { props.handleItemClick('', getAppName() === 'explorer'); }} menuComponent={menu} /> ); }; ExplorerAppMenu.propTypes = { // state isLoggedIn: PropTypes.bool.isRequired, // from dispatch handleItemClick: PropTypes.func.isRequired, // from context intl: PropTypes.object.isRequired, }; const mapStateToProps = state => ({ isLoggedIn: state.user.isLoggedIn, }); const mapDispatchToProps = dispatch => ({ handleItemClick: (path, isLocal) => { if (isLocal) { dispatch(push(path)); } else { window.location.href = urlToExplorer(path); } }, }); export default injectIntl( connect(mapStateToProps, mapDispatchToProps)( ExplorerAppMenu ) );
pootle/static/js/auth/components/SignInForm.js
mail-apps/pootle
/* * Copyright (C) Pootle contributors. * * This file is a part of the Pootle project. It is distributed under the GPL3 * or later license. See the LICENSE file for a copy of the license and the * AUTHORS file for copyright and authorship information. */ 'use strict'; import assign from 'object-assign'; import React from 'react'; import { FormElement } from 'components/forms'; import { FormMixin } from 'mixins/forms'; let SignInForm = React.createClass({ mixins: [FormMixin], propTypes: { canRegister: React.PropTypes.bool.isRequired, formErrors: React.PropTypes.object.isRequired, isLoading: React.PropTypes.bool.isRequired, }, /* Lifecycle */ getInitialState() { // XXX: initialData required by `FormMixin`; this is really OBSCURE this.initialData = { login: '', password: '', }; return { formData: assign({}, this.initialData), }; }, componentWillReceiveProps(nextProps) { if (this.state.errors !== nextProps.formErrors) { this.setState({errors: nextProps.formErrors}); } }, /* Handlers */ handleRequestPasswordReset(e) { e.preventDefault(); this.props.flux.getActions('auth').gotoScreen('requestPasswordReset'); }, handleSignUp(e) { e.preventDefault(); this.props.flux.getActions('auth').gotoScreen('signUp'); }, handleFormSubmit(e) { e.preventDefault(); let nextURL = window.location.pathname + window.location.hash; this.props.flux.getActions('auth').signIn(this.state.formData, nextURL); }, /* Others */ hasData() { let { formData } = this.state; return formData.login !== '' && formData.password !== ''; }, /* Layout */ render() { let { errors } = this.state; let { formData } = this.state; let signUp = this.props.canRegister ? <a href="#" onClick={this.handleSignUp}> {gettext('Sign up as a new user')} </a> : <p>{gettext('Creating new user accounts is prohibited.')}</p>; return ( <form method="post" onSubmit={this.handleFormSubmit} > <div className="fields"> <FormElement attribute="login" label={gettext('Username')} autoFocus={true} handleChange={this.handleChange} formData={formData} errors={errors} /> <FormElement type="password" attribute="password" label={gettext('Password')} handleChange={this.handleChange} formData={formData} errors={errors} /> <div className="actions password-forgotten"> <a href="#" onClick={this.handleRequestPasswordReset}> {gettext('I forgot my password')} </a> </div> {this.renderAllFormErrors()} </div> <div className="actions"> <div> <input type="submit" className="btn btn-primary" disabled={!this.hasData() || this.props.isLoading} value={gettext('Sign In')} /> </div> <div> {signUp} </div> </div> </form> ); } }); export default SignInForm;
src/components/FilterContainer.js
joellanciaux/Griddle
import React from 'react'; import PropTypes from 'prop-types'; import { connect } from '../utils/griddleConnect'; import { classNamesForComponentSelector, stylesForComponentSelector } from '../selectors/dataSelectors'; import { setFilter } from '../actions'; const EnhancedFilter = OriginalComponent => connect((state, props) => ({ className: classNamesForComponentSelector(state, 'Filter'), style: stylesForComponentSelector(state, 'Filter'), }), { setFilter })(props => <OriginalComponent {...props} />); export default EnhancedFilter;
src/svg-icons/editor/border-all.js
mtsandeep/material-ui
import React from 'react'; import pure from 'recompose/pure'; import SvgIcon from '../../SvgIcon'; let EditorBorderAll = (props) => ( <SvgIcon {...props}> <path d="M3 3v18h18V3H3zm8 16H5v-6h6v6zm0-8H5V5h6v6zm8 8h-6v-6h6v6zm0-8h-6V5h6v6z"/> </SvgIcon> ); EditorBorderAll = pure(EditorBorderAll); EditorBorderAll.displayName = 'EditorBorderAll'; EditorBorderAll.muiName = 'SvgIcon'; export default EditorBorderAll;
docs/app/Examples/elements/Label/Types/index.js
aabustamante/Semantic-UI-React
import React from 'react' import ComponentExample from 'docs/app/Components/ComponentDoc/ComponentExample' import ExampleSection from 'docs/app/Components/ComponentDoc/ExampleSection' const LabelTypes = () => ( <ExampleSection title='Types'> <ComponentExample title='Label' description='A label' examplePath='elements/Label/Types/LabelExampleBasic' /> <ComponentExample examplePath='elements/Label/Types/LabelExampleImage' /> <ComponentExample examplePath='elements/Label/Types/LabelExampleImageColored' /> <ComponentExample examplePath='elements/Label/Types/LabelExampleIcon' /> <ComponentExample title='Pointing' description='A label can point to content next to it' examplePath='elements/Label/Types/LabelExamplePointing' /> <ComponentExample examplePath='elements/Label/Types/LabelExamplePointingColored' /> <ComponentExample title='Corner' description='A label can position itself in the corner of an element' examplePath='elements/Label/Types/LabelExampleCorner' /> <ComponentExample title='Tag' description='A label can appear as a tag' examplePath='elements/Label/Types/LabelExampleTag' /> <ComponentExample title='Ribbon' description='A label can appear as a ribbon attaching itself to an element' examplePath='elements/Label/Types/LabelExampleRibbon' /> <ComponentExample examplePath='elements/Label/Types/LabelExampleRibbonImage' /> <ComponentExample title='Attached' description='A label can attach to a content segment' examplePath='elements/Label/Types/LabelExampleAttached' /> <ComponentExample title='Horizontal' description='A horizontal label is formatted to label content along-side it horizontally' examplePath='elements/Label/Types/LabelExampleHorizontal' /> <ComponentExample title='Floating' description='A label can float above another element' examplePath='elements/Label/Types/LabelExampleFloating' /> </ExampleSection> ) export default LabelTypes
src/components/Footer.js
Open-Seat-Philly/open-seat
import React from 'react'; const Footer = () => ( <footer className="footer"> <div className="container"> <p className="text-muted pull-right"><a href="https://codeforphilly.org/projects/open_seat_finder"> Civic Engagement Launchpad 2017</a></p> </div> </footer> ); export default Footer;
src/components/MyiWorlds/ContainerMapperLevel1/containers/EdgeCardsContainer1/EdgeCardsContainer1.js
DaveyEdwards/myiworlds
/** * React Starter Kit (https://www.reactstarterkit.com/) * * Copyright © 2014-present Kriasoft, LLC. All rights reserved. * * This source code is licensed under the MIT license found in the * LICENSE.txt file in the root directory of this source tree. */ import React from 'react'; import PropTypes from 'prop-types'; import withStyles from 'isomorphic-style-loader/lib/withStyles'; import { graphql, createFragmentContainer } from 'react-relay'; import Divider from 'material-ui/Divider'; import Typography from 'material-ui/Typography'; import Card, { CardActions, CardContent, CardMedia } from 'material-ui/Card'; import Grid from 'material-ui/Grid'; import Button from 'material-ui/Button'; import s from './EdgeCardsContainer1.css'; class EdgeCardsContainer1 extends React.Component { static propTypes = { // eslint-disable-next-line react/forbid-prop-types circle: PropTypes.object, title: PropTypes.string, }; static defaultProps = { circle: null, title: '', }; render() { return ( <Card className={s.root}> <div className={s.header}> <Typography type="display1" gutterBottom> {this.props.circle.title} </Typography> </div> <Divider light style={{ marginBottom: '72px' }} /> <Grid className={s.grid} container gutter={24}> {this.props.circle.linesMany.edges.map(({ node }) => <Grid item sm={4} key={node._id}> <Card> {node.media.value ? <CardMedia className={s.cardMedia} image={node.media.value} title={node.media.title} /> : null} <CardContent> {node.title ? <Typography type="headline" component="h2"> {node.title} </Typography> : null} {node.description ? <Typography component="p"> {node.description} </Typography> : null} </CardContent> <CardActions> <Button dense color="primary"> VIEW PAGE </Button> </CardActions> </Card> </Grid>, )} </Grid> <Divider light /> </Card> ); } } export default createFragmentContainer( withStyles(s)(EdgeCardsContainer1), graphql` fragment EdgeCardsContainer1_circle on Circle { title linesMany { edges { node { _id media { value title } title type description pathFull } } } } `, );
app/javascript/mastodon/features/reblogs/index.js
narabo/mastodon
import React from 'react'; import { connect } from 'react-redux'; import PropTypes from 'prop-types'; import ImmutablePropTypes from 'react-immutable-proptypes'; import LoadingIndicator from '../../components/loading_indicator'; import { fetchReblogs } from '../../actions/interactions'; import { ScrollContainer } from 'react-router-scroll'; import AccountContainer from '../../containers/account_container'; import Column from '../ui/components/column'; import ColumnBackButton from '../../components/column_back_button'; import ImmutablePureComponent from 'react-immutable-pure-component'; const mapStateToProps = (state, props) => ({ accountIds: state.getIn(['user_lists', 'reblogged_by', Number(props.params.statusId)]), }); class Reblogs extends ImmutablePureComponent { static propTypes = { params: PropTypes.object.isRequired, dispatch: PropTypes.func.isRequired, accountIds: ImmutablePropTypes.list, }; componentWillMount () { this.props.dispatch(fetchReblogs(Number(this.props.params.statusId))); } componentWillReceiveProps(nextProps) { if (nextProps.params.statusId !== this.props.params.statusId && nextProps.params.statusId) { this.props.dispatch(fetchReblogs(Number(nextProps.params.statusId))); } } render () { const { accountIds } = this.props; if (!accountIds) { return ( <Column> <LoadingIndicator /> </Column> ); } return ( <Column> <ColumnBackButton /> <ScrollContainer scrollKey='reblogs'> <div className='scrollable reblogs'> {accountIds.map(id => <AccountContainer key={id} id={id} withNote={false} />)} </div> </ScrollContainer> </Column> ); } } export default connect(mapStateToProps)(Reblogs);
app/containers/NotFoundPage/index.js
audoralc/pyxis
/** * NotFoundPage * * This is the page we show when the user visits a url that doesn't have a route * */ import React from 'react'; export default class NotFound extends React.PureComponent { // eslint-disable-line react/prefer-stateless-function render() { return ( <h1> 404: Not Found </h1> ); } }
app/js/views/Components/Switches/Switches.js
jagatjeevan/dakiya
import React, { Component } from 'react'; class Switches extends Component { render() { return ( <div className="animated fadeIn"> <div className="row"> <div className="col-md-12"> <div className="card"> <div className="card-header"> 3d Switch </div> <div className="card-block"> <label className="switch switch-3d switch-primary"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" /> <span className="switch-handle" /> </label> &nbsp;&nbsp;&nbsp; <label className="switch switch-3d switch-secondary"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" /> <span className="switch-handle" /> </label> &nbsp;&nbsp;&nbsp; <label className="switch switch-3d switch-success"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" /> <span className="switch-handle" /> </label> &nbsp;&nbsp;&nbsp; <label className="switch switch-3d switch-warning"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" /> <span className="switch-handle" /> </label> &nbsp;&nbsp;&nbsp; <label className="switch switch-3d switch-info"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" /> <span className="switch-handle" /> </label> &nbsp;&nbsp;&nbsp; <label className="switch switch-3d switch-danger"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" /> <span className="switch-handle" /> </label> </div> </div> </div> <div className="col-md-6"> <div className="card"> <div className="card-header"> Switch default </div> <div className="card-block"> <label className="switch switch-default switch-primary"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" /> <span className="switch-handle" /> </label> &nbsp;&nbsp;&nbsp; <label className="switch switch-default switch-secondary"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" /> <span className="switch-handle" /> </label> &nbsp;&nbsp;&nbsp; <label className="switch switch-default switch-success"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" /> <span className="switch-handle" /> </label> &nbsp;&nbsp;&nbsp; <label className="switch switch-default switch-warning"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" /> <span className="switch-handle" /> </label> &nbsp;&nbsp;&nbsp; <label className="switch switch-default switch-info"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" /> <span className="switch-handle" /> </label> &nbsp;&nbsp;&nbsp; <label className="switch switch-default switch-danger"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" /> <span className="switch-handle" /> </label> </div> </div> </div> <div className="col-md-6"> <div className="card"> <div className="card-header"> Switch default - pills </div> <div className="card-block"> <label className="switch switch-default switch-pill switch-primary"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" /> <span className="switch-handle" /> </label> &nbsp;&nbsp;&nbsp; <label className="switch switch-default switch-pill switch-secondary"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" /> <span className="switch-handle" /> </label> &nbsp;&nbsp;&nbsp; <label className="switch switch-default switch-pill switch-success"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" /> <span className="switch-handle" /> </label> &nbsp;&nbsp;&nbsp; <label className="switch switch-default switch-pill switch-warning"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" /> <span className="switch-handle" /> </label> &nbsp;&nbsp;&nbsp; <label className="switch switch-default switch-pill switch-info"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" /> <span className="switch-handle" /> </label> &nbsp;&nbsp;&nbsp; <label className="switch switch-default switch-pill switch-danger"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" /> <span className="switch-handle" /> </label> </div> </div> </div> <div className="col-md-6"> <div className="card"> <div className="card-header"> Switch outline </div> <div className="card-block"> <label className="switch switch-default switch-primary-outline"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" /> <span className="switch-handle" /> </label> &nbsp;&nbsp;&nbsp; <label className="switch switch-default switch-secondary-outline"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" /> <span className="switch-handle" /> </label> &nbsp;&nbsp;&nbsp; <label className="switch switch-default switch-success-outline"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" /> <span className="switch-handle" /> </label> &nbsp;&nbsp;&nbsp; <label className="switch switch-default switch-warning-outline"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" /> <span className="switch-handle" /> </label> &nbsp;&nbsp;&nbsp; <label className="switch switch-default switch-info-outline"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" /> <span className="switch-handle" /> </label> &nbsp;&nbsp;&nbsp; <label className="switch switch-default switch-danger-outline"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" /> <span className="switch-handle" /> </label> </div> </div> </div> <div className="col-md-6"> <div className="card"> <div className="card-header"> Switch outline - pills </div> <div className="card-block"> <label className="switch switch-default switch-pill switch-primary-outline"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" /> <span className="switch-handle" /> </label> &nbsp;&nbsp;&nbsp; <label className="switch switch-default switch-pill switch-secondary-outline"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" /> <span className="switch-handle" /> </label> &nbsp;&nbsp;&nbsp; <label className="switch switch-default switch-pill switch-success-outline"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" /> <span className="switch-handle" /> </label> &nbsp;&nbsp;&nbsp; <label className="switch switch-default switch-pill switch-warning-outline"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" /> <span className="switch-handle" /> </label> &nbsp;&nbsp;&nbsp; <label className="switch switch-default switch-pill switch-info-outline"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" /> <span className="switch-handle" /> </label> &nbsp;&nbsp;&nbsp; <label className="switch switch-default switch-pill switch-danger-outline"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" /> <span className="switch-handle" /> </label> </div> </div> </div> <div className="col-md-6"> <div className="card"> <div className="card-header"> Switch outline alternative </div> <div className="card-block"> <label className="switch switch-default switch-primary-outline-alt"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" /> <span className="switch-handle" /> </label> &nbsp;&nbsp;&nbsp; <label className="switch switch-default switch-secondary-outline-alt"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" /> <span className="switch-handle" /> </label> &nbsp;&nbsp;&nbsp; <label className="switch switch-default switch-success-outline-alt"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" /> <span className="switch-handle" /> </label> &nbsp;&nbsp;&nbsp; <label className="switch switch-default switch-warning-outline-alt"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" /> <span className="switch-handle" /> </label> &nbsp;&nbsp;&nbsp; <label className="switch switch-default switch-info-outline-alt"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" /> <span className="switch-handle" /> </label> &nbsp;&nbsp;&nbsp; <label className="switch switch-default switch-danger-outline-alt"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" /> <span className="switch-handle" /> </label> </div> </div> </div> <div className="col-md-6"> <div className="card"> <div className="card-header"> Switch outline alternative - pills </div> <div className="card-block"> <label className="switch switch-default switch-pill switch-primary-outline-alt"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" /> <span className="switch-handle" /> </label> &nbsp;&nbsp;&nbsp; <label className="switch switch-default switch-pill switch-secondary-outline-alt"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" /> <span className="switch-handle" /> </label> &nbsp;&nbsp;&nbsp; <label className="switch switch-default switch-pill switch-success-outline-alt"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" /> <span className="switch-handle" /> </label> &nbsp;&nbsp;&nbsp; <label className="switch switch-default switch-pill switch-warning-outline-alt"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" /> <span className="switch-handle" /> </label> &nbsp;&nbsp;&nbsp; <label className="switch switch-default switch-pill switch-info-outline-alt"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" /> <span className="switch-handle" /> </label> &nbsp;&nbsp;&nbsp; <label className="switch switch-default switch-pill switch-danger-outline-alt"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" /> <span className="switch-handle" /> </label> </div> </div> </div> <div className="col-md-6"> <div className="card"> <div className="card-header"> Switch with text </div> <div className="card-block"> <label className="switch switch-text switch-primary"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" data-on="On" data-off="Off" /> <span className="switch-handle" /> </label> &nbsp;&nbsp;&nbsp; <label className="switch switch-text switch-secondary"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" data-on="On" data-off="Off" /> <span className="switch-handle" /> </label> &nbsp;&nbsp;&nbsp; <label className="switch switch-text switch-success"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" data-on="On" data-off="Off" /> <span className="switch-handle" /> </label> &nbsp;&nbsp;&nbsp; <label className="switch switch-text switch-warning"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" data-on="On" data-off="Off" /> <span className="switch-handle" /> </label> &nbsp;&nbsp;&nbsp; <label className="switch switch-text switch-info"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" data-on="On" data-off="Off" /> <span className="switch-handle" /> </label> &nbsp;&nbsp;&nbsp; <label className="switch switch-text switch-danger"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" data-on="On" data-off="Off" /> <span className="switch-handle" /> </label> </div> </div> </div> <div className="col-md-6"> <div className="card"> <div className="card-header"> Switch with text - pills </div> <div className="card-block"> <label className="switch switch-text switch-pill switch-primary"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" data-on="On" data-off="Off" /> <span className="switch-handle" /> </label> &nbsp;&nbsp;&nbsp; <label className="switch switch-text switch-pill switch-secondary"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" data-on="On" data-off="Off" /> <span className="switch-handle" /> </label> &nbsp;&nbsp;&nbsp; <label className="switch switch-text switch-pill switch-success"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" data-on="On" data-off="Off" /> <span className="switch-handle" /> </label> &nbsp;&nbsp;&nbsp; <label className="switch switch-text switch-pill switch-warning"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" data-on="On" data-off="Off" /> <span className="switch-handle" /> </label> &nbsp;&nbsp;&nbsp; <label className="switch switch-text switch-pill switch-info"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" data-on="On" data-off="Off" /> <span className="switch-handle" /> </label> &nbsp;&nbsp;&nbsp; <label className="switch switch-text switch-pill switch-danger"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" data-on="On" data-off="Off" /> <span className="switch-handle" /> </label> </div> </div> </div> <div className="col-md-6"> <div className="card"> <div className="card-header"> Switch with text outline </div> <div className="card-block"> <label className="switch switch-text switch-primary-outline"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" data-on="On" data-off="Off" /> <span className="switch-handle" /> </label> &nbsp;&nbsp;&nbsp; <label className="switch switch-text switch-secondary-outline"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" data-on="On" data-off="Off" /> <span className="switch-handle" /> </label> &nbsp;&nbsp;&nbsp; <label className="switch switch-text switch-success-outline"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" data-on="On" data-off="Off" /> <span className="switch-handle" /> </label> &nbsp;&nbsp;&nbsp; <label className="switch switch-text switch-warning-outline"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" data-on="On" data-off="Off" /> <span className="switch-handle" /> </label> &nbsp;&nbsp;&nbsp; <label className="switch switch-text switch-info-outline"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" data-on="On" data-off="Off" /> <span className="switch-handle" /> </label> &nbsp;&nbsp;&nbsp; <label className="switch switch-text switch-danger-outline"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" data-on="On" data-off="Off" /> <span className="switch-handle" /> </label> </div> </div> </div> <div className="col-md-6"> <div className="card"> <div className="card-header"> Switch with text outline - pills </div> <div className="card-block"> <label className="switch switch-text switch-pill switch-primary-outline"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" data-on="On" data-off="Off" /> <span className="switch-handle" /> </label> &nbsp;&nbsp;&nbsp; <label className="switch switch-text switch-pill switch-secondary-outline"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" data-on="On" data-off="Off" /> <span className="switch-handle" /> </label> &nbsp;&nbsp;&nbsp; <label className="switch switch-text switch-pill switch-success-outline"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" data-on="On" data-off="Off" /> <span className="switch-handle" /> </label> &nbsp;&nbsp;&nbsp; <label className="switch switch-text switch-pill switch-warning-outline"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" data-on="On" data-off="Off" /> <span className="switch-handle" /> </label> &nbsp;&nbsp;&nbsp; <label className="switch switch-text switch-pill switch-info-outline"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" data-on="On" data-off="Off" /> <span className="switch-handle" /> </label> &nbsp;&nbsp;&nbsp; <label className="switch switch-text switch-pill switch-danger-outline"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" data-on="On" data-off="Off" /> <span className="switch-handle" /> </label> </div> </div> </div> <div className="col-md-6"> <div className="card"> <div className="card-header"> Switch with text outline alternative </div> <div className="card-block"> <label className="switch switch-text switch-primary-outline-alt"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" data-on="On" data-off="Off" /> <span className="switch-handle" /> </label> &nbsp;&nbsp;&nbsp; <label className="switch switch-text switch-secondary-outline-alt"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" data-on="On" data-off="Off" /> <span className="switch-handle" /> </label> &nbsp;&nbsp;&nbsp; <label className="switch switch-text switch-success-outline-alt"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" data-on="On" data-off="Off" /> <span className="switch-handle" /> </label> &nbsp;&nbsp;&nbsp; <label className="switch switch-text switch-warning-outline-alt"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" data-on="On" data-off="Off" /> <span className="switch-handle" /> </label> &nbsp;&nbsp;&nbsp; <label className="switch switch-text switch-info-outline-alt"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" data-on="On" data-off="Off" /> <span className="switch-handle" /> </label> &nbsp;&nbsp;&nbsp; <label className="switch switch-text switch-danger-outline-alt"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" data-on="On" data-off="Off" /> <span className="switch-handle" /> </label> </div> </div> </div> <div className="col-md-6"> <div className="card"> <div className="card-header"> Switch with text outline alternative - pills </div> <div className="card-block"> <label className="switch switch-text switch-pill switch-primary-outline-alt"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" data-on="On" data-off="Off" /> <span className="switch-handle" /> </label> &nbsp;&nbsp;&nbsp; <label className="switch switch-text switch-pill switch-secondary-outline-alt"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" data-on="On" data-off="Off" /> <span className="switch-handle" /> </label> &nbsp;&nbsp;&nbsp; <label className="switch switch-text switch-pill switch-success-outline-alt"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" data-on="On" data-off="Off" /> <span className="switch-handle" /> </label> &nbsp;&nbsp;&nbsp; <label className="switch switch-text switch-pill switch-warning-outline-alt"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" data-on="On" data-off="Off" /> <span className="switch-handle" /> </label> &nbsp;&nbsp;&nbsp; <label className="switch switch-text switch-pill switch-info-outline-alt"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" data-on="On" data-off="Off" /> <span className="switch-handle" /> </label> &nbsp;&nbsp;&nbsp; <label className="switch switch-text switch-pill switch-danger-outline-alt"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" data-on="On" data-off="Off" /> <span className="switch-handle" /> </label> </div> </div> </div> <div className="col-md-6"> <div className="card"> <div className="card-header"> Switch with icon </div> <div className="card-block"> <label className="switch switch-icon switch-primary"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" data-on="&#xf00c" data-off="&#xf00d" /> <span className="switch-handle" /> </label> &nbsp;&nbsp;&nbsp; <label className="switch switch-icon switch-secondary"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" data-on="&#xf00c" data-off="&#xf00d" /> <span className="switch-handle" /> </label> &nbsp;&nbsp;&nbsp; <label className="switch switch-icon switch-success"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" data-on="&#xf00c" data-off="&#xf00d" /> <span className="switch-handle" /> </label> &nbsp;&nbsp;&nbsp; <label className="switch switch-icon switch-warning"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" data-on="&#xf00c" data-off="&#xf00d" /> <span className="switch-handle" /> </label> &nbsp;&nbsp;&nbsp; <label className="switch switch-icon switch-info"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" data-on="&#xf00c" data-off="&#xf00d" /> <span className="switch-handle" /> </label> &nbsp;&nbsp;&nbsp; <label className="switch switch-icon switch-danger"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" data-on="&#xf00c" data-off="&#xf00d" /> <span className="switch-handle" /> </label> </div> </div> </div> <div className="col-md-6"> <div className="card"> <div className="card-header"> Switch with icon - pills </div> <div className="card-block"> <label className="switch switch-icon switch-pill switch-primary"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" data-on="&#xf00c" data-off="&#xf00d" /> <span className="switch-handle" /> </label> &nbsp;&nbsp;&nbsp; <label className="switch switch-icon switch-pill switch-secondary"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" data-on="&#xf00c" data-off="&#xf00d" /> <span className="switch-handle" /> </label> &nbsp;&nbsp;&nbsp; <label className="switch switch-icon switch-pill switch-success"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" data-on="&#xf00c" data-off="&#xf00d" /> <span className="switch-handle" /> </label> &nbsp;&nbsp;&nbsp; <label className="switch switch-icon switch-pill switch-warning"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" data-on="&#xf00c" data-off="&#xf00d" /> <span className="switch-handle" /> </label> &nbsp;&nbsp;&nbsp; <label className="switch switch-icon switch-pill switch-info"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" data-on="&#xf00c" data-off="&#xf00d" /> <span className="switch-handle" /> </label> &nbsp;&nbsp;&nbsp; <label className="switch switch-icon switch-pill switch-danger"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" data-on="&#xf00c" data-off="&#xf00d" /> <span className="switch-handle" /> </label> </div> </div> </div> <div className="col-md-6"> <div className="card"> <div className="card-header"> Switch with icon outline </div> <div className="card-block"> <label className="switch switch-icon switch-primary-outline"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" data-on="&#xf00c" data-off="&#xf00d" /> <span className="switch-handle" /> </label> &nbsp;&nbsp;&nbsp; <label className="switch switch-icon switch-secondary-outline"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" data-on="&#xf00c" data-off="&#xf00d" /> <span className="switch-handle" /> </label> &nbsp;&nbsp;&nbsp; <label className="switch switch-icon switch-success-outline"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" data-on="&#xf00c" data-off="&#xf00d" /> <span className="switch-handle" /> </label> &nbsp;&nbsp;&nbsp; <label className="switch switch-icon switch-warning-outline"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" data-on="&#xf00c" data-off="&#xf00d" /> <span className="switch-handle" /> </label> &nbsp;&nbsp;&nbsp; <label className="switch switch-icon switch-info-outline"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" data-on="&#xf00c" data-off="&#xf00d" /> <span className="switch-handle" /> </label> &nbsp;&nbsp;&nbsp; <label className="switch switch-icon switch-danger-outline"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" data-on="&#xf00c" data-off="&#xf00d" /> <span className="switch-handle" /> </label> </div> </div> </div> <div className="col-md-6"> <div className="card"> <div className="card-header"> Switch with icon outline - pills </div> <div className="card-block"> <label className="switch switch-icon switch-pill switch-primary-outline"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" data-on="&#xf00c" data-off="&#xf00d" /> <span className="switch-handle" /> </label> &nbsp;&nbsp;&nbsp; <label className="switch switch-icon switch-pill switch-secondary-outline"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" data-on="&#xf00c" data-off="&#xf00d" /> <span className="switch-handle" /> </label> &nbsp;&nbsp;&nbsp; <label className="switch switch-icon switch-pill switch-success-outline"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" data-on="&#xf00c" data-off="&#xf00d" /> <span className="switch-handle" /> </label> &nbsp;&nbsp;&nbsp; <label className="switch switch-icon switch-pill switch-warning-outline"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" data-on="&#xf00c" data-off="&#xf00d" /> <span className="switch-handle" /> </label> &nbsp;&nbsp;&nbsp; <label className="switch switch-icon switch-pill switch-info-outline"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" data-on="&#xf00c" data-off="&#xf00d" /> <span className="switch-handle" /> </label> &nbsp;&nbsp;&nbsp; <label className="switch switch-icon switch-pill switch-danger-outline"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" data-on="&#xf00c" data-off="&#xf00d" /> <span className="switch-handle" /> </label> </div> </div> </div> <div className="col-md-6"> <div className="card"> <div className="card-header"> Switch with icon outline alternative </div> <div className="card-block"> <label className="switch switch-icon switch-primary-outline-alt"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" data-on="&#xf00c" data-off="&#xf00d" /> <span className="switch-handle" /> </label> &nbsp;&nbsp;&nbsp; <label className="switch switch-icon switch-secondary-outline-alt"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" data-on="&#xf00c" data-off="&#xf00d" /> <span className="switch-handle" /> </label> &nbsp;&nbsp;&nbsp; <label className="switch switch-icon switch-success-outline-alt"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" data-on="&#xf00c" data-off="&#xf00d" /> <span className="switch-handle" /> </label> &nbsp;&nbsp;&nbsp; <label className="switch switch-icon switch-warning-outline-alt"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" data-on="&#xf00c" data-off="&#xf00d" /> <span className="switch-handle" /> </label> &nbsp;&nbsp;&nbsp; <label className="switch switch-icon switch-info-outline-alt"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" data-on="&#xf00c" data-off="&#xf00d" /> <span className="switch-handle" /> </label> &nbsp;&nbsp;&nbsp; <label className="switch switch-icon switch-danger-outline-alt"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" data-on="&#xf00c" data-off="&#xf00d" /> <span className="switch-handle" /> </label> </div> </div> </div> <div className="col-md-6"> <div className="card"> <div className="card-header"> Switch with icon outline alternative - pills </div> <div className="card-block"> <label className="switch switch-icon switch-pill switch-primary-outline-alt"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" data-on="&#xf00c" data-off="&#xf00d" /> <span className="switch-handle" /> </label> &nbsp;&nbsp;&nbsp; <label className="switch switch-icon switch-pill switch-secondary-outline-alt"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" data-on="&#xf00c" data-off="&#xf00d" /> <span className="switch-handle" /> </label> &nbsp;&nbsp;&nbsp; <label className="switch switch-icon switch-pill switch-success-outline-alt"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" data-on="&#xf00c" data-off="&#xf00d" /> <span className="switch-handle" /> </label> &nbsp;&nbsp;&nbsp; <label className="switch switch-icon switch-pill switch-warning-outline-alt"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" data-on="&#xf00c" data-off="&#xf00d" /> <span className="switch-handle" /> </label> &nbsp;&nbsp;&nbsp; <label className="switch switch-icon switch-pill switch-info-outline-alt"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" data-on="&#xf00c" data-off="&#xf00d" /> <span className="switch-handle" /> </label> &nbsp;&nbsp;&nbsp; <label className="switch switch-icon switch-pill switch-danger-outline-alt"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" data-on="&#xf00c" data-off="&#xf00d" /> <span className="switch-handle" /> </label> </div> </div> </div> <div className="col-md-12"> <div className="card"> <div className="card-header"> Sizes </div> <div className="card-block p-0"> <table className="table table-hover table-striped table-align-middle mb-0"> <thead> <tr> <th>Size</th> <th>Example</th> <th>CSS Class</th> </tr> </thead> <tbody> <tr> <td> Large </td> <td> <label className="switch switch-lg switch-3d switch-primary"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" /> <span className="switch-handle" /> </label> </td> <td> Add following class <code>.switch-lg</code> </td> </tr> <tr> <td> Normal </td> <td> <label className="switch switch-3d switch-primary"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" /> <span className="switch-handle" /> </label> </td> <td> - </td> </tr> <tr> <td> Small </td> <td> <label className="switch switch-sm switch-3d switch-primary"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" /> <span className="switch-handle" /> </label> </td> <td> Add following class <code>.switch-sm</code> </td> </tr> <tr> <td> Extra small </td> <td> <label className="switch switch-xs switch-3d switch-primary"> <input type="checkbox" className="switch-input" defaultChecked /> <span className="switch-label" /> <span className="switch-handle" /> </label> </td> <td> Add following class <code>.switch-sm</code> </td> </tr> </tbody> </table> </div> </div> </div> </div> </div> ); } } export default Switches;
src/components/Social.js
maciejziaja/lutech-www
import React from 'react'; import styles from './Social.module.css'; const Social = ({ social }) => ( <a href={social.url} className={styles.link}> <img src={`/social/${social.name}.svg`} className={styles.logo} alt={social.description}/> </a> ); export default Social;
template/src/App.js
andyeskridge/create-react-app
import React, { Component } from 'react'; import logo from './logo.svg'; import './App.css'; class App extends Component { render() { return ( <div className="App"> <div className="App-header"> <img src={logo} className="App-logo" alt="logo" /> <h2>Welcome to React</h2> </div> <p className="App-intro"> To get started, edit <code>src/App.js</code> and save to reload. </p> </div> ); } } export default App;
generators/nfeb/templates/htmls/pcweb/pageapp.js
Horve/generator-nlife
/** * @jsdoc function * @name <%= appname %>.page:<%= pageName %> * @description * # <%= classedName %> * page of the <%= appname %> * `<<%= classedName %>App/>` main file */ import React from 'react'; import NLDownload from '../common/nl_download.js'; import NLDownloadType from '../../../../global_define/download_type.js'; class <%= classedName %>App extends React.Component { static propTypes = { } static defaultProps = { } constructor(props) { super(props); this.state = { }; } contextSetPageTitle() { let me = this; let { props } = me; me.context.setPageTitleBar && me.context.setPageTitleBar({ title: '', extra: null, type: '', bordered: false, isThemeSwitchVisible: false, isUserInfoVisible: true, pageName: '<%= pageName %>' }); } componentDidMount() { this.contextSetPageTitle(); } render() { return <div></div>; } }; <%= classedName %>App.contextTypes = { setPageTitleBar: React.PropTypes.func }; export default <%= classedName %>App;
client/util/react-intl-test-helper.js
MingLow605/MERN-stack-testing
/** * Components using the react-intl module require access to the intl context. * This is not available when mounting single components in Enzyme. * These helper functions aim to address that and wrap a valid, * English-locale intl context around them. */ import React from 'react'; import { IntlProvider, intlShape } from 'react-intl'; import { mount, shallow } from 'enzyme'; // You can pass your messages to the IntlProvider. Optional: remove if unneeded. const messages = require('../../Intl/localizationData/en'); // Create the IntlProvider to retrieve context for wrapping around. const intlProvider = new IntlProvider({ locale: 'en', messages }, {}); export const { intl } = intlProvider.getChildContext(); /** * When using React-Intl `injectIntl` on components, props.intl is required. */ const nodeWithIntlProp = node => { return React.cloneElement(node, { intl }); }; export const shallowWithIntl = node => { return shallow(nodeWithIntlProp(node), { context: { intl } }); }; export const mountWithIntl = node => { return mount(nodeWithIntlProp(node), { context: { intl }, childContextTypes: { intl: intlShape }, }); };
new-lamassu-admin/src/routing/pazuz.routes.js
naconner/lamassu-server
import React from 'react' import { Redirect } from 'react-router-dom' import ATMWallet from 'src/pages/ATMWallet/ATMWallet' import Accounting from 'src/pages/Accounting/Accounting' import Analytics from 'src/pages/Analytics/Analytics' import Assets from 'src/pages/Assets/Assets' import Blacklist from 'src/pages/Blacklist' import Cashout from 'src/pages/Cashout' import Commissions from 'src/pages/Commissions' import { Customers, CustomerProfile } from 'src/pages/Customers' import Funding from 'src/pages/Funding' import Locales from 'src/pages/Locales' import IndividualDiscounts from 'src/pages/LoyaltyPanel/IndividualDiscounts' import PromoCodes from 'src/pages/LoyaltyPanel/PromoCodes' import MachineLogs from 'src/pages/MachineLogs' import CashCassettes from 'src/pages/Maintenance/CashCassettes' import MachineStatus from 'src/pages/Maintenance/MachineStatus' import Notifications from 'src/pages/Notifications/Notifications' import CoinAtmRadar from 'src/pages/OperatorInfo/CoinATMRadar' import ContactInfo from 'src/pages/OperatorInfo/ContactInfo' import ReceiptPrinting from 'src/pages/OperatorInfo/ReceiptPrinting' import SMSNotices from 'src/pages/OperatorInfo/SMSNotices/SMSNotices' import TermsConditions from 'src/pages/OperatorInfo/TermsConditions' import ServerLogs from 'src/pages/ServerLogs' import Services from 'src/pages/Services/Services' import SessionManagement from 'src/pages/SessionManagement/SessionManagement' import Transactions from 'src/pages/Transactions/Transactions' import Triggers from 'src/pages/Triggers' import UserManagement from 'src/pages/UserManagement/UserManagement' import { namespaces } from 'src/utils/config' import { ROLES } from './utils' const getPazuzRoutes = () => [ { key: 'transactions', label: 'Transactions', route: '/transactions', allowedRoles: [ROLES.USER, ROLES.SUPERUSER], component: Transactions }, { key: 'maintenance', label: 'Maintenance', route: '/maintenance', allowedRoles: [ROLES.USER, ROLES.SUPERUSER], get component() { return () => <Redirect to={this.children[0].route} /> }, children: [ { key: 'cash_cassettes', label: 'Cash Cassettes', route: '/maintenance/cash-cassettes', allowedRoles: [ROLES.USER, ROLES.SUPERUSER], component: CashCassettes }, { key: 'funding', label: 'Funding', route: '/maintenance/funding', allowedRoles: [ROLES.USER, ROLES.SUPERUSER], component: Funding }, { key: 'logs', label: 'Machine Logs', route: '/maintenance/logs', allowedRoles: [ROLES.USER, ROLES.SUPERUSER], component: MachineLogs }, { key: 'machine-status', label: 'Machine Status', route: '/maintenance/machine-status', allowedRoles: [ROLES.USER, ROLES.SUPERUSER], component: MachineStatus }, { key: 'server-logs', label: 'Server', route: '/maintenance/server-logs', allowedRoles: [ROLES.USER, ROLES.SUPERUSER], component: ServerLogs } ] }, { key: 'analytics', label: 'Analytics', route: '/analytics', allowedRoles: [ROLES.USER, ROLES.SUPERUSER], component: Analytics }, { key: 'settings', label: 'Settings', route: '/settings', allowedRoles: [ROLES.USER, ROLES.SUPERUSER], get component() { return () => <Redirect to={this.children[0].route} /> }, children: [ { key: namespaces.COMMISSIONS, label: 'Commissions', route: '/settings/commissions', allowedRoles: [ROLES.USER, ROLES.SUPERUSER], component: Commissions }, { key: namespaces.LOCALE, label: 'Locales', route: '/settings/locale', allowedRoles: [ROLES.USER, ROLES.SUPERUSER], component: Locales }, { key: namespaces.CASH_OUT, label: 'Cash-out', route: '/settings/cash-out', allowedRoles: [ROLES.USER, ROLES.SUPERUSER], component: Cashout }, { key: namespaces.NOTIFICATIONS, label: 'Notifications', route: '/settings/notifications', allowedRoles: [ROLES.USER, ROLES.SUPERUSER], component: Notifications }, { key: 'services', label: '3rd Party Services', route: '/settings/3rd-party-services', allowedRoles: [ROLES.USER, ROLES.SUPERUSER], component: Services }, { key: namespaces.OPERATOR_INFO, label: 'Operator Info', route: '/settings/operator-info', title: 'Operator Information', allowedRoles: [ROLES.USER, ROLES.SUPERUSER], get component() { return () => ( <Redirect to={{ pathname: this.children[0].route, state: { prev: this.state?.prev } }} /> ) }, children: [ { key: 'contact-info', label: 'Contact information', route: '/settings/operator-info/contact-info', allowedRoles: [ROLES.USER, ROLES.SUPERUSER], component: ContactInfo }, { key: 'receipt-printing', label: 'Receipt', route: '/settings/operator-info/receipt-printing', allowedRoles: [ROLES.USER, ROLES.SUPERUSER], component: ReceiptPrinting }, { key: 'sms-notices', label: 'SMS notices', route: '/settings/operator-info/sms-notices', allowedRoles: [ROLES.USER, ROLES.SUPERUSER], component: SMSNotices }, { key: 'coin-atm-radar', label: 'Coin ATM Radar', route: '/settings/operator-info/coin-atm-radar', allowedRoles: [ROLES.USER, ROLES.SUPERUSER], component: CoinAtmRadar }, { key: 'terms-conditions', label: 'Terms & Conditions', route: '/settings/operator-info/terms-conditions', allowedRoles: [ROLES.USER, ROLES.SUPERUSER], component: TermsConditions } ] } ] }, { key: 'compliance', label: 'Compliance', route: '/compliance', allowedRoles: [ROLES.USER, ROLES.SUPERUSER], get component() { return () => <Redirect to={this.children[0].route} /> }, children: [ { key: 'triggers', label: 'Triggers', route: '/compliance/triggers', allowedRoles: [ROLES.USER, ROLES.SUPERUSER], component: Triggers }, { key: 'customers', label: 'Customers', route: '/compliance/customers', allowedRoles: [ROLES.USER, ROLES.SUPERUSER], component: Customers }, { key: 'blacklist', label: 'Blacklist', route: '/compliance/blacklist', allowedRoles: [ROLES.USER, ROLES.SUPERUSER], component: Blacklist }, { key: 'loyalty', label: 'Loyalty', route: '/compliance/loyalty', allowedRoles: [ROLES.USER, ROLES.SUPERUSER], get component() { return () => ( <Redirect to={{ pathname: this.children[0].route, state: { prev: this.state?.prev } }} /> ) }, children: [ { key: 'individual-discounts', label: 'Individual Discounts', route: '/compliance/loyalty/individual-discounts', allowedRoles: [ROLES.USER, ROLES.SUPERUSER], component: IndividualDiscounts }, { key: 'promo-codes', label: 'Promo Codes', route: '/compliance/loyalty/codes', allowedRoles: [ROLES.USER, ROLES.SUPERUSER], component: PromoCodes } ] }, { key: 'customer', route: '/compliance/customer/:id', allowedRoles: [ROLES.USER, ROLES.SUPERUSER], component: CustomerProfile } ] }, { key: 'accounting', label: 'Accounting', route: '/accounting', allowedRoles: [ROLES.USER, ROLES.SUPERUSER], get component() { return () => <Redirect to={this.children[0].route} /> }, children: [ { key: 'accountingpage', label: 'Accounting', route: '/accounting/accounting', allowedRoles: [ROLES.USER, ROLES.SUPERUSER], component: Accounting }, { key: 'atmwallets', label: 'ATM Wallets', route: '/accounting/wallets', allowedRoles: [ROLES.USER, ROLES.SUPERUSER], component: ATMWallet }, { key: 'assetspage', label: 'Assets', route: '/accounting/assets', allowedRoles: [ROLES.USER, ROLES.SUPERUSER], component: Assets } ] }, { key: 'system', label: 'System', route: '/system', allowedRoles: [ROLES.SUPERUSER], get component() { return () => <Redirect to={this.children[0].route} /> }, children: [ { key: 'user-management', label: 'User Management', route: '/system/user-management', allowedRoles: [ROLES.SUPERUSER], component: UserManagement }, { key: 'session-management', label: 'Session Management', route: '/system/session-management', allowedRoles: [ROLES.SUPERUSER], component: SessionManagement } ] } ] export default getPazuzRoutes
src/components/blog_category.js
b0ts/react-redux-sweetlightstudios-website
import React from 'react'; import { LinkContainer } from 'react-router-bootstrap'; import { NavItem } from 'react-bootstrap'; const BlogCategory = ({ id, name, count, linkBy }) => ( <div> <LinkContainer className='blog-category-link' to={ '/blog/category/' + linkBy + '/page/1/' } > <NavItem className="blog-item" eventKey={ id } > &bull; { name } <span className='blog-category-count'> ({ count })</span> </NavItem> </LinkContainer> </div> ); export default BlogCategory;
node_modules/styled-components/src/models/StyleSheet.js
bburnett-cpf/react-intro
// @flow import React from 'react' import BrowserStyleSheet from './BrowserStyleSheet' import ServerStyleSheet from './ServerStyleSheet' export const SC_ATTR = 'data-styled-components' export const LOCAL_ATTR = 'data-styled-components-is-local' export const CONTEXT_KEY = '__styled-components-stylesheet__' export interface Tag { isLocal: boolean, components: { [string]: Object }, isFull(): boolean, addComponent(componentId: string): void, inject(componentId: string, css: string, name: ?string): void, toHTML(): string, toReactElement(key: string): React.Element<*>, clone(): Tag, } let instance = null // eslint-disable-next-line no-use-before-define export const clones: Array<StyleSheet> = [] export default class StyleSheet { tagConstructor: (boolean) => Tag tags: Array<Tag> names: { [string]: boolean } hashes: { [string]: string } = {} deferredInjections: { [string]: string } = {} componentTags: { [string]: Tag } constructor(tagConstructor: (boolean) => Tag, tags: Array<Tag> = [], names: { [string]: boolean } = {}, ) { this.tagConstructor = tagConstructor this.tags = tags this.names = names this.constructComponentTagMap() } constructComponentTagMap() { this.componentTags = {} this.tags.forEach(tag => { Object.keys(tag.components).forEach(componentId => { this.componentTags[componentId] = tag }) }) } /* Best level of caching—get the name from the hash straight away. */ getName(hash: any) { return this.hashes[hash.toString()] } /* Second level of caching—if the name is already in the dom, don't * inject anything and record the hash for getName next time. */ alreadyInjected(hash: any, name: string) { if (!this.names[name]) return false this.hashes[hash.toString()] = name return true } /* Third type of caching—don't inject components' componentId twice. */ hasInjectedComponent(componentId: string) { return !!this.componentTags[componentId] } deferredInject(componentId: string, isLocal: boolean, css: string) { if (this === instance) { clones.forEach(clone => { clone.deferredInject(componentId, isLocal, css) }) } this.getOrCreateTag(componentId, isLocal) this.deferredInjections[componentId] = css } inject(componentId: string, isLocal: boolean, css: string, hash: ?any, name: ?string) { if (this === instance) { clones.forEach(clone => { clone.inject(componentId, isLocal, css) }) } const tag = this.getOrCreateTag(componentId, isLocal) const deferredInjection = this.deferredInjections[componentId] if (deferredInjection) { tag.inject(componentId, deferredInjection) delete this.deferredInjections[componentId] } tag.inject(componentId, css, name) if (hash && name) { this.hashes[hash.toString()] = name } } toHTML() { return this.tags.map(tag => tag.toHTML()).join('') } toReactElements() { return this.tags.map((tag, i) => tag.toReactElement(`sc-${i}`)) } getOrCreateTag(componentId: string, isLocal: boolean) { const existingTag = this.componentTags[componentId] if (existingTag) { return existingTag } const lastTag = this.tags[this.tags.length - 1] const componentTag = (!lastTag || lastTag.isFull() || lastTag.isLocal !== isLocal) ? this.createNewTag(isLocal) : lastTag this.componentTags[componentId] = componentTag componentTag.addComponent(componentId) return componentTag } createNewTag(isLocal: boolean) { const newTag = this.tagConstructor(isLocal) this.tags.push(newTag) return newTag } static get instance() { return instance || (instance = StyleSheet.create()) } static reset(isServer: ?boolean) { instance = StyleSheet.create(isServer) } /* We can make isServer totally implicit once Jest 20 drops and we * can change environment on a per-test basis. */ static create(isServer: ?boolean = typeof document === 'undefined') { return (isServer ? ServerStyleSheet : BrowserStyleSheet).create() } static clone(oldSheet: StyleSheet) { const newSheet = new StyleSheet( oldSheet.tagConstructor, oldSheet.tags.map(tag => tag.clone()), { ...oldSheet.names }, ) newSheet.hashes = { ...oldSheet.hashes } newSheet.deferredInjections = { ...oldSheet.deferredInjections } clones.push(newSheet) return newSheet } }
src/components/Header/Header.js
hack-duke/hackduke-code-for-good-website
import React from 'react' import Scroll from 'react-scroll' import { Navbar, Nav, NavItem } from 'react-bootstrap' import classes from './Header.scss' // <Nav pullRight> // <a className={classes.applyButton} eventKey={1} href={'http://my.hackduke.org/login'}>Login</a> // </Nav> class Header extends React.Component { scrollToElement (elem) { Scroll.scroller.scrollTo(elem, { duration: 850, delay: 100, smooth: true }) } render () { return ( <div> <Navbar inverse fixedTop> <Navbar.Header> <Navbar.Brand> </Navbar.Brand> <Navbar.Toggle /> </Navbar.Header> <Navbar.Collapse> <Nav> <NavItem className={classes.navItem} onClick={() => this.scrollToElement('aboutScrollPoint')}>ABOUT</NavItem> <NavItem className={classes.navItem} onClick={() => this.scrollToElement('tracksScrollPoint')}>TRACKS</NavItem> <NavItem className={classes.navItem} onClick={() => this.scrollToElement('faqScrollPoint')}>FAQS</NavItem> <NavItem className={classes.navItem} onClick={() => this.scrollToElement('sponsorsScrollPoint')}>SPONSORS</NavItem> </Nav> </Navbar.Collapse> </Navbar> </div> ) } } export default Header
app/components/Welcome/index.js
fforres/coworks_2
/** * * Welcome * */ import React from 'react'; import styles from './styles.css'; class Welcome extends React.Component { // eslint-disable-line react/prefer-stateless-function render() { return ( <div className={styles.welcome}> <h1>Hola Coworkers!</h1> <p> Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. </p> </div> ); } } export default Welcome;
modules/Router.js
axross/react-router
import React from 'react' import warning from 'warning' import createHashHistory from 'history/lib/createHashHistory' import { createRoutes } from './RouteUtils' import RoutingContext from './RoutingContext' import useRoutes from './useRoutes' import { routes } from './PropTypes' const { func, object } = React.PropTypes /** * A <Router> is a high-level API for automatically setting up * a router that renders a <RoutingContext> with all the props * it needs each time the URL changes. */ const Router = React.createClass({ propTypes: { history: object, children: routes, routes, // alias for children createElement: func, onError: func, onUpdate: func, parseQueryString: func, stringifyQuery: func }, getInitialState() { return { location: null, routes: null, params: null, components: null } }, handleError(error) { if (this.props.onError) { this.props.onError.call(this, error) } else { // Throw errors by default so we don't silently swallow them! throw error // This error probably occurred in getChildRoutes or getComponents. } }, componentWillMount() { let { history, children, routes, parseQueryString, stringifyQuery } = this.props let createHistory = history ? () => history : createHashHistory this.history = useRoutes(createHistory)({ routes: createRoutes(routes || children), parseQueryString, stringifyQuery }) this._unlisten = this.history.listen((error, state) => { if (error) { this.handleError(error) } else { this.setState(state, this.props.onUpdate) } }) }, componentWillReceiveProps(nextProps) { warning( nextProps.history === this.props.history, 'You cannot change <Router history>; it will be ignored' ) }, componentWillUnmount() { if (this._unlisten) this._unlisten() }, render() { let { location, routes, params, components } = this.state let { createElement } = this.props if (location == null) return null // Async match return React.createElement(RoutingContext, { history: this.history, createElement, location, routes, params, components }) } }) export default Router
app/routes/index.js
alubbe/redux-blog-example
import React from 'react'; import { Route } from 'react-router'; import App from './App'; import SignupRoute from './SignupRoute'; import LoginRoute from './LoginRoute'; import ProfileRoute from './ProfileRoute'; import NotFound from '../components/NotFound'; import redirectBackAfter from '../utils/redirectBackAfter'; import fillStore from '../utils/fillStore'; import DashboardRoute from './DashboardRoute'; import * as Posts from './Posts'; const routes = ( <Route component={App}> <Route path="/signup" component={SignupRoute} /> <Route path="/login" component={LoginRoute} /> <Route path="/" component={Posts.List} /> <Route path="/posts/:id" component={Posts.View} /> <Route requireAuth> <Route path="/profile" component={ProfileRoute} /> <Route path="/dashboard" component={DashboardRoute} /> <Route path="/dashboard/add" component={Posts.Edit} /> <Route path="/dashboard/edit/:id" component={Posts.Edit} /> </Route> <Route path="*" component={NotFound} /> </Route> ); function walk(routes, cb) { cb(routes); if (routes.childRoutes) { routes.childRoutes.forEach(route => walk(route, cb)); } return routes; } export default (store, client) => { return walk(Route.createRouteFromReactElement(routes), route => { route.onEnter = (nextState, transition) => { const loggedIn = !!store.getState().auth.token; if (route.requireAuth && !loggedIn) { transition.to(...redirectBackAfter('/login', nextState)); } else if (client) { fillStore(store, nextState, [route.component]); } }; }); };
antd-dva/dva-restart/src/routes/IndexPage.js
JianmingXia/StudyTest
import React from 'react'; import { connect } from 'dva'; import styles from './IndexPage.css'; import Header from '../components/Header'; function IndexPage() { return ( <div> <Header /> <div className={styles.normal}> <h1 className={styles.title}>Yay! Welcome to dva!</h1> <div className={styles.welcome} /> <ul className={styles.list}> <li>To get started, edit <code>src/index.js</code> and save to reload.</li> <li><a href="https://github.com/dvajs/dva-docs/blob/master/v1/en-us/getting-started.md">Getting Started</a></li> </ul> </div> </div> ); } IndexPage.propTypes = { }; export default connect()(IndexPage);
node_modules/@material-ui/core/es/SvgIcon/SvgIcon.js
pcclarke/civ-techs
import _extends from "@babel/runtime/helpers/extends"; import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose"; import React from 'react'; import PropTypes from 'prop-types'; import clsx from 'clsx'; import withStyles from '../styles/withStyles'; import { capitalize } from '../utils/helpers'; export const styles = theme => ({ /* Styles applied to the root element. */ root: { userSelect: 'none', width: '1em', height: '1em', display: 'inline-block', fill: 'currentColor', flexShrink: 0, fontSize: theme.typography.pxToRem(24), transition: theme.transitions.create('fill', { duration: theme.transitions.duration.shorter }) }, /* Styles applied to the root element if `color="primary"`. */ colorPrimary: { color: theme.palette.primary.main }, /* Styles applied to the root element if `color="secondary"`. */ colorSecondary: { color: theme.palette.secondary.main }, /* Styles applied to the root element if `color="action"`. */ colorAction: { color: theme.palette.action.active }, /* Styles applied to the root element if `color="error"`. */ colorError: { color: theme.palette.error.main }, /* Styles applied to the root element if `color="disabled"`. */ colorDisabled: { color: theme.palette.action.disabled }, /* Styles applied to the root element if `fontSize="inherit"`. */ fontSizeInherit: { fontSize: 'inherit' }, /* Styles applied to the root element if `fontSize="small"`. */ fontSizeSmall: { fontSize: theme.typography.pxToRem(20) }, /* Styles applied to the root element if `fontSize="large"`. */ fontSizeLarge: { fontSize: theme.typography.pxToRem(35) } }); const SvgIcon = React.forwardRef(function SvgIcon(props, ref) { const { children, classes, className, color = 'inherit', component: Component = 'svg', fontSize = 'default', htmlColor, titleAccess, viewBox = '0 0 24 24' } = props, other = _objectWithoutPropertiesLoose(props, ["children", "classes", "className", "color", "component", "fontSize", "htmlColor", "titleAccess", "viewBox"]); return React.createElement(Component, _extends({ className: clsx(classes.root, color !== 'inherit' && classes[`color${capitalize(color)}`], fontSize !== 'default' && classes[`fontSize${capitalize(fontSize)}`], className), focusable: "false", viewBox: viewBox, color: htmlColor, "aria-hidden": titleAccess ? 'false' : 'true', role: titleAccess ? 'img' : 'presentation', ref: ref }, other), children, titleAccess ? React.createElement("title", null, titleAccess) : null); }); process.env.NODE_ENV !== "production" ? SvgIcon.propTypes = { /** * Node passed into the SVG element. */ children: PropTypes.node.isRequired, /** * Override or extend the styles applied to the component. * See [CSS API](#css) below for more details. */ classes: PropTypes.object.isRequired, /** * @ignore */ className: PropTypes.string, /** * The color of the component. It supports those theme colors that make sense for this component. * You can use the `htmlColor` property to apply a color attribute to the SVG element. */ color: PropTypes.oneOf(['inherit', 'primary', 'secondary', 'action', 'error', 'disabled']), /** * The component used for the root node. * Either a string to use a DOM element or a component. */ component: PropTypes.elementType, /** * The fontSize applied to the icon. Defaults to 24px, but can be configure to inherit font size. */ fontSize: PropTypes.oneOf(['inherit', 'default', 'small', 'large']), /** * Applies a color attribute to the SVG element. */ htmlColor: PropTypes.string, /** * The shape-rendering attribute. The behavior of the different options is described on the * [MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/shape-rendering). * If you are having issues with blurry icons you should investigate this property. */ shapeRendering: PropTypes.string, /** * Provides a human-readable title for the element that contains it. * https://www.w3.org/TR/SVG-access/#Equivalent */ titleAccess: PropTypes.string, /** * Allows you to redefine what the coordinates without units mean inside an SVG element. * For example, if the SVG element is 500 (width) by 200 (height), * and you pass viewBox="0 0 50 20", * this means that the coordinates inside the SVG will go from the top left corner (0,0) * to bottom right (50,20) and each unit will be worth 10px. */ viewBox: PropTypes.string } : void 0; SvgIcon.muiName = 'SvgIcon'; export default withStyles(styles, { name: 'MuiSvgIcon' })(SvgIcon);
src/components/DateRange/index.js
Adphorus/react-date-range
import React, { Component } from 'react'; import PropTypes from 'prop-types'; import Calendar from '../Calendar'; import { rangeShape } from '../DayCell'; import { findNextRangeIndex, generateStyles } from '../../utils'; import { isBefore, differenceInCalendarDays, addDays, min, isWithinInterval, max } from 'date-fns'; import classnames from 'classnames'; import coreStyles from '../../styles'; class DateRange extends Component { constructor(props, context) { super(props, context); this.state = { focusedRange: props.initialFocusedRange || [findNextRangeIndex(props.ranges), 0], preview: null, }; this.styles = generateStyles([coreStyles, props.classNames]); } calcNewSelection = (value, isSingleValue = true) => { const focusedRange = this.props.focusedRange || this.state.focusedRange; const { ranges, onChange, maxDate, moveRangeOnFirstSelection, retainEndDateOnFirstSelection, disabledDates, } = this.props; const focusedRangeIndex = focusedRange[0]; const selectedRange = ranges[focusedRangeIndex]; if (!selectedRange || !onChange) return {}; let { startDate, endDate } = selectedRange; const now = new Date(); let nextFocusRange; if (!isSingleValue) { startDate = value.startDate; endDate = value.endDate; } else if (focusedRange[1] === 0) { // startDate selection const dayOffset = differenceInCalendarDays(endDate || now, startDate); const calculateEndDate = () => { if (moveRangeOnFirstSelection) { return addDays(value, dayOffset); } if (retainEndDateOnFirstSelection) { if (!endDate || isBefore(value, endDate)) { return endDate; } return value; } return value || now; }; startDate = value; endDate = calculateEndDate(); if (maxDate) endDate = min([endDate, maxDate]); nextFocusRange = [focusedRange[0], 1]; } else { endDate = value; } // reverse dates if startDate before endDate let isStartDateSelected = focusedRange[1] === 0; if (isBefore(endDate, startDate)) { isStartDateSelected = !isStartDateSelected; [startDate, endDate] = [endDate, startDate]; } const inValidDatesWithinRange = disabledDates.filter(disabledDate => isWithinInterval(disabledDate, { start: startDate, end: endDate, }) ); if (inValidDatesWithinRange.length > 0) { if (isStartDateSelected) { startDate = addDays(max(inValidDatesWithinRange), 1); } else { endDate = addDays(min(inValidDatesWithinRange), -1); } } if (!nextFocusRange) { const nextFocusRangeIndex = findNextRangeIndex(this.props.ranges, focusedRange[0]); nextFocusRange = [nextFocusRangeIndex, 0]; } return { wasValid: !(inValidDatesWithinRange.length > 0), range: { startDate, endDate }, nextFocusRange: nextFocusRange, }; }; setSelection = (value, isSingleValue) => { const { onChange, ranges, onRangeFocusChange } = this.props; const focusedRange = this.props.focusedRange || this.state.focusedRange; const focusedRangeIndex = focusedRange[0]; const selectedRange = ranges[focusedRangeIndex]; if (!selectedRange) return; const newSelection = this.calcNewSelection(value, isSingleValue); onChange({ [selectedRange.key || `range${focusedRangeIndex + 1}`]: { ...selectedRange, ...newSelection.range, }, }); this.setState({ focusedRange: newSelection.nextFocusRange, preview: null, }); onRangeFocusChange && onRangeFocusChange(newSelection.nextFocusRange); }; handleRangeFocusChange = focusedRange => { this.setState({ focusedRange }); this.props.onRangeFocusChange && this.props.onRangeFocusChange(focusedRange); }; updatePreview = val => { if (!val) { this.setState({ preview: null }); return; } const { rangeColors, ranges } = this.props; const focusedRange = this.props.focusedRange || this.state.focusedRange; const color = ranges[focusedRange[0]]?.color || rangeColors[focusedRange[0]] || color; this.setState({ preview: { ...val.range, color } }); }; render() { return ( <Calendar focusedRange={this.state.focusedRange} onRangeFocusChange={this.handleRangeFocusChange} preview={this.state.preview} onPreviewChange={value => { this.updatePreview(value ? this.calcNewSelection(value) : null); }} {...this.props} displayMode="dateRange" className={classnames(this.styles.dateRangeWrapper, this.props.className)} onChange={this.setSelection} updateRange={val => this.setSelection(val, false)} ref={target => { this.calendar = target; }} /> ); } } DateRange.defaultProps = { classNames: {}, ranges: [], moveRangeOnFirstSelection: false, retainEndDateOnFirstSelection: false, rangeColors: ['#3d91ff', '#3ecf8e', '#fed14c'], disabledDates: [], }; DateRange.propTypes = { ...Calendar.propTypes, onChange: PropTypes.func, onRangeFocusChange: PropTypes.func, className: PropTypes.string, ranges: PropTypes.arrayOf(rangeShape), moveRangeOnFirstSelection: PropTypes.bool, retainEndDateOnFirstSelection: PropTypes.bool, }; export default DateRange;
src/client.js
YorkshireDigital/yorkshiredigital.com
import React from 'react'; import ReactDOM from 'react-dom'; import { Router, browserHistory } from 'react-router'; import configureStore from './store.js'; import { Provider } from 'react-redux'; import routes from './routes'; import RadiumContainer from './universal/containers/RadiumContainer'; import { syncHistoryWithStore } from 'react-router-redux'; const store = configureStore(window.__INITIAL_STATE__); delete window.__INITIAL_STATE__; const history = syncHistoryWithStore(browserHistory, store); /** * Fire-up React Router. */ const reactRoot = window.document.getElementById('react-root'); ReactDOM.render( <Provider store={store}> <RadiumContainer> <Router routes={routes} history={history} /> </RadiumContainer> </Provider>, reactRoot ); /** * Detect whether the server-side render has been discarded due to an invalid checksum. */ if (process.env.NODE_ENV === 'production') { if (!reactRoot.firstChild || !reactRoot.firstChild.attributes || !reactRoot.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.'); } }
src/router.js
zaneriley/personal-site
/** * 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'; function decodeParam(val) { if (!(typeof val === 'string' || val.length === 0)) { return val; } try { return decodeURIComponent(val); } catch (err) { if (err instanceof URIError) { err.message = `Failed to decode param '${val}'`; err.status = 400; } throw err; } } // Match the provided URL path pattern to an actual URI string. For example: // matchURI({ path: '/posts/:id' }, '/dummy') => null // matchURI({ path: '/posts/:id' }, '/posts/123') => { id: 123 } function matchURI(route, path) { const match = route.pattern.exec(path); if (!match) { return null; } const params = Object.create(null); for (let i = 1; i < match.length; i++) { params[route.keys[i - 1].name] = match[i] !== undefined ? decodeParam(match[i]) : undefined; } return params; } // Find the route matching the specified location (context), fetch the required data, // instantiate and return a React component function resolve(routes, context) { for (const route of routes) { const params = matchURI(route, context.error ? '/error' : context.pathname); if (!params) { continue; } // Check if the route has any data requirements, for example: // { path: '/tasks/:id', data: { task: 'GET /api/tasks/$id' }, page: './pages/task' } if (route.data) { // Load page component and all required data in parallel const keys = Object.keys(route.data); return Promise.all([ route.load(), ...keys.map(key => { const query = route.data[key]; const method = query.substring(0, query.indexOf(' ')); // GET let url = query.substr(query.indexOf(' ') + 1); // /api/tasks/$id // TODO: Optimize Object.keys(params).forEach((k) => { url = url.replace(`${k}`, params[k]); }); return fetch(url, { method }).then(resp => resp.json()); }), ]).then(([Page, ...data]) => { const props = keys.reduce((result, key, i) => ({ ...result, [key]: data[i] }), {}); return <Page route={{ ...route, params }} error={context.error} {...props} />; }); } return route.load().then(Page => <Page route={{ ...route, params }} error={context.error} />); } const error = new Error('Page not found'); error.status = 404; return Promise.reject(error); } export default { resolve };
node_modules/react-navigation/lib-rn/views/withNavigation.js
RahulDesai92/PHR
import React from 'react'; import propTypes from 'prop-types'; import hoistStatics from 'hoist-non-react-statics'; var babelPluginFlowReactPropTypes_proptype_NavigationAction = require('../TypeDefinition').babelPluginFlowReactPropTypes_proptype_NavigationAction || require('prop-types').any; var babelPluginFlowReactPropTypes_proptype_NavigationState = require('../TypeDefinition').babelPluginFlowReactPropTypes_proptype_NavigationState || require('prop-types').any; export default function withNavigation(Component) { const componentWithNavigation = (props, { navigation }) => <Component {...props} navigation={navigation} />; componentWithNavigation.displayName = `withNavigation(${Component.displayName || Component.name})`; componentWithNavigation.contextTypes = { navigation: propTypes.object.isRequired }; return hoistStatics(componentWithNavigation, Component); }
app/assets/scripts/components/modal-download/download-type-selector.js
openaq/openaq.org
import React from 'react'; import { PropTypes as T } from 'prop-types'; const downloadTypes = [ { id: 'locations', label: 'Locations', }, { id: 'projects', label: 'Datasets', }, ]; export const downloadTypeDefault = downloadTypes[0].id; export default function DownloadType(props) { const { selected, onSelect } = props; return ( <fieldset className="form__fieldset form__fieldset--parameters"> <legend className="form__legend">Data download</legend> <div className="form__option-group"> {downloadTypes.map(o => { return ( <label className="form__option form__option--custom-radio" htmlFor={o.id} key={o.id} > <input type="radio" value={o.id} id={o.id} name="download-data-type" onChange={() => onSelect(o.id)} checked={selected === o.id} /> <span className="form__option__text">{o.label}</span> <span className="form__option__ui"></span> </label> ); })} </div> </fieldset> ); } DownloadType.propTypes = { title: T.string, list: T.array, selected: T.array, onSelect: T.func, };
itemField/form.js
KAESapps/ks-admin
import get from 'lodash/get' import React from 'react' const el = React.createElement import { observer } from 'mobservable-react' import { map, asReference, observable } from 'mobservable' import Command from '../reactiveCollection/Command' import Box from '../layout/flex' import debounce from 'lodash/debounce' const preventDefault = ev => ev.preventDefault() const numberEditor = ({model, path, itemId, $patch}) => { const numberValueAsText = observable(null) return { setValue: newVal => { numberValueAsText(newVal) newVal = parseFloat(newVal) $patch.set(path, isNaN(newVal) ? null : newVal) }, getValue: observable(() => { var itemValue = model.get(itemId).value var partEditing = $patch.has(path) var numberValueOrNull = partEditing ? $patch.get(path) : get(itemValue, path) if (isNaN(numberValueOrNull) || numberValueOrNull == null) return '' return parseFloat(numberValueAsText()) === numberValueOrNull ? numberValueAsText() : numberValueOrNull+'' }), } } const textEditor = ({model, path, itemId, $patch}) => ({ setValue: newVal => { $patch.set(path, newVal) }, getValue: observable(() => { var itemValue = model.get(itemId).value var partEditing = $patch.has(path) return partEditing ? $patch.get(path) : get(itemValue, path) }), }) export var fieldEditor = function(collections, collectionId, itemId, $patch, options) { var model = collections[collectionId].model var path = options.path var type = options.type || 'text' const { setValue: onChange, getValue } = (type === 'number' ? numberEditor : textEditor)({model, path, itemId, $patch}) return observer(function() { const value = getValue() if (typeof type === 'function') return el(type, {value, onChange}) return el(type === 'textarea' ? 'textarea' : 'input', { className: 'ui input', type: type === 'number' ? 'tel' : type, value: value || "", onChange: ev => onChange(ev.target.value), }) }) } export var labeledPart = function(collections, collectionId, itemId, $patch, options) { var label = options.label var innerView = options.view var cmp = typeof innerView === 'function' ? innerView(collections, collectionId, itemId, $patch, options) : fieldEditor(collections, collectionId, itemId, $patch, options) return function () { return el('div', { className: 'field' }, el('label', {}, label), el(cmp), el('p', {}, options.help) ) } } export const partFactory = function(collections, collectionId, itemId, $patch) { return function(part) { if (typeof part === 'function') return part(collections, collectionId, itemId, $patch) if (typeof part === 'string') part = {path: part, label: part, type: 'text'} if (Array.isArray(part)) part = {path: part[0], label: part[1], type: 'text'} return labeledPart(collections, collectionId, itemId, $patch, part) } } export default function (opts, parts) { if (arguments.length < 2) { parts = opts opts = { autoSave: false } } return function (collections, collectionId, itemId) { var model = collections[collectionId].model var $patch = map({}, asReference) var save = new Command(() => { return model.patch(itemId, $patch.toJs()).then(() => $patch.clear()) }) var cmps = parts.map(partFactory(collections, collectionId, itemId, $patch)) if (opts.autoSave) { $patch.observe(debounce(save.trigger, 500)) } return observer(function () { var editing = $patch.keys().length > 0 return el(Box, { className: 'ui form'}, el('form', {onSubmit: preventDefault}, cmps.map((cmp, i) => el(cmp, {key: i}))), el('div', { className: 'ui hidden divider'}), editing && save.status() === 'idle' ? el('button', { className: 'ui primary button', onClick: save.trigger, // disabled: !editing || save.status() !== 'idle', }, 'Enregistrer') : null, save.status() === 'inProgress' ? el('button', { className: 'ui primary loading button', }, 'Enregistrer') : null, save.status() === 'success' ? el('button', { className: 'ui positive button', disabled: true, }, 'Enregistré') : null, !opts.autoSave && editing && save.status() === 'idle' ? el('button', { // disabled: !editing || save.status() !== 'idle', className: 'ui button', onClick: () => $patch.clear(), }, "Annuler") : null, save.status() === 'error' ? el('div', { className: 'ui negative message' }, save.status('fr')) : null ) }) } }
src/svg-icons/editor/space-bar.js
tan-jerene/material-ui
import React from 'react'; import pure from 'recompose/pure'; import SvgIcon from '../../SvgIcon'; let EditorSpaceBar = (props) => ( <SvgIcon {...props}> <path d="M18 9v4H6V9H4v6h16V9z"/> </SvgIcon> ); EditorSpaceBar = pure(EditorSpaceBar); EditorSpaceBar.displayName = 'EditorSpaceBar'; EditorSpaceBar.muiName = 'SvgIcon'; export default EditorSpaceBar;
src/navigation/tabs.js
N3TC4T/Nearby-Live
/** * Tabs Scenes */ import React from 'react'; import {Scene} from 'react-native-router-flux'; // Consts and Libs import {AppStyles, AppSizes, AppColors} from '@theme/'; // Components import {TabIcon} from '@ui/'; // Scenes import Placeholder from '@components/general/Placeholder'; // Containers import Home from '@containers/main/home/HomeContainer'; import SystemNotificationsContainer from '@containers/main/system-notifications/SystemNotificationsContainer'; const sceneStyleProps = { sceneStyle: { backgroundColor: AppColors.background, paddingBottom: AppSizes.tabbarHeight } }; /* Routes ==================================================================== */ const scenes = ( <Scene key='tabBar' tabs tabBarIconContainerStyle={AppStyles.tabbar} pressOpacity={0.95}> <Scene {...sceneStyleProps} hideNavBar key='home' icon={props => <TabIcon {...props} title='Home' icon='home' size={22} type='material-icons' />} component={Home} analyticsDesc='Home: Main' /> <Scene {...sceneStyleProps} key='people' hideNavBar component={Placeholder} text='people' icon={props => <TabIcon {...props} title='Explore' icon='explore' size={22} type='material-icons' />} analyticsDesc='People: People' /> <Scene {...sceneStyleProps} key='new-post' hideNavBar component={Placeholder} text='Add New Post' icon={props => <TabIcon {...props} raised icon='add' size={20} type='material-icons' />} analyticsDesc='Posts: New' /> <Scene {...sceneStyleProps} key='notifications' hideNavBar component={SystemNotificationsContainer} icon={props => <TabIcon {...props} tabType='notification-system' title='Notifications' icon='notifications' size={22} type='material-icons' />} analyticsDesc='SystemNotifications: Notifications-List' /> <Scene {...sceneStyleProps} key='profile' hideNavBar component={Placeholder} text='Profile' icon={props => <TabIcon {...props} title='Profile' icon='person' size={22} type='material-icons' />} analyticsDesc='Profile: Profile' /> </Scene> ); export default scenes;
src/docs/examples/Label/ExampleRequired.js
vonZ/rc-vvz
import React from 'react'; import Label from 'ps-react/Label'; /** Required label */ export default function ExampleRequired() { return <Label htmlFor="test" label="test" required /> }
src/components/common/svg-icons/notification/airline-seat-legroom-reduced.js
abzfarah/Pearson.NAPLAN.GnomeH
import React from 'react'; import pure from 'recompose/pure'; import SvgIcon from '../../SvgIcon'; let NotificationAirlineSeatLegroomReduced = (props) => ( <SvgIcon {...props}> <path d="M19.97 19.2c.18.96-.55 1.8-1.47 1.8H14v-3l1-4H9c-1.65 0-3-1.35-3-3V3h6v6h5c1.1 0 2 .9 2 2l-2 7h1.44c.73 0 1.39.49 1.53 1.2zM5 12V3H3v9c0 2.76 2.24 5 5 5h4v-2H8c-1.66 0-3-1.34-3-3z"/> </SvgIcon> ); NotificationAirlineSeatLegroomReduced = pure(NotificationAirlineSeatLegroomReduced); NotificationAirlineSeatLegroomReduced.displayName = 'NotificationAirlineSeatLegroomReduced'; NotificationAirlineSeatLegroomReduced.muiName = 'SvgIcon'; export default NotificationAirlineSeatLegroomReduced;
src/routes/Home/components/CandidateList/CandidateItem.js
imrenagi/rojak-web-frontend
import React from 'react' import { Card, Icon, Image } from 'semantic-ui-react' export default class CandidateItem extends React.Component { render () { return ( <Card> <Image src={this.props.candidate.image_url} /> <Card.Content> <Card.Header> {this.props.candidate.name} </Card.Header> <Card.Meta> <span className='date'> Joined in 2015 </span> </Card.Meta> <Card.Description> {this.props.candidate.id} </Card.Description> </Card.Content> <Card.Content extra> <a> <Icon name='user' /> {this.props.candidate.statistic.total_news} Berita </a> </Card.Content> </Card> ) } }
src/js/pages/Home/index.js
trazyn/weweChat
import React, { Component } from 'react'; import { inject, observer } from 'mobx-react'; import clazz from 'classname'; import classes from './style.css'; import Loader from 'components/Loader'; import SearchBar from './SearchBar'; import Chats from './Chats'; import ChatContent from './ChatContent'; @inject(stores => ({ loading: stores.session.loading, showConversation: stores.chat.showConversation, toggleConversation: stores.chat.toggleConversation, showRedIcon: stores.settings.showRedIcon, newChat: () => stores.newchat.toggle(true), })) @observer export default class Home extends Component { componentDidMount() { this.props.toggleConversation(true); } render() { return ( <div className={classes.container}> <Loader fullscreen={true} show={this.props.loading} /> <div className={clazz(classes.inner, { [classes.hideConversation]: !this.props.showConversation })}> <div className={classes.left}> <SearchBar /> <Chats /> { this.props.showRedIcon && ( <div className={classes.addChat} onClick={() => this.props.newChat()}> <i className="icon-ion-android-add" /> </div> ) } </div> <div className={classes.right}> <ChatContent /> </div> </div> </div> ); } }
node_modules/react-router/es6/withRouter.js
fahidRM/aqua-couch-test
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; import invariant from 'invariant'; import React from 'react'; import hoistStatics from 'hoist-non-react-statics'; import { routerShape } from './PropTypes'; function getDisplayName(WrappedComponent) { return WrappedComponent.displayName || WrappedComponent.name || 'Component'; } export default function withRouter(WrappedComponent, options) { var withRef = options && options.withRef; var WithRouter = React.createClass({ displayName: 'WithRouter', contextTypes: { router: routerShape }, propTypes: { router: routerShape }, getWrappedInstance: function getWrappedInstance() { !withRef ? process.env.NODE_ENV !== 'production' ? invariant(false, 'To access the wrapped instance, you need to specify ' + '`{ withRef: true }` as the second argument of the withRouter() call.') : invariant(false) : void 0; return this.wrappedInstance; }, render: function render() { var _this = this; var router = this.props.router || this.context.router; var props = _extends({}, this.props, { router: router }); if (withRef) { props.ref = function (c) { _this.wrappedInstance = c; }; } return React.createElement(WrappedComponent, props); } }); WithRouter.displayName = 'withRouter(' + getDisplayName(WrappedComponent) + ')'; WithRouter.WrappedComponent = WrappedComponent; return hoistStatics(WithRouter, WrappedComponent); }
src/Pagination.js
thealjey/react-bootstrap
import React from 'react'; import classNames from 'classnames'; import BootstrapMixin from './BootstrapMixin'; import PaginationButton from './PaginationButton'; import CustomPropTypes from './utils/CustomPropTypes'; import SafeAnchor from './SafeAnchor'; const Pagination = React.createClass({ mixins: [BootstrapMixin], propTypes: { activePage: React.PropTypes.number, items: React.PropTypes.number, maxButtons: React.PropTypes.number, ellipsis: React.PropTypes.bool, first: React.PropTypes.bool, last: React.PropTypes.bool, prev: React.PropTypes.bool, next: React.PropTypes.bool, onSelect: React.PropTypes.func, /** * You can use a custom element for the buttons */ buttonComponentClass: CustomPropTypes.elementType }, getDefaultProps() { return { activePage: 1, items: 1, maxButtons: 0, first: false, last: false, prev: false, next: false, ellipsis: true, buttonComponentClass: SafeAnchor, bsClass: 'pagination' }; }, renderPageButtons() { let pageButtons = []; let startPage, endPage, hasHiddenPagesAfter; let { maxButtons, activePage, items, onSelect, ellipsis, buttonComponentClass } = this.props; if (maxButtons) { let hiddenPagesBefore = activePage - parseInt(maxButtons / 2, 10); startPage = hiddenPagesBefore > 1 ? hiddenPagesBefore : 1; hasHiddenPagesAfter = startPage + maxButtons <= items; if (!hasHiddenPagesAfter) { endPage = items; startPage = items - maxButtons + 1; if (startPage < 1) { startPage = 1; } } else { endPage = startPage + maxButtons - 1; } } else { startPage = 1; endPage = items; } for (let pagenumber = startPage; pagenumber <= endPage; pagenumber++) { pageButtons.push( <PaginationButton key={pagenumber} eventKey={pagenumber} active={pagenumber === activePage} onSelect={onSelect} buttonComponentClass={buttonComponentClass}> {pagenumber} </PaginationButton> ); } if (maxButtons && hasHiddenPagesAfter && ellipsis) { pageButtons.push( <PaginationButton key="ellipsis" disabled buttonComponentClass={buttonComponentClass}> <span aria-label="More">...</span> </PaginationButton> ); } return pageButtons; }, renderPrev() { if (!this.props.prev) { return null; } return ( <PaginationButton key="prev" eventKey={this.props.activePage - 1} disabled={this.props.activePage === 1} onSelect={this.props.onSelect} buttonComponentClass={this.props.buttonComponentClass}> <span aria-label="Previous">&lsaquo;</span> </PaginationButton> ); }, renderNext() { if (!this.props.next) { return null; } return ( <PaginationButton key="next" eventKey={this.props.activePage + 1} disabled={this.props.activePage >= this.props.items} onSelect={this.props.onSelect} buttonComponentClass={this.props.buttonComponentClass}> <span aria-label="Next">&rsaquo;</span> </PaginationButton> ); }, renderFirst() { if (!this.props.first) { return null; } return ( <PaginationButton key="first" eventKey={1} disabled={this.props.activePage === 1 } onSelect={this.props.onSelect} buttonComponentClass={this.props.buttonComponentClass}> <span aria-label="First">&laquo;</span> </PaginationButton> ); }, renderLast() { if (!this.props.last) { return null; } return ( <PaginationButton key="last" eventKey={this.props.items} disabled={this.props.activePage >= this.props.items} onSelect={this.props.onSelect} buttonComponentClass={this.props.buttonComponentClass}> <span aria-label="Last">&raquo;</span> </PaginationButton> ); }, render() { return ( <ul {...this.props} className={classNames(this.props.className, this.getBsClassSet())}> {this.renderFirst()} {this.renderPrev()} {this.renderPageButtons()} {this.renderNext()} {this.renderLast()} </ul> ); } }); export default Pagination;
src/components/Recipe.js
evelinalaroussi/evelinalaroussi.github.io
import React from 'react'; import Interactive from 'react-interactive'; import { Link } from 'react-router-dom'; //import { Code } from '../styles/style'; //import s from '../styles/home.style'; export default class Recipe extends React.Component { constructor(props) { super(props); } render() { return ( <div id="siteContainer" className="thissite"> <Link to="/head"><div><img className="logo-img" src="/logo.png"/></div></Link> <div className = "this-img"> <div className="head"><p>Haptic and e-commerce</p></div> <hr id="headLine"/> <Link to="/work"><div className="button-div"><button id="button" className="sliderB">Back to listing</button></div></Link> <Slider/> </div> <div className="this-text"> <div className="tech"> <h3>FRAMEWORKS</h3> <hr id="miniheadLine"/> <div><p>-Rss feed, makes it possible to subscribe for the website and get latest recipes</p> <p>-MySQL database, to save all recipes that users create</p> <p>-php, HTML, CSS and XML, to developer and design the website</p> </div> </div> <div className="desc"><h3>DESCRIPTION</h3> <hr id="miniheadLine"/> <div><p>This website is the first i ever have made in a course called "XML for publication". It is a recipe website where you can search for recipes, log in on your own page and create new recipes.</p></div> </div> </div> </div> ) } }; // Try out some settings live! var Carousel = require('nuka-carousel'); class Slider extends React.Component { mixins: [Carousel.ControllerMixin]; render() { return ( <Carousel dragging={true}> <img src="/work_images/recept.png"/> <img src="/work_images/recept2.png"/> </Carousel> ) } };
src/containers/App.js
vasanthk/redux-friendlist-demo
import React, { Component } from 'react'; import { combineReducers } from 'redux'; import { Provider } from 'react-redux'; import { createStore, renderDevTools } from '../store_enhancers/devTools'; import FriendListApp from './FriendListApp'; import * as reducers from '../reducers'; const reducer = combineReducers(reducers); const store = createStore(reducer); export default class App extends Component { render() { return ( <div> <Provider store={store}> {() => <FriendListApp /> } </Provider> {renderDevTools(store)} </div> ); } }
src/components/theme-giraffe/register.js
MoveOnOrg/mop-frontend
import React from 'react' import RegisterForm from '../../containers/register-form' export const Register = () => ( <div className='container'> <div className='row justify-content-center mt-3'> <div className='col-md-6'> <h1 className='text-align-center mt-5 mb-3'>Quick Sign Up</h1> <RegisterForm /> <p> <small> By creating an account you agree to receive email messages from MoveOn.org Civic Action and MoveOn.org Political Action. You may unsubscribe at any time. </small> </p> <p> <small> <strong>Privacy Policy (the basics):</strong> <br /> <strong> MoveOn will never sell your personal information to anyone ever. </strong>{' '} For petitions, letters to the editor, and surveys you’ve signed or completed, we treat your name, city, state, and comments as public information, which means anyone can access and view it. We will not make your street address publicly available, but we may transmit it to your state legislators, governor, members of Congress, or the President as part of a petition. MoveOn will send you updates on this and other important campaigns by email. If at any time you would like to unsubscribe from our email list, you may do so. For our complete privacy policy,{' '} <a href='http://petitions.moveon.org/privacy.html' target='_blank' rel='noopener noreferrer' > click here </a>. </small> </p> </div> </div> </div> ) Register.propTypes = {} export default Register
src/components/fileGrid.js
cephalization/filehub
// Import components import React from 'react'; import ItemGrid from './itemGrid'; import NotImplemented from './notImplemented'; import {Link} from 'react-router-dom'; import { Card, Image, Button, Container, Loader, Dimmer } from 'semantic-ui-react'; import FileModal from './fileModal'; // Import assets import white_image from '../images/white-image.png'; // Import sample images // This is only for demonstration purposes at the moment // and will be removed in a future commit import brace from '../images/sample_brace.jpg' import gearbox from '../images/sample_gearbox.jpg' import respirator from '../images/sample_respirator.jpg' import scissors from '../images/sample_scissors.jpg' import speculum from '../images/sample_speculum.jpg' class FileGrid extends React.Component { constructor() { super(); this.retrieveItems = this.retrieveItems.bind(this); this.state = { items: [], loading: true } } componentDidMount() { // Wrap in promise or async/await const files = this.retrieveItems(); this.setState({ items: files, loading: false }); } /** * Retrieve JSON information about files availble for download * from the server. The server will run its own functions to * create this JSON. */ retrieveItems = () => ( // This is only for demonstration purposes at the moment // and will be removed in a future commit [ { name: 'brace.stl', size: '400kb', thumb_URI: brace, file_URI: null, variables:[ { name: 'Length', description: 'The length of the thingy', unit: 'mm', value: 1 }, { name: 'Height', description: 'The height of the thingy', unit: 'mm', value: 10 }, { name: 'Wrist extension', description: 'Brace extends to the wrist', value: true, type: 'checkbox' } ] }, { name: 'gearbox.stl', size: '123kb', thumb_URI: gearbox, file_URI: null }, { name: 'respirator.stl', size: '934kb', thumb_URI: respirator, file_URI: null }, { name: 'scissors.stl', size: '156kb', thumb_URI: scissors, file_URI: null }, { name: 'speculum.stl', size: '523kb', thumb_URI: speculum, file_URI: null } ] ) /** * JSX template for translating an item into a card * @param {*} item containing information for a file to be * displayed */ fileTemplate = (item) => ( <Card> <Image src={item.thumb_URI || white_image} /> <Card.Content> <Card.Header>{item.name}</Card.Header> <Card.Meta>{item.size}</Card.Meta> <Card.Description> {item.Description || 'No Description'} </Card.Description> </Card.Content> <Card.Content extra> <div className='ui two buttons'> <FileModal trigger={ <Button basic as={Link} to='' color='blue'>View Info</Button> } item={item} /> {NotImplemented( <Button basic as={Link} to='' color='green'>Download</Button> )} </div> </Card.Content> </Card> ) render() { /* An instance of an item grid configured in the right */ /* way. Or, if there are no files available from the */ /* server, an image declaring that there are no files */ /* to be downloaded */ return ( <Container style={{ paddingTop: '7em' }}> <Dimmer active={this.state.loading}> <Loader indeterminate>Finding files...</Loader> </Dimmer> <ItemGrid items={this.state.items} template={this.fileTemplate} /> </Container> ); } } export default FileGrid;
packages/react-scripts/fixtures/kitchensink/src/features/env/FileEnvVariables.js
TryKickoff/create-kickoff-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 from 'react'; export default () => ( <span> <span id="feature-file-env-original-1"> {process.env.REACT_APP_ORIGINAL_1} </span> <span id="feature-file-env-original-2"> {process.env.REACT_APP_ORIGINAL_2} </span> <span id="feature-file-env"> {process.env.REACT_APP_DEVELOPMENT} {process.env.REACT_APP_PRODUCTION} </span> <span id="feature-file-env-x">{process.env.REACT_APP_X}</span> </span> );
react/src/index.js
inversoft/passport-bluemix-example
import React from 'react'; import ReactDOM from 'react-dom'; import { browserHistory, IndexRoute, Router, Route } from 'react-router'; import App from './App'; import auth from './auth'; import Login from './components/Login'; import Register from './components/Register'; import Logout from './components/Logout'; import ToDoListContainer from './components/containers/ToDoListContainer'; import './assets/index.css'; function requireAuth(nextState, replace) { if (!auth.loggedIn()) { replace({ pathname: '/login', state: { nextPathname: nextState.location.pathname } }) } } ReactDOM.render( <Router history={browserHistory}> <Route path="/" component={App} > <IndexRoute component={ToDoListContainer} onEnter={requireAuth} /> <Route path="login" component={Login} /> <Route path="logout" component={Logout} /> <Route path="register" component={Register} /> </Route> </Router>, document.getElementById('root') );
src/svg-icons/maps/pin-drop.js
ArcanisCz/material-ui
import React from 'react'; import pure from 'recompose/pure'; import SvgIcon from '../../SvgIcon'; let MapsPinDrop = (props) => ( <SvgIcon {...props}> <path d="M18 8c0-3.31-2.69-6-6-6S6 4.69 6 8c0 4.5 6 11 6 11s6-6.5 6-11zm-8 0c0-1.1.9-2 2-2s2 .9 2 2-.89 2-2 2c-1.1 0-2-.9-2-2zM5 20v2h14v-2H5z"/> </SvgIcon> ); MapsPinDrop = pure(MapsPinDrop); MapsPinDrop.displayName = 'MapsPinDrop'; MapsPinDrop.muiName = 'SvgIcon'; export default MapsPinDrop;
blueocean-material-icons/src/js/components/svg-icons/content/undo.js
kzantow/blueocean-plugin
import React from 'react'; import SvgIcon from '../../SvgIcon'; const ContentUndo = (props) => ( <SvgIcon {...props}> <path d="M12.5 8c-2.65 0-5.05.99-6.9 2.6L2 7v9h9l-3.62-3.62c1.39-1.16 3.16-1.88 5.12-1.88 3.54 0 6.55 2.31 7.6 5.5l2.37-.78C21.08 11.03 17.15 8 12.5 8z"/> </SvgIcon> ); ContentUndo.displayName = 'ContentUndo'; ContentUndo.muiName = 'SvgIcon'; export default ContentUndo;
src/components/layout.js
xavierdutreilh/xavier.dutreilh.com
import { StaticQuery, graphql } from 'gatsby' import PropTypes from 'prop-types' import React from 'react' import Helmet from 'react-helmet' import 'normalize.css' import Content from './content' import Wrapper from './wrapper' import './layout.scss' const Layout = ({ children }) => ( <StaticQuery query={graphql` query SiteTitleQuery { site { siteMetadata { title } } } `} render={data => ( <Wrapper> <Helmet title={data.site.siteMetadata.title}> <html lang="en" /> </Helmet> <Content>{children}</Content> </Wrapper> )} /> ) Layout.propTypes = { children: PropTypes.node.isRequired, } export default Layout
src/js/components/Page/stories/CustomThemed/LeftColumn.js
grommet/grommet
import React from 'react'; import { Page, Header, Heading, Paragraph, Grid, Card, PageContent, Grommet, } from 'grommet'; const customTheme = { page: { customKind: { alignSelf: 'start', width: { min: '200px', max: '500px', }, small: { pad: 'medium', margin: { vertical: 'small', horizontal: 'small' }, }, medium: { pad: 'medium', margin: { vertical: 'small', horizontal: 'small' }, }, large: { pad: 'medium', margin: { vertical: 'small', horizontal: 'small' }, }, }, }, }; export const LeftColumn = () => ( <Grommet theme={customTheme}> <Page kind="customKind"> <PageContent> <Header> <Heading>Custom Kind</Heading> </Header> </PageContent> <PageContent background={{ fill: 'horizontal', color: 'pink' }}> Background goes all the way across Page width regardless of Page kind (wide, narrow, full, or custom). </PageContent> <PageContent> <Paragraph> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer commodo gravida tincidunt. Nunc fringilla blandit tortor, id accumsan nisi dictum quis. Aenean porttitor at mi id semper. Donec mattis bibendum leo, interdum ullamcorper lectus ultrices vel. Fusce nec enim faucibus nunc porta egestas. Fusce dapibus lobortis tincidunt. </Paragraph> </PageContent> <PageContent background="orange"> <Paragraph> Background width is restricted by Page kind (wide, narrow, or full). </Paragraph> <Grid rows="small" columns={{ count: 'fit', size: 'small' }} gap="small" > <Card background="white" pad="large"> Card </Card> <Card background="white" pad="large"> Card </Card> </Grid> </PageContent> <PageContent> <Paragraph> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer commodo gravida tincidunt. Nunc fringilla blandit tortor, id accumsan nisi dictum quis. Aenean porttitor at mi id semper. Donec mattis bibendum leo, interdum ullamcorper lectus ultrices vel. Fusce nec enim faucibus nunc porta egestas. Fusce dapibus lobortis tincidunt. </Paragraph> </PageContent> </Page> </Grommet> ); LeftColumn.storyName = 'Left column'; export default { title: 'Layout/Page/Custom Themed/Left column', };
src/containers/user.js
suckak/vox
import React, { Component } from 'react'; import { bindActionCreators } from 'redux' import { connect } from 'react-redux' import { getUser } from "../actions/index"; import {getAssetsURL} from "../utils/utils"; class User extends Component { componentDidMount(){ this.props.getUser(); } renderUnseen(unseen){ if(unseen.length>0){ return <span className="unseen">{unseen.length}</span>; } } render() { const user = this.props.user; const unseen = this.props.unseen; if(user&&unseen!=null){ return ( <div className="user"> <div className="menu__img"> <img className="user__avatar" src={getAssetsURL(user.avatarUrl)} alt=""/> </div> <p className="menu__text">{user.name.toUpperCase()}</p> {this.renderUnseen(unseen)} </div> ); }else{ return ( <div></div> ); } } } function mapStateToProps(state){ return { user : state.appData.user, unseen : state.appData.unseen }; } function mapDispatchToProps(dispatch){ return { getUser : bindActionCreators(getUser,dispatch) }; } export default connect(mapStateToProps,mapDispatchToProps)(User);
modules/Route.js
pjuke/react-router
import React from 'react' import warning from 'warning' import invariant from 'invariant' import { createRouteFromReactElement } from './RouteUtils' import { component, components } from './PropTypes' const { string, bool, func } = React.PropTypes /** * A <Route> is used to declare which components are rendered to the page when * the URL matches a given pattern. * * Routes are arranged in a nested tree structure. When a new URL is requested, * the tree is searched depth-first to find a route whose path matches the URL. * When one is found, all routes in the tree that lead to it are considered * "active" and their components are rendered into the DOM, nested in the same * order as they are in the tree. */ const Route = React.createClass({ statics: { createRouteFromReactElement(element) { const route = createRouteFromReactElement(element) if (route.handler) { warning( false, '<Route handler> is deprecated, use <Route component> instead' ) route.component = route.handler delete route.handler } return route } }, propTypes: { path: string, ignoreScrollBehavior: bool, handler: component, // deprecated component, components, getComponents: func }, render() { invariant( false, '<Route> elements are for router configuration only and should not be rendered' ) } }) export default Route
shared/components/Admin/Sortable/Sortable.js
KCPSoftware/KCPS-React-Starterkit
import React, { Component } from 'react'; import Helmet from 'react-helmet'; import { connect } from 'react-redux'; import {SortableContainer, SortableElement,arrayMove} from 'react-sortable-hoc'; import {getQuestionGroups,setQuestionSort} from '../../../actions/sortQuestionActions'; import {Loading} from '../../SubComponents/Loading'; const SortableItem = SortableElement(({value,text}) => <div className="sortableItem">Id {value} - {text}</div>); const SortableList = SortableContainer(({children, ...props}) => <div className="SortableList" {...props}>{children}</div>); @connect(store => ({ isLoading: store.questionSort.isLoading, questionGroups: store.questionSort.questionGroups, })) class Sortable extends Component { constructor(props) { super(props); this.state = { questionGroups: [] } } handleSort({oldIndex, newIndex, collection}) { let {questionGroups} = this.state; questionGroups[collection] = arrayMove(questionGroups[collection], oldIndex, newIndex) this.setState({questionGroups}); } componentWillMount() { this.props.dispatch(getQuestionGroups("2017")); } save(){ this.props.dispatch(setQuestionSort(this.state.questionGroups,"2017")); } componentWillReceiveProps(props){ this.setState({ questionGroups:props.questionGroups }) } render() { if(this.props.isLoading){ return <div>'...Loading'</div> } else { return( <div className="sortableContainer"> <SortableList onSortEnd={this.handleSort.bind(this)}> {this.state.questionGroups.map((sublist, collectionIndex,index) => ( <div className="itemContainer"> <div className="itemHeader">Group {collectionIndex+1}</div> <ul> {sublist.map((question, subIndex) => ( <SortableItem key={question.id} text={question.text} value={question.id} index={subIndex} collection={collectionIndex} /> ))} </ul> </div> ))} </SortableList> <div className="btn-save" onClick={this.save.bind(this)}>Save</div> </div> ) } } } export default Sortable;
react-app/src/components/CareNeedForm.js
floodfx/gma-village
import React, { Component } from 'react'; import { Field, reduxForm } from 'redux-form'; import { Neighborhood } from 'gma-village-data-model'; import { required, requiredArray } from './forms/Validate'; import FontAwesome from 'react-fontawesome'; import MultiCheckbox from './forms/MultiCheckbox'; import KidsCheckbox from './forms/KidsCheckbox'; import MultiRadio from './forms/MultiRadio'; import DateTimeStartEnd from './forms/DateTimeStartEnd'; import ElsewhereLearnMore from './ElsewhereLearnMore'; const otherFieldMap = { neighborhood: "other_neighborhood" } const DATE_FORMAT_RFC3339 = 'YYYY-MM-DDTHH:mm:ssZ' class CareNeedForm extends Component { constructor(props) { super(props); const { initialValues } = props; var children = []; var other_neighborhood = ''; if(initialValues) { children = initialValues.children || []; other_neighborhood = initialValues.other_neighborhood || ''; } this.state = { children, other_neighborhood } } careStartTimeValueChange = (value) => { var rfc3339Start = value.format(DATE_FORMAT_RFC3339); this.props.change("start_time", rfc3339Start); } careEndTimeValueChange = (value) => { var rfc3339End = value.format(DATE_FORMAT_RFC3339); this.props.change("end_time", rfc3339End); } onOtherValueChange = (name, value) => { const otherField = otherFieldMap[name]; this.props.change(otherField, value); } render() { const { handleSubmit, pristine, invalid, submitting, heading, description } = this.props const { children, other_neighborhood } = this.state; return ( <div> <h2 className="lh-title fw2 f1">{heading}</h2> {description && <p className="lh-copy fw3 f3">{description}</p> } <h3 className="lh-title fw2 f2">Delivery Schedule</h3> <p className="lh-copy fw3 f3"> Text messages are sent between 9am-7pm PT. Messages outside that window are delivered in the next window. </p> <form onSubmit={handleSubmit} encType="multipart/form-data"> <div className="mt4"> <Field heading="I need child care for:" name="children" component={KidsCheckbox} options={children.slice(0)} validate={[requiredArray]} /> </div> <div className="mt4"> <Field heading="My most immediate need for child care is:" name="careDateStartEnd" component={DateTimeStartEnd} placeholder="Date of Care" onStartDateTimeValueChange={this.careStartTimeValueChange} onEndDateTimeValueChange={this.careEndTimeValueChange} /> </div> <div className="mt4"> <Field heading="In the following neighborhood:" name="neighborhood" options={Neighborhood.enumValues.map((val) => { return { id: val.name, label: val.text } })} component={MultiRadio} otherTextValue={other_neighborhood} onOtherValueChange={this.onOtherValueChange} /> </div> <div className="mt4"> <Field heading="I would like the care provided at:" name="care_locations" options={[ {id: "PROVIDERS_HOME", label: "Provider's Home"}, {id: "ELSEWHERE", label: "Elsewhere"}, ]} component={MultiCheckbox} validate={[required]}/> <ElsewhereLearnMore /> </div> <Field name="other_neighborhood" component="input" type="hidden" /> <div className="mt4"> <button className="btn gma-orange-bg" type="submit" disabled={pristine || submitting || invalid}> {this.props.saving && <FontAwesome name='spinner' spin={true} className="mr1"/> } Send </button> </div> </form> </div> ) } } const validateOthers = values => { const errors = {} if (!values.neighborhood && !values[otherFieldMap]) { errors.neighborhood = 'Required' } else if (values.neighborhood === Neighborhood.OTHER.name && !values.other_neighborhood) { errors.neighborhood = "Please provide 'Other' text" } else if (values.neighborhood === Neighborhood.OTHER.name && values.other_neighborhood && values.other_neighborhood.length < 2) { errors.neighborhood = "'Other' text be at least 2 characters" } if (!values.start_time || !values.end_time) { errors.careDateStartEnd = 'Start and End Time Required' } else if (values.start_time && values.end_time && values.start_time >= values.end_time) { errors.careDateStartEnd = 'Start Time must be before End Time' } return errors } CareNeedForm = reduxForm({ form: 'careRequestForm', // a unique identifier for this form validate: validateOthers })(CareNeedForm) export default CareNeedForm;