path
stringlengths 5
195
| repo_name
stringlengths 5
79
| content
stringlengths 25
1.01M
|
---|---|---|
src/components/Status.js | greg5green/isrobhomeyet | import React from 'react';
import {isHereNow} from '../services/status';
class Status extends React.Component {
constructor(props) {
super(props);
this.state = this.getRobStatusObject();
}
componentDidMount() {
this.updateInterval = setInterval(() => this.updateStatusText(), 1000);
}
componentWillUnmount() {
clearInterval(this.updateInterval);
}
getRobStatusObject() {
return {
robStatus: isHereNow() ? 'Yes' : 'No'
};
}
render() {
return <h1>{this.state.robStatus}</h1>;
}
updateStatusText() {
this.setState(this.getRobStatusObject());
}
}
export default Status;
|
src/app/index.js | ucokfm/admin-lte-react | import { AppContainer } from 'react-hot-loader';
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
const rootEl = document.getElementById('root');
ReactDOM.render(
<AppContainer>
<App />
</AppContainer>,
rootEl
);
if (module.hot) {
module.hot.accept('./App', () => {
// If you use Webpack 2 in ES modules mode, you can
// use <App /> here rather than require() a <NextApp />.
// eslint-disable-next-line global-require
const NextApp = require('./App').default;
ReactDOM.render(
<AppContainer>
<NextApp />
</AppContainer>,
rootEl
);
});
}
|
src/client/devTools.js | cle1994/personal-website | /* ==========================================================================
* ./src/server/devtools.js
*
* DevTools Container
* ========================================================================== */
import React from 'react';
import { createDevTools } from 'redux-devtools';
import LogMonitor from 'redux-devtools-log-monitor';
export default createDevTools(
<LogMonitor />
);
|
src/svg-icons/device/signal-cellular-connected-no-internet-3-bar.js | skarnecki/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let DeviceSignalCellularConnectedNoInternet3Bar = (props) => (
<SvgIcon {...props}>
<path fillOpacity=".3" d="M22 8V2L2 22h16V8z"/><path d="M17 22V7L2 22h15zm3-12v8h2v-8h-2zm0 12h2v-2h-2v2z"/>
</SvgIcon>
);
DeviceSignalCellularConnectedNoInternet3Bar = pure(DeviceSignalCellularConnectedNoInternet3Bar);
DeviceSignalCellularConnectedNoInternet3Bar.displayName = 'DeviceSignalCellularConnectedNoInternet3Bar';
export default DeviceSignalCellularConnectedNoInternet3Bar;
|
geonode/contrib/monitoring/frontend/src/components/organisms/error-detail/index.js | kartoza/geonode | import React from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { Tabs, Tab } from 'material-ui/Tabs';
import HoverPaper from '../../atoms/hover-paper';
import styles from './styles';
import actions from './actions';
const mapStateToProps = (state) => ({
errorDetails: state.errorDetails.response,
from: state.interval.from,
to: state.interval.to,
});
@connect(mapStateToProps, actions)
class ErrorDetail extends React.Component {
static propTypes = {
errorDetails: PropTypes.object,
errorId: PropTypes.number,
get: PropTypes.func.isRequired,
}
componentWillMount() {
this.props.get(this.props.errorId);
}
render() {
const errorDetails = this.props.errorDetails;
const result = {
client: {},
};
if (errorDetails) {
const date = new Date(errorDetails.created);
const year = date.getFullYear();
const month = `0${date.getMonth() + 1}`.slice(-2);
const day = `0${date.getDate()}`.slice(-2);
const hours = `0${date.getHours()}`.slice(-2);
const minutes = `0${date.getMinutes()}`.slice(-2);
const seconds = `0${date.getSeconds()}`.slice(-2);
const formatedDate = `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
result.date = `Date: ${formatedDate}`;
result.service = `Service: ${errorDetails.service.name}`;
result.errorType = `Type: ${errorDetails.error_type}`;
result.errorData = errorDetails.error_data;
if (errorDetails.request) {
const request = errorDetails.request.request;
const url = `${request.path}`;
result.url = <span>URL: <a href={url}>{url}</a></span>;
const response = errorDetails.request.response;
result.errorCode = `Status code: ${response.status}`;
if (errorDetails.request.client) {
const client = errorDetails.request.client;
result.client.ip = `IP: ${client.ip}`;
result.client.userAgent = `Browser: ${client.user_agent}`;
result.client.userAgentFamily = `Browser Family: ${client.user_agent_family}`;
}
}
}
return (
<HoverPaper style={styles.content}>
<div style={styles.header}>
<h3 style={styles.title}>Error id: {this.props.errorId}</h3>
</div>
<Tabs>
<Tab label="Metadata">
<div style={styles.tab}>
<div>{result.date}</div>
<div>{result.service}</div>
<div>{result.errorType}</div>
<div>{result.errorCode}</div>
<div>{result.url}</div>
</div>
</Tab>
<Tab label="Client">
<div style={styles.tab}>
<div>{result.client.ip}</div>
<div>{result.client.userAgent}</div>
<div>{result.client.userAgentFamily}</div>
</div>
</Tab>
</Tabs>
<h3>Log</h3>
<pre style={styles.log}>{result.errorData}</pre>
</HoverPaper>
);
}
}
export default ErrorDetail;
|
src/apps/home/root.component.js | raquel/cuddly-tribble | import React from 'react';
import Technology from './technology.component.js';
import Walkthroughs from './walkthroughs.component.js';
import {getBorder, showFrameworkObservable} from '../common/colored-border';
export default class HomeRoot extends React.Component {
constructor() {
super();
this.state = {
frameworkInspector: false,
};
}
componentWillMount() {
this.subscription = showFrameworkObservable.subscribe(newValue => this.setState({frameworkInspector: newValue}));
}
render() {
return (
<div style={this.state.frameworkInspector ? {border: getBorder('react')} : {}}>
{this.state.frameworkInspector &&
<div>(built with React)</div>
}
<div className="container">
<div className="row">
<h4 className="light">
Introduction
</h4>
<p className="caption">
Single-spa is a javascript libary that allows for many small applications to coexist in one single page application.
This website is a demo application that shows off what single-spa can do.
For more information about single-spa, go to the <a href="https://github.com/CanopyTax/single-spa" target="_blank">single-spa Github page</a>.
Additionally, this website's code can be found at the <a href="https://github.com/CanopyTax/single-spa-examples" target="_blank">single-spa-examples Github</a>.
While you're here, check out the following features:
</p>
<Walkthroughs />
</div>
<div className="row">
<h4 className="light">
Framework examples
</h4>
<p className="caption">
Single-spa allows for multiple frameworks to coexist in the same single page application.
</p>
<div className="row">
<Technology
imgSrc="https://facebook.github.io/react/img/logo.svg"
imgBackgroundColor="#222222"
cardTitle="React"
href="/#/react"
explanation={`Yep we've got a React example. We actually just borrowed it from the react-router examples, to show how easy it is to migrate an existing app into single-spa`}
/>
<Technology
imgSrc="https://angularjs.org/img/ng-logo.png"
cardTitle="Angular 1"
href="/#/angular1"
explanation={`Angular 1 has some quirks, but works just fine when you use the single-spa-angular1 npm library to help you set up your app`}
/>
<Technology
imgSrc="/images/angular.svg"
imgBackgroundColor="#1976D2"
cardTitle="Angular 2"
href="/#/angular2"
explanation={`Angular 2 is compatible with single-spa, check out a simple 'Hello World' in the example.`}
/>
<Technology
imgSrc="https://vuejs.org/images/logo.png"
cardTitle="Vue.js"
href="/#/vue"
explanation={`Vue.js is compatible with single-spa. Easily get started with the single-spa-vue plugin.`}
/>
<Technology
imgSrc="/images/svelte.jpg"
cardTitle="Svelte"
href="/#/svelte"
explanation={`Svelte is compatible with single-spa. Easily get started with the single-spa-svelte plugin.`}
/>
<Technology
imgSrc="https://camo.githubusercontent.com/31415a8c001234dbf4875c2c5a44b646fb9338b4/68747470733a2f2f63646e2e7261776769742e636f6d2f646576656c6f7069742f62343431366435633932623734336462616563316536386263346332376364612f7261772f333233356463353038663765623833346562663438343138616561323132613035646631336462312f7072656163742d6c6f676f2d7472616e732e737667"
cardTitle="Preact"
href="/#/preact"
explanation={`Preact is compatible with single-spa. Easily get started with the single-spa-preact plugin.`}
/>
<Technology
imgSrc="http://xitrus.es/blog/imgs/vnll.jpg"
cardTitle="Vanilla"
href="/#/vanilla"
explanation={`
If you want to write single-spa applications in vanilla javascript, that's fine too.
`}
/>
<Technology
imgSrc="/images/inferno-logo.png"
cardTitle="Inferno"
href="/#/inferno"
explanation={`
Inferno is compatible with single-spa. Easily get started with the single-spa-inferno plugin.
`}
/>
</div>
</div>
<div className="row">
<h4 className="light">
Build system examples
</h4>
<p className="caption">
Each application chooses it's own build system, which will fit into the root single-spa application at runtime.
</p>
<div className="row">
<Technology
imgSrc="https://avatars0.githubusercontent.com/webpack?&s=256"
cardTitle="Webpack"
href="/#/react"
explanation={`The React example is built with Webpack, and even uses require.ensure for extra lazy loading.`}
/>
<Technology
imgSrc="https://avatars3.githubusercontent.com/u/3802108?v=3&s=200"
cardTitle="SystemJS"
href="/#/angular1"
explanation={`The navbar app, home app, and Angular 1 app are all built with JSPM / SystemJS.`}
/>
<Technology
imgSrc="http://4.bp.blogspot.com/-rI6g4ZgVqBA/Uv8fPnl9TLI/AAAAAAAAMZU/tbylo5ngisg/s1600/iFrame+Generator.jpg"
cardTitle="Iframe"
href="/#/vanilla"
explanation={`
Putting things in iframes is the wrong thing to do many times, but there are valid use cases for it.
If you put a single-spa application into an iframe, you get a whole new DOM and global namespace for variables.
But the cons include degraded performance and trickier inter-app communication.
`}
/>
</div>
</div>
</div>
</div>
);
}
componentWillUnmount() {
this.subscription.dispose();
}
}
|
app/components/transactions/AmountInput.js | jpsierens/budget | // @flow
import React from 'react';
type Props = {
value: String,
onInputChange: () => void
}
const AmountInput = ({ onInputChange, value } : Props) => {
let input;
return (
<div>
<label>Amount</label>
<input
type="text"
ref={(e) => { input = e; }}
value={value}
onChange={() =>
onInputChange({ amount: input.value })
}/>
</div>
);
};
export default AmountInput;
|
src/components/ToolbarCallButton/ToolbarCallButton.js | dialogs/dialog-web-components | /*
* Copyright 2019 dialog LLC <[email protected]>
* @flow
*/
import React from 'react';
import classNames from 'classnames';
import Icon from '../Icon/Icon';
import styles from './ToolbarCallButton.css';
export type Props = {
className?: string,
disabled: boolean,
onClick: (event: SyntheticMouseEvent<>) => mixed,
};
function ToolbarCallButton(props: Props) {
const className = classNames(
styles.container,
{
[styles.disabled]: props.disabled,
},
props.className,
);
if (props.disabled) {
return (
<div className={className} id="toolbar_call_button">
<Icon glyph="phone_outline" className={styles.icon} size={28} />
</div>
);
}
return (
<div className={className} id="toolbar_call_button" onClick={props.onClick}>
<Icon glyph="phone_outline" className={styles.icon} size={28} />
</div>
);
}
export default ToolbarCallButton;
|
src/App.js | serban-petrescu/serban-petrescu.github.io | import React, { Component } from 'react';
import data from './data';
import Hero from './hero/Hero';
import Introduction from './intro/Introduction';
import Footer from './footer/Footer';
import Highlights from './intro/Highlights';
import ExperienceList from './experience/ExperienceList';
import GalleryModal from './common/GalleryModal';
import ProjectList from './experience/ProjectsList';
export default class App extends Component {
constructor(props) {
super(props);
this.state = data;
}
render() {
const state = this.state;
const onClickGallery = ({ name, images }) => modal.open(name, images);
let modal;
return (
<div>
<Hero name={state.name} title={state.role} avatar={state.avatar} linkedin={state.accounts.linkedin} cv={state.cv} />
<Introduction cover={state.cover} summary={state.summary} social={data.accounts} />
<Highlights {...state.highlights} onClickGallery={onClickGallery} />
<div id='work' />
<ExperienceList title='Work History' items={state.experience.work} />
<div id='certifications' />
<ExperienceList title='Certifications' items={state.experience.certifications} />
<div id='academic' />
<ExperienceList title='Education' items={state.experience.academic} />
<div id='projects' />
<ProjectList projects={data.projects} onClickGallery={onClickGallery} />
<GalleryModal ref={ref => modal = ref} />
<div className='section-divider'/>
<Footer {...state.site} />
</div>
);
}
}
|
client/containers/Home/HomeContainer.js | Moises404/rapbot | import React from 'react'
import PostApp from '../../components/PostApp/PostApp'
class HomeContainer extends React.Component {
static displayName = 'HomeContainer'
render() {
return (
<div className="Home">
<PostApp {...this.props}/>
</div>
)
}
}
export default HomeContainer
|
src/demos/custom-layers/4-custom-attribute/root.js | uber-common/vis-academy | import React from 'react';
import {render} from 'react-dom';
import App from './src/app';
const element = document.getElementById('root');
render(<App />, element);
if (module.hot) {
module.hot.accept('./src/app', () => {
const Next = require('./src/app').default;
render(<Next />, element);
});
}
|
webapp/src/lib/form/FormFieldContainer.js | cpollet/itinerants | import React from 'react';
class FormFieldContainer extends React.Component {
onChange(event) {
if (typeof event.target.selectedOptions !== 'undefined') {
let value = [];
for (let i = 0; i < event.target.selectedOptions.length; i++) {
value.push(event.target.selectedOptions[i].value);
}
this.context.update(this.props.name, value);
} else {
this.context.update(this.props.name, event.target.value);
}
}
componentWillMount() {
this.context.update(this.props.name, this.context.fieldValues[this.props.name]);
}
render() {
return React.cloneElement(this.props.children, {
onChange: this.onChange.bind(this),
value: this.context.fieldValues[this.props.name]
});
}
}
FormFieldContainer.propTypes = {
children: React.PropTypes.element.isRequired,
/**
* The name of the wrapped field.
*/
name: React.PropTypes.string.isRequired
};
FormFieldContainer.contextTypes = {
/**
* Method to use when the wrapped field is updated. This method expects to have as 1st parameter the field's name
* and as 2nd parameter the field's value.
*/
update: React.PropTypes.func.isRequired,
fieldValues: React.PropTypes.object
};
export default FormFieldContainer;
|
src/components/main.component.js | MichelLosier/cardspace | import React from 'react';
import { Route, Link } from 'react-router-dom';
import RoomLobby from './rooms/room-lobby.component';
import UserService from '../services/user.service';
import UserEntry from './user/user-entry.component';
import Room from './rooms/room.component';
import '../main.css';
const User$ = new UserService();
class Main extends React.Component {
constructor(){
super();
this.state = {
userLoggedIn: true,
user: {
id: undefined,
alias: undefined
}
}
this.setLocalUser = this.setLocalUser.bind(this);
}
componentDidMount(){
this.checkLocalUser();
}
checkLocalUser(){
const id = window.localStorage.getItem('uid');
if (id) {
User$.getUser(id, (user) => {
if (!user.id) {
console.log('user in local storage not found on server.. create new user');
this.setState({userLoggedIn: false});
} else {
console.log('existing user found in local storage.. setting.')
this.setLocalUser(user);
}
});
} else {
this.setState({userLoggedIn: false});
}
}
setLocalUser(user) {
const id = window.localStorage.getItem('uid');
if (id) {
this.setState({
userLoggedIn: true,
user: user
});
}
}
//Views
_UserEntry(props){
return(
<UserEntry
setLocalUser={this.setLocalUser}
/>
);
}
_RoomLobby(props){
return(
<RoomLobby
{...props}
/>
);
}
_Room(props){
return(
<Room
{...props}
/>
)
}
render(){
const state = this.state;
return(
<div>
<div>
<div className="main-header layout-container">
<div>
<h1><a href="/">cardspace</a></h1>
</div>
<div>
<p>UserId: {state.user.id}</p>
<p>Logged In: {state.user.alias}</p>
</div>
</div>
<div className="main-body layout-container">
{!state.userLoggedIn &&
this._UserEntry()
}
<Route
exact path="/"
render={(props) => this._RoomLobby(props)}
/>
<Route
path="/room/:roomId"
render={(props) => this._Room(props)}
/>
</div>
</div>
</div>
);
}
}
export default Main; |
mxcube3/ui/components/SampleView/MotorInput.js | amilan/mxcube3 | import React from 'react';
import cx from 'classnames';
import { Button } from 'react-bootstrap';
import PopInput from '../PopInput/PopInput';
import './motor.css';
export default class MotorInput extends React.Component {
constructor(props) {
super(props);
this.handleKey = this.handleKey.bind(this);
this.stopMotor = this.stopMotor.bind(this, props.motorName);
this.stepIncrement = this.stepChange.bind(this, props.motorName, 1);
this.stepDecrement = this.stepChange.bind(this, props.motorName, -1);
}
componentWillReceiveProps(nextProps) {
if (nextProps.value !== this.props.value) {
this.refs.motorValue.value = nextProps.value.toFixed(this.props.decimalPoints);
this.refs.motorValue.defaultValue = nextProps.value.toFixed(this.props.decimalPoints);
}
}
handleKey(e) {
e.preventDefault();
e.stopPropagation();
if ([13, 38, 40].includes(e.keyCode) && this.props.state === 2) {
this.props.save(e.target.name, e.target.valueAsNumber);
this.refs.motorValue.value = this.props.value.toFixed(this.props.decimalPoints);
} else if (this.props.state === 4) {
this.refs.motorValue.value = this.props.value.toFixed(this.props.decimalPoints);
}
}
stepChange(name, operator) {
const { value, step } = this.props;
const newValue = value + step * operator;
this.refs.motorValue.value = this.props.value.toFixed(this.props.decimalPoints);
this.refs.motorValue.defaultValue = newValue;
this.props.save(name, newValue);
}
stopMotor(name) {
this.props.stop(name);
}
render() {
const { value, motorName, step, suffix, decimalPoints } = this.props;
const valueCropped = value.toFixed(decimalPoints);
let inputCSS = cx('form-control rw-input', {
'input-bg-moving': this.props.state === 4 || this.props.state === 3,
'input-bg-ready': this.props.state === 2,
'input-bg-fault': this.props.state <= 1,
'input-bg-onlimit': this.props.state === 5
});
let data = { state: 'IMMEDIATE', value: step };
return (
<div className="motor-input-container">
<p className="motor-name">{this.props.label}</p>
<form className="inline form-inline form-group" onSubmit={this.handleKey} noValidate>
<div className="rw-widget rw-numberpicker">
<span className="rw-select">
<button
type="button"
className="rw-btn"
disabled={this.props.state !== 2}
onClick={this.stepIncrement}
>
<i aria-hidden="true" className="rw-i rw-i-caret-up"></i>
</button>
<button
type="button"
className="rw-btn"
disabled={this.props.state !== 2}
onClick={this.stepDecrement}
>
<i aria-hidden="true" className="rw-i rw-i-caret-down"></i>
</button>
</span>
<input
ref="motorValue"
className={inputCSS}
onKeyUp={this.handleKey}
type="number"
step={step}
defaultValue={valueCropped}
name={motorName}
disabled={this.props.state !== 2}
/>
</div>
<span>
{this.props.saveStep ?
<PopInput
className="step-size"
ref={motorName} name="Step size" pkey={`${motorName.toLowerCase()}Step`}
data={data} onSave={this.props.saveStep} suffix={suffix}
/>
: null
}
</span>
<span>
{this.props.state === 4 ?
<Button
className="btn-xs motor-abort"
bsStyle="danger"
disabled={this.props.state !== 4}
onClick={this.stopMotor}
>
<i className="glyphicon glyphicon-remove" />
</Button>
: null
}
</span>
</form>
</div>
);
}
}
|
node_modules/bs-recipes/recipes/webpack.react-transform-hmr/app/js/main.js | choy1379/MoonEDM | import React from 'react';
import { render } from 'react-dom';
// It's important to not define HelloWorld component right in this file
// because in that case it will do full page reload on change
import HelloWorld from './HelloWorld.jsx';
render(<HelloWorld />, document.getElementById('react-root'));
|
src/svg-icons/navigation/more-vert.js | igorbt/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let NavigationMoreVert = (props) => (
<SvgIcon {...props}>
<path d="M12 8c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"/>
</SvgIcon>
);
NavigationMoreVert = pure(NavigationMoreVert);
NavigationMoreVert.displayName = 'NavigationMoreVert';
NavigationMoreVert.muiName = 'SvgIcon';
export default NavigationMoreVert;
|
addons/themes/txt/layouts/Blog.js | rendact/rendact | import $ from 'jquery'
import React from 'react';
import gql from 'graphql-tag';
import {graphql} from 'react-apollo';
import moment from 'moment';
import {Link} from 'react-router';
import scrollToElement from 'scroll-to-element';
let Blog = React.createClass({
componentDidMount(){
require('../assets/css/main.css')
},
componentWillMount(){
document.body.className = "homepage";
},
handleScrolly(e){
scrollToElement("#inti", {
duration: 1500,
offset: 0,
ease: 'in-sine'
})
},
render(){
let { theConfig, latestPosts: data, thePagination, loadDone } = this.props;
return (
<div>
<div id="page-wrapper">
<header id="header">
<div className="logo container">
<div>
<h1><Link to={"/"}>{theConfig?theConfig.name:"Rendact"} </Link></h1>
<p>{theConfig?theConfig.tagline:"Hello, you are in Rendact"}</p>
</div>
</div>
</header>
<nav id="nav">
{this.props.theMenu()}
</nav>
<div id="banner-wrapper">
<section id="banner">
<h2><Link to={"/"}>{theConfig?theConfig.name:"Rendact"}</Link></h2>
<p>{theConfig?theConfig.tagline:"Hello, you are in Rendact"}</p>
<a href="#" className="button" onClick={this.handleScrolly}>Alright let's go</a>
</section>
</div>
<div id="main-wrapper">
<div id="main" className="container">
<div className="row 200%">
<div className="12u">
<section id="inti" className="box features">
<h2 className="major"><span>Posts</span></h2>
<div>
<div className="row">
{data && data.map((post, index) => (
<div className="6u 12u(mobile)">
<section className="box feature">
<Link className="image featured" to={"/post/" + post.id}>
<img src={post.imageFeatured ? post.imageFeatured.blobUrl: require('images/logo-128.png') } alt="" />
</Link>
<h3><Link to={"/post/" + post.id}>{post.title && post.title}</Link></h3>
<p dangerouslySetInnerHTML={{__html: post.content ? post.content.slice(0, 160):""}} />
<Link className="button" to={"/post/" + post.id}>Read More</Link>
</section>
</div>
))}
</div>
</div>
</section>
</div>
</div>
</div>
</div>
<footer id="footer" className="container">
{this.props.footerWidgets &&
this.props.footerWidgets.map((fw, idx) => <div className="row 200%"><div className="12u"><section>{fw}</section></div></div>)}
<div className="row 200%">
<div className="12u">
<section>
<h2 className="major"><span>Get in touch</span></h2>
<ul className="contact">
<li><a className="icon fa-facebook" href="#"><span className="label">Facebook</span></a></li>
<li><a className="icon fa-twitter" href="#"><span className="label">Twitter</span></a></li>
<li><a className="icon fa-instagram" href="#"><span className="label">Instagram</span></a></li>
<li><a className="icon fa-dribbble" href="#"><span className="label">Dribbble</span></a></li>
<li><a className="icon fa-google-plus" href="#"><span className="label">Google+</span></a></li>
</ul>
</section>
</div>
</div>
<div id="copyright">
<ul className="menu">
<li>© Rendact. All rights reserved</li><li>Design: <a href="http://html5up.net">HTML5 UP</a></li>
</ul>
</div>
</footer>
</div>
</div>
)
}
});
export default Blog; |
packages/material-ui-icons/src/PinDrop.js | AndriusBil/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from 'material-ui/SvgIcon';
let PinDrop = 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>;
PinDrop = pure(PinDrop);
PinDrop.muiName = 'SvgIcon';
export default PinDrop;
|
src-example/components/molecules/Field/index.js | SIB-Colombia/biodiversity_catalogue_v2_frontend | import React from 'react'
import PropTypes from 'prop-types'
import styled from 'styled-components'
import { Label, Input, Block } from 'components'
const Error = styled(Block)`
margin: 0.5rem 0 0;
`
const Wrapper = styled.div`
margin-bottom: 1rem;
input[type="checkbox"],
input[type="radio"] {
margin-right: 0.5rem;
}
label {
vertical-align: middle;
}
`
const Field = ({ error, name, invalid, label, type, ...props }) => {
const inputProps = { id: name, name, type, invalid, 'aria-describedby': `${name}Error`, ...props }
const renderInputFirst = type === 'checkbox' || type === 'radio'
return (
<Wrapper>
{renderInputFirst && <Input {...inputProps} />}
{label && <Label htmlFor={inputProps.id}>{label}</Label>}
{renderInputFirst || <Input {...inputProps} />}
{invalid && error &&
<Error id={`${name}Error`} role="alert" palette="danger">
{error}
</Error>
}
</Wrapper>
)
}
Field.propTypes = {
name: PropTypes.string.isRequired,
invalid: PropTypes.bool,
error: PropTypes.string,
label: PropTypes.string,
type: PropTypes.string,
}
Field.defaultProps = {
type: 'text',
}
export default Field
|
src/docs/components/headline/HeadlineExamplesDoc.js | karatechops/grommet-docs | // (C) Copyright 2014-2016 Hewlett Packard Enterprise Development LP
import React, { Component } from 'react';
import Headline from 'grommet/components/Headline';
import InteractiveExample from '../../../components/InteractiveExample';
const PROPS_SCHEMA = {
strong: { value: true },
size: { options: ['small', 'medium', 'large', 'xlarge'] }
};
export default class HeadlineExamplesDoc extends Component {
constructor () {
super();
this.state = { elementProps: {} };
}
render () {
const { elementProps } = this.state;
const element = <Headline {...elementProps}>Sample Headline</Headline>;
return (
<InteractiveExample contextLabel='Headline' contextPath='/docs/headline'
preamble={`import Headline from 'grommet/components/Headline';`}
propsSchema={PROPS_SCHEMA}
element={element}
onChange={elementProps => this.setState({ elementProps })} />
);
}
};
|
src/svg-icons/image/edit.js | rhaedes/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let ImageEdit = (props) => (
<SvgIcon {...props}>
<path d="M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04c.39-.39.39-1.02 0-1.41l-2.34-2.34c-.39-.39-1.02-.39-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z"/>
</SvgIcon>
);
ImageEdit = pure(ImageEdit);
ImageEdit.displayName = 'ImageEdit';
export default ImageEdit;
|
senic_hub/setup_app/components/SelectComponentDevices.js | grunskis/nuimo-hub-backend | import React from 'react'
import { Text } from 'react-native'
import { Button } from 'react-native-elements'
import Screen from './Screen'
import Settings from '../Settings'
export default class AddComponent extends Screen {
constructor(props) {
super(props)
this.setNavigationButtons([], [{
'title': "Save",
'id': 'save',
//TODO: Replace the dummy deviceId value
'onPress': () => this.saveComponent('001788176885')
}])
}
saveComponent(deviceId) {
let body = JSON.stringify({device_id: deviceId})
let params = {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: body,
}
fetch(Settings.HUB_API_URL + 'nuimos/0/components', params)
.then(() => this.dismissAllModals())
.catch((error) => console.error(error))
}
render() {
return (
<Text>TODO</Text>
)
}
}
|
examples/src/components/Creatable.js | dmatteo/react-select | import React from 'react';
import Select from 'react-select';
var CreatableDemo = React.createClass({
displayName: 'CreatableDemo',
propTypes: {
hint: React.PropTypes.string,
label: React.PropTypes.string
},
getInitialState () {
return {
multi: true,
multiValue: [],
options: [
{ value: 'R', label: 'Red' },
{ value: 'G', label: 'Green' },
{ value: 'B', label: 'Blue' }
],
value: undefined
};
},
handleOnChange (value) {
const { multi } = this.state;
if (multi) {
this.setState({ multiValue: value });
} else {
this.setState({ value });
}
},
render () {
const { multi, multiValue, options, value } = this.state;
return (
<div className="section">
<h3 className="section-heading">{this.props.label}</h3>
<Select.Creatable
multi={multi}
options={options}
onChange={this.handleOnChange}
value={multi ? multiValue : value}
/>
<div className="hint">{this.props.hint}</div>
<div className="checkbox-list">
<label className="checkbox">
<input
type="radio"
className="checkbox-control"
checked={multi}
onChange={() => this.setState({ multi: true })}
/>
<span className="checkbox-label">Multiselect</span>
</label>
<label className="checkbox">
<input
type="radio"
className="checkbox-control"
checked={!multi}
onChange={() => this.setState({ multi: false })}
/>
<span className="checkbox-label">Single Value</span>
</label>
</div>
</div>
);
}
});
module.exports = CreatableDemo;
|
src/DropdownButton.js | pombredanne/react-bootstrap | import React from 'react';
import Dropdown from './Dropdown';
import omit from 'lodash-compat/object/omit';
import pick from 'lodash-compat/object/pick';
import Button from './Button';
class DropdownButton extends React.Component {
render() {
let { bsStyle, bsSize, disabled } = this.props;
let { title, children, ...props } = this.props;
let dropdownProps = pick(props, Object.keys(Dropdown.ControlledComponent.propTypes));
let toggleProps = omit(props, Object.keys(Dropdown.ControlledComponent.propTypes));
return (
<Dropdown {...dropdownProps}
bsSize={bsSize}
bsStyle={bsStyle}
>
<Dropdown.Toggle
{...toggleProps}
disabled={disabled}
>
{title}
</Dropdown.Toggle>
<Dropdown.Menu>
{children}
</Dropdown.Menu>
</Dropdown>
);
}
}
DropdownButton.propTypes = {
disabled: React.PropTypes.bool,
bsStyle: Button.propTypes.bsStyle,
bsSize: Button.propTypes.bsSize,
/**
* When used with the `title` prop, the noCaret option will not render a caret icon, in the toggle element.
*/
noCaret: React.PropTypes.bool,
title: React.PropTypes.node.isRequired,
...Dropdown.propTypes,
};
DropdownButton.defaultProps = {
disabled: false,
pullRight: false,
dropup: false,
navItem: false,
noCaret: false
};
export default DropdownButton;
|
client/src/App.js | CrashsLanding/petfinder-searcher | import React, { Component } from 'react';
import FacetContainer from './Components/FacetContainer/FacetContainer';
import AnimalContainer from './Components/AnimalContainer/AnimalContainer';
import axios from 'axios';
import config from './config';
import './App.css';
import _ from 'lodash';
class App extends Component {
constructor(props) {
super(props);
this.endpoint = config.apiEndpoint;
this.state = {
animals: [],
facets: {},
selectedFacets: {},
andFacets: [],
andAbleFacets: ["options", "breeds"]
};
}
onFacetChange(updatedFacets) {
this.setState({
selectedFacets: updatedFacets
});
}
onAndFacetChange(updatedFacets) {
this.setState({
andFacets: updatedFacets
});
}
componentDidMount() {
this.loadAnimals().then(animals => {
this.setState({
animals: animals
});
this.loadFacets();
});
}
processPet(pet){
let options = pet.options;
let index = options.indexOf("noClaws");
if (index !== -1){
options[index] = "declawed";
}
return pet;
}
loadAnimals() {
return axios.get(this.endpoint)
.then(response => {
let pets = _.map(response.data['pets'], pet => this.processPet(pet));
return _.sortBy(pets, pet => pet.name);
});
}
loadFacets() {
// let petType = this.createFacetEntriesForFacetName('petType');
let breeds = this.createFacetEntriesForFacetName('breeds');
let age = this.createFacetEntriesForFacetName('age');
let size = this.createFacetEntriesForFacetName('size');
let sex = this.createFacetEntriesForFacetName('sex');
let options = this.createFacetEntriesForFacetName('options');
let colors = this.createFacetEntriesForFacetName('colors');
let shelter = this.createFacetEntriesForFacetName('shelter');
this.setState({
facets: { shelter, options, breeds, colors, age, size, sex }
});
}
createFacetEntriesForFacetName(facetName) {
let animals = this.state.animals;
let availableEntriesForFacet = _.flatMap(animals, animal => _.get(animal, facetName));
return availableEntriesForFacet.reduce((map, obj) => {
map[obj] = false;
return map;
}, {});
}
render() {
return (
<div className="App">
<div className="container-fluid app-container">
<div className="row">
<FacetContainer onFacetChange={this.onFacetChange.bind(this)}
onAndFacetChange={this.onAndFacetChange.bind(this)}
andFacets={this.state.andFacets}
andAbleFacets={this.state.andAbleFacets}
facets={this.state.facets}>
</FacetContainer>
<AnimalContainer selectedFacets={this.state.selectedFacets}
andFacets={this.state.andFacets}
animals={this.state.animals}>
</AnimalContainer>
</div>
</div>
</div>
);
}
}
export default App;
|
src/stores/CountryDefsStore.js | alexmasselot/medlineGeoWebFrontend | import React from 'react';
import {EventEmitter} from 'events';
import assign from 'object-assign';
import httpClient from '../core/HttpClient';
import dispatcher from '../core/Dispatcher';
import Constants from '../constants/Constants';
import BaseStore from './BaseStore'
import _ from 'lodash';
import topojsonWorld from './data/world-110m.json';
let _data = {};
const store = assign({}, BaseStore, {
getTopoJson() {
return topojsonWorld;
},
getInfoByIso2(iso2){
let _this = this;
//builds the dictionary if not ready
if(_this._hInfos === undefined){
_this._hInfos= {};
_.each(topojsonWorld.features, function(ft){
_this._hInfos[ft.properties.iso_a2] = ft.properties;
});
}
return _this._hInfos[iso2];
},
setCountryFocus(iso2){
_data.countryFocus = this.getInfoByIso2(iso2);
store.emitChange();
},
getCountryFocus(){
return _data.countryFocus
},
dispatcherIndex: dispatcher.register(function (payload) {
let _this = this;
let action = payload.action;
switch (action.type) {
case Constants.ACTION_SET_COUNTRY_FOCUS:
store.setCountryFocus(payload.iso2.toUpperCase());
break;
}
})
});
export default store;
|
test/helpers/shallowRenderHelper.js | andresin87/enAlquiler | /**
* Function to get the shallow output for a given component
* As we are using phantom.js, we also need to include the fn.proto.bind shim!
*
* @see http://simonsmith.io/unit-testing-react-components-without-a-dom/
* @author somonsmith
*/
import React from 'react';
import TestUtils from 'react-addons-test-utils';
/**
* Get the shallow rendered component
*
* @param {Object} component The component to return the output for
* @param {Object} props [optional] The components properties
* @param {Mixed} ...children [optional] List of children
* @return {Object} Shallow rendered output
*/
export default function createComponent(component, props = {}, ...children) {
const shallowRenderer = TestUtils.createRenderer();
shallowRenderer.render(React.createElement(component, props, children.length > 1 ? children : children[0]));
return shallowRenderer.getRenderOutput();
}
|
src/components/subjects/BookSubjectItem.js | great-design-and-systems/cataloguing-app | import FontAwesome from 'react-fontawesome';
import { LABEL_REMOVE } from '../../labels/';
import { Link } from 'react-router';
import PropTypes from 'prop-types';
import React from 'react';
import { toReadableSubject } from '../../utils/';
export const BookSubjectItem = ({ subject, removeSubject, index }) => {
return (<div className="subject-item list-group-item">
<button type="button" onClick={removeSubject} className="btn btn-danger btn-xs"><FontAwesome fixedWidth={true} name="minus" /><span className="hidden-xs">{LABEL_REMOVE}</span></button><Link to={'/books/subjects/' + index}>{toReadableSubject(subject)}</Link></div>);
};
BookSubjectItem.propTypes = {
index: PropTypes.number,
removeSubject: PropTypes.func.isRequired,
subject: PropTypes.string.isRequired
}; |
src/components/SvgIcons/WhatsApp/index.js | RaphaelHaettich/werwolfga.me | import React from 'react';
import SvgIcon from 'material-ui/SvgIcon';
/* eslint-disable max-len*/
// SVG d Path | eslint disa
const icon = `M380.9 97.1C339 55.1 283.2 32 223.9 32c-122.4 0-222 99.6-222 222 0 39.1 10.2 77.3 29.6 111L0 480l117.7-30.9c32.4 17.7 68.9 27 106.1 27h.1c122.3 0 224.1-99.6 224.1-222 0-59.3-25.2-115-67.1-157zm-157 341.6c-33.2 0-65.7-8.9-94-25.7l-6.7-4-69.8 18.3L72 359.2l-4.4-7c-18.5-29.4-28.2-63.3-28.2-98.2 0-101.7 82.8-184.5 184.6-184.5 49.3 0 95.6 19.2 130.4 54.1 34.8 34.9 56.2 81.2 56.1 130.5 0 101.8-84.9 184.6-186.6 184.6zm101.2-138.2c-5.5-2.8-32.8-16.2-37.9-18-5.1-1.9-8.8-2.8-12.5 2.8-3.7 5.6-14.3 18-17.6 21.8-3.2 3.7-6.5 4.2-12 1.4-32.6-16.3-54-29.1-75.5-66-5.7-9.8 5.7-9.1 16.3-30.3 1.8-3.7.9-6.9-.5-9.7-1.4-2.8-12.5-30.1-17.1-41.2-4.5-10.8-9.1-9.3-12.5-9.5-3.2-.2-6.9-.2-10.6-.2-3.7 0-9.7 1.4-14.8 6.9-5.1 5.6-19.4 19-19.4 46.3 0 27.3 19.9 53.7 22.6 57.4 2.8 3.7 39.1 59.7 94.8 83.8 35.2 15.2 49 16.5 66.6 13.9 10.7-1.6 32.8-13.4 37.4-26.4 4.6-13 4.6-24.1 3.2-26.4-1.3-2.5-5-3.9-10.5-6.6z`;
/* eslint-enable*/
const Icon = props => (
<SvgIcon {...props}>
<path d={icon} />
</SvgIcon>
);
const WhatsAppIcon = props => (
<Icon {...props} viewBox="0 0 448 512" />
);
export default WhatsAppIcon;
|
src/components/exercises/MatchImage.stories.js | cognostics/serlo-abc | import React from 'react';
import { storiesOf } from '@storybook/react-native';
import MatchImage from './MatchImage';
storiesOf('exercises/MatchImage', module).add('Apfel', () => (
<MatchImage
images={[
require('../../assets/images/affe.jpg'),
require('../../assets/images/esel.jpg'),
require('../../assets/images/apfel.jpg'),
require('../../assets/images/nase.jpg')
]}
text="Apfel"
sound={require('../../assets/sounds/apfel_short.mp3')}
/>
));
|
app/javascript/src/client/pages/not_found.js | rringler/billtalk | import React, { Component } from 'react';
export default class NotFound extends Component {
render() {
return <h1>404 <small>Not Found :(</small></h1>;
}
}
|
packages/react-server-website/middleware/PageFooter.js | emecell/react-server | import React from 'react';
import Footer from '../components/Footer';
export default class PageFooter {
getElements(next) {
return next().concat(<Footer />);
}
}
|
frontend/jqwidgets/jqwidgets-react/react_jqxdragdrop.js | liamray/nexl-js | /*
jQWidgets v5.7.2 (2018-Apr)
Copyright (c) 2011-2018 jQWidgets.
License: https://jqwidgets.com/license/
*/
import React from 'react';
const JQXLite = window.JQXLite;
export const jqx = window.jqx;
export default class JqxDragDrop extends React.Component {
componentDidMount() {
let options = this.manageAttributes();
this.createComponent(options);
};
manageAttributes() {
let properties = ['appendTo','disabled','distance','data','dropAction','dropTarget','dragZIndex','feedback','initFeedback','opacity','onDragEnd','onDrag','onDragStart','onTargetDrop','onDropTargetEnter','onDropTargetLeave','restricter','revert','revertDuration','tolerance'];
let options = {};
for(let item in this.props) {
if(item === 'settings') {
for(let itemTwo in this.props[item]) {
options[itemTwo] = this.props[item][itemTwo];
}
} else {
if(properties.indexOf(item) !== -1) {
options[item] = this.props[item];
}
}
}
return options;
};
createComponent(options) {
if(!this.style) {
for (let style in this.props.style) {
JQXLite(this.componentSelector).css(style, this.props.style[style]);
}
}
if(this.props.className !== undefined) {
let classes = this.props.className.split(' ');
for (let i = 0; i < classes.length; i++ ) {
JQXLite(this.componentSelector).addClass(classes[i]);
}
}
if(!this.template) {
JQXLite(this.componentSelector).html(this.props.template);
}
JQXLite(this.componentSelector).jqxDragDrop(options);
};
setOptions(options) {
JQXLite(this.componentSelector).jqxDragDrop('setOptions', options);
};
getOptions() {
if(arguments.length === 0) {
throw Error('At least one argument expected in getOptions()!');
}
let resultToReturn = {};
for(let i = 0; i < arguments.length; i++) {
resultToReturn[arguments[i]] = JQXLite(this.componentSelector).jqxDragDrop(arguments[i]);
}
return resultToReturn;
};
on(name,callbackFn) {
JQXLite(this.componentSelector).on(name,callbackFn);
};
off(name) {
JQXLite(this.componentSelector).off(name);
};
appendTo(arg) {
if (arg !== undefined) {
JQXLite(this.componentSelector).jqxDragDrop('appendTo', arg)
} else {
return JQXLite(this.componentSelector).jqxDragDrop('appendTo');
}
};
disabled(arg) {
if (arg !== undefined) {
JQXLite(this.componentSelector).jqxDragDrop('disabled', arg)
} else {
return JQXLite(this.componentSelector).jqxDragDrop('disabled');
}
};
distance(arg) {
if (arg !== undefined) {
JQXLite(this.componentSelector).jqxDragDrop('distance', arg)
} else {
return JQXLite(this.componentSelector).jqxDragDrop('distance');
}
};
data(arg) {
if (arg !== undefined) {
JQXLite(this.componentSelector).jqxDragDrop('data', arg)
} else {
return JQXLite(this.componentSelector).jqxDragDrop('data');
}
};
dropAction(arg) {
if (arg !== undefined) {
JQXLite(this.componentSelector).jqxDragDrop('dropAction', arg)
} else {
return JQXLite(this.componentSelector).jqxDragDrop('dropAction');
}
};
dropTarget(arg) {
if (arg !== undefined) {
JQXLite(this.componentSelector).jqxDragDrop('dropTarget', arg)
} else {
return JQXLite(this.componentSelector).jqxDragDrop('dropTarget');
}
};
dragZIndex(arg) {
if (arg !== undefined) {
JQXLite(this.componentSelector).jqxDragDrop('dragZIndex', arg)
} else {
return JQXLite(this.componentSelector).jqxDragDrop('dragZIndex');
}
};
feedback(arg) {
if (arg !== undefined) {
JQXLite(this.componentSelector).jqxDragDrop('feedback', arg)
} else {
return JQXLite(this.componentSelector).jqxDragDrop('feedback');
}
};
initFeedback(arg) {
if (arg !== undefined) {
JQXLite(this.componentSelector).jqxDragDrop('initFeedback', arg)
} else {
return JQXLite(this.componentSelector).jqxDragDrop('initFeedback');
}
};
opacity(arg) {
if (arg !== undefined) {
JQXLite(this.componentSelector).jqxDragDrop('opacity', arg)
} else {
return JQXLite(this.componentSelector).jqxDragDrop('opacity');
}
};
onDragEnd(arg) {
if (arg !== undefined) {
JQXLite(this.componentSelector).jqxDragDrop('onDragEnd', arg)
} else {
return JQXLite(this.componentSelector).jqxDragDrop('onDragEnd');
}
};
onDrag(arg) {
if (arg !== undefined) {
JQXLite(this.componentSelector).jqxDragDrop('onDrag', arg)
} else {
return JQXLite(this.componentSelector).jqxDragDrop('onDrag');
}
};
onDragStart(arg) {
if (arg !== undefined) {
JQXLite(this.componentSelector).jqxDragDrop('onDragStart', arg)
} else {
return JQXLite(this.componentSelector).jqxDragDrop('onDragStart');
}
};
onTargetDrop(arg) {
if (arg !== undefined) {
JQXLite(this.componentSelector).jqxDragDrop('onTargetDrop', arg)
} else {
return JQXLite(this.componentSelector).jqxDragDrop('onTargetDrop');
}
};
onDropTargetEnter(arg) {
if (arg !== undefined) {
JQXLite(this.componentSelector).jqxDragDrop('onDropTargetEnter', arg)
} else {
return JQXLite(this.componentSelector).jqxDragDrop('onDropTargetEnter');
}
};
onDropTargetLeave(arg) {
if (arg !== undefined) {
JQXLite(this.componentSelector).jqxDragDrop('onDropTargetLeave', arg)
} else {
return JQXLite(this.componentSelector).jqxDragDrop('onDropTargetLeave');
}
};
restricter(arg) {
if (arg !== undefined) {
JQXLite(this.componentSelector).jqxDragDrop('restricter', arg)
} else {
return JQXLite(this.componentSelector).jqxDragDrop('restricter');
}
};
revert(arg) {
if (arg !== undefined) {
JQXLite(this.componentSelector).jqxDragDrop('revert', arg)
} else {
return JQXLite(this.componentSelector).jqxDragDrop('revert');
}
};
revertDuration(arg) {
if (arg !== undefined) {
JQXLite(this.componentSelector).jqxDragDrop('revertDuration', arg)
} else {
return JQXLite(this.componentSelector).jqxDragDrop('revertDuration');
}
};
tolerance(arg) {
if (arg !== undefined) {
JQXLite(this.componentSelector).jqxDragDrop('tolerance', arg)
} else {
return JQXLite(this.componentSelector).jqxDragDrop('tolerance');
}
};
render() {
let id = 'jqxDragDrop' + JQXLite.generateID();
this.componentSelector = '#' + id;
return (
<div id={id}>{this.props.value}{this.props.children}</div>
)
};
};
|
src/components/buttons/RaisedButton.js | tuckerconnelly/carbon-ui | import React from 'react'
import PropTypes from 'prop-types'
import Uranium from 'uranium'
import Color from 'color'
import {
TouchableRipple,
Body2,
Breakpoints,
Colors,
Elevation,
connectTheme,
} from '../../index'
/**
* Raised buttons behave like a piece of material resting on another sheet –
* they lift and fill with color on press.
*
* ### Examples
*
* import React from 'react'
* import { View } from 'react-native'
* import { RaisedButton } from 'carbon-ui'
*
* export default () =>
* <View style={{ justifyContent: 'flex-start', flexDirection: 'row' }}>
* <RaisedButton>Click me!</RaisedButton>
* <RaisedButton disabled>Out of commission</RaisedButton>
* </View>
*
*/
const RaisedButton = ({
disabled,
children,
textStyle,
theme,
...other
}) => {
// Themed styles
const styles = tStyles(theme)
// Uppercase and style if the child is a string
// Otherwise it's probably an icon or image, so let it through
const formattedChildren = typeof children === 'string' ?
(<Body2
style={[
styles.text,
disabled && styles.disabledText,
textStyle,
]}>
{children.toUpperCase()}
</Body2>) :
children
return (
<TouchableRipple
hitSlop={{ top: 6, right: 6, bottom: 6, left: 6 }}
css={[styles.base, disabled && styles.disabled]}
rippleColor={Colors.white}
disabled={disabled}
{...other}>
{formattedChildren}
</TouchableRipple>
)
}
RaisedButton.propTypes = {
/**
* Disables the button if set to true.
*/
disabled: PropTypes.bool,
/**
* The inside of the button. If it's text, it'll be UPPERCASEd.
*/
children: PropTypes.node,
/**
* The style of the button text. Only applies if props.children isn't passed.
*/
textStyle: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
// connectTheme
theme: PropTypes.object.isRequired,
}
const tStyles = theme => ({
base: {
height: 36,
minWidth: 88,
paddingHorizontal: 16,
borderRadius: 2,
marginHorizontal: 8,
alignItems: 'center',
justifyContent: 'center',
backgroundColor: theme.colors.primary,
...Elevation.dp2,
[Breakpoints.ml]: {
height: 32,
...Elevation.none,
},
},
text: {
color: Colors.whitePrimary,
lineHeight: 16,
textAlign: 'center',
},
pressed: {
...Elevation.dp4,
},
disabled: {
backgroundColor: theme.colors.button.raised.disabled,
},
disabledText: {
color: theme.colors.button.raised.disabledText,
},
focused: {
backgroundColor: Color(theme.colors.primary).darken(0.12).hexString(),
},
hovered: {
...Elevation.dp2,
},
})
export default
connectTheme(
Uranium(
RaisedButton))
|
src/js/components/mobile_list.js | wangi4myself/myFirstReactJs | import React from 'react';
import {Row,Col} from 'antd';
import {Router, Route, Link, browserHistory} from 'react-router'
export default class MobileList extends React.Component {
constructor() {
super();
this.state = {
news: ''
};
}
componentWillMount() {
var myFetchOptions = {
method: 'GET'
};
fetch("http://newsapi.gugujiankong.com/Handler.ashx?action=getnews&type=" + this.props.type + "&count=" + this.props.count, myFetchOptions).then(response => response.json()).then(json => this.setState({news: json}));
};
render() {
const {news} = this.state;
const newsList = news.length
? news.map((newsItem, index) => (
<section key={index} className="m_article list-item special_section clearfix">
<Link to={`details/${newsItem.uniquekey}`}>
<div className="m_article_img">
<img src={newsItem.thumbnail_pic_s} alt={newsItem.title} />
</div>
<div className="m_article_info">
<div className="m_article_title">
<span>{newsItem.title}</span>
</div>
<div className="m_article_desc clearfix">
<div className="m_article_desc_l">
<span className="m_article_channel">{newsItem.realtype}</span>
<span className="m_article_time">{newsItem.date}</span>
</div>
</div>
</div>
</Link>
</section>
))
: '没有加载到任何新闻';
return (
<div>
<Row>
<Col span={24}>
{newsList}
</Col>
</Row>
</div>
);
};
}
|
web/components/shared/Button/cosmos.decorator.js | skidding/flatris | // @flow
import React from 'react';
import { GameContainerMock } from '../../../mocks/GameContainerMock';
export default ({ children }: { children: React$Node }) => (
<GameContainerMock cols={4} rows={2}>
{children}
</GameContainerMock>
);
|
docs/src/examples/modules/Dropdown/Types/DropdownExampleInline.js | Semantic-Org/Semantic-UI-React | import React from 'react'
import { Dropdown } from 'semantic-ui-react'
const friendOptions = [
{
key: 'Jenny Hess',
text: 'Jenny Hess',
value: 'Jenny Hess',
image: { avatar: true, src: '/images/avatar/small/jenny.jpg' },
},
{
key: 'Elliot Fu',
text: 'Elliot Fu',
value: 'Elliot Fu',
image: { avatar: true, src: '/images/avatar/small/elliot.jpg' },
},
{
key: 'Stevie Feliciano',
text: 'Stevie Feliciano',
value: 'Stevie Feliciano',
image: { avatar: true, src: '/images/avatar/small/stevie.jpg' },
},
{
key: 'Christian',
text: 'Christian',
value: 'Christian',
image: { avatar: true, src: '/images/avatar/small/christian.jpg' },
},
]
const DropdownExampleInline = () => (
<span>
Show me posts by{' '}
<Dropdown
inline
options={friendOptions}
defaultValue={friendOptions[0].value}
/>
</span>
)
export default DropdownExampleInline
|
src/components/Sidebar/index.js | RodgerLai/nodejs-nedb-excel | import React from 'react';
import {Link} from 'react-router';
import {connect} from 'react-redux'
import {bindActionCreators} from 'redux'
import {Menu, Icon} from 'antd';
import Logo from '../Logo';
import Logger from '../../utils/Logger';
import items from 'menu.js'; // 由于webpack中的设置, 不用写完整路径
import globalConfig from 'config.js';
import './index.less';
import {sidebarCollapseCreator} from '../../redux/Sidebar.js';
const SubMenu = Menu.SubMenu;
const MenuItem = Menu.Item;
const logger = Logger.getLogger('Sidebar');
/**
* 定义sidebar组件
*/
class Sidebar extends React.PureComponent {
// 尝试把sidebar做成PureComponent, 注意可能的bug
// 注意PureComponent的子组件也应该是pure的
state = {
openKeys: [], // 当前有哪些submenu被展开
};
// 哪些状态组件自己维护, 哪些状态放到redux, 是需要权衡的
/**
* 将菜单项配置转换为对应的MenuItem组件
*
* @param obj sidebar菜单配置项
* @param paths 父级目录, array
* @returns {XML}
*/
transFormMenuItem(obj, paths, isLevel1) {
const parentPath = paths.join('/'); // 将各级父目录组合成完整的路径
logger.debug('transform %o to path %s', obj, parentPath);
// 这个表达式还是有点恶心的...
// JSX虽然方便, 但是很容易被滥用, ES6也是
// 注意这里的样式, 用chrome一点点调出来的...
// 我的css都是野路子, 头痛医头脚痛医脚, 哪里显示有问题就去调一下, 各种inline style
// 估计事后去看的话, 我都忘了为什么要加这些样式...
return (
<MenuItem key={obj.key} style={{ margin: '0px' }}>
{obj.icon && <Icon type={obj.icon}/>}
{/*对于level1的菜单项, 如果没有图标, 取第一个字用于折叠时显示*/}
{isLevel1 && !obj.icon && <span className="invisible-nav-text">{obj.name[0]}</span>}
<Link to={`/${parentPath}`} style={{ display: 'inline' }}><span className="nav-text">{obj.name}</span></Link>
</MenuItem>
);
}
// 在每次组件挂载的时候parse一次菜单, 不用每次render都解析
// 其实这个也可以放在constructor里
componentWillMount() {
const paths = []; // 暂存各级路径, 当作stack用
const level1KeySet = new Set(); // 暂存所有顶级菜单的key
const level2KeyMap = new Map(); // 次级菜单与顶级菜单的对应关系
// 菜单项是从配置中读取的, parse过程还是有点复杂的
// map函数很好用
const menu = items.map((level1) => {
// parse一级菜单
paths.push(level1.key);
level1KeySet.add(level1.key);
if (this.state.openKeys.length === 0) {
this.state.openKeys.push(level1.key); // 默认展开第一个菜单, 直接修改state, 没必要setState
}
// 是否有子菜单?
if (level1.child) {
const level2menu = level1.child.map((level2) => {
// parse二级菜单
paths.push(level2.key);
level2KeyMap.set(level2.key, level1.key);
if (level2.child) {
const level3menu = level2.child.map((level3) => {
// parse三级菜单, 不能再有子菜单了, 即使有也会忽略
paths.push(level3.key);
const tmp = this.transFormMenuItem(level3, paths);
paths.pop();
return tmp;
});
paths.pop();
return (
<SubMenu key={level2.key}
title={level2.icon ? <span><Icon type={level2.icon} />{level2.name}</span> : level2.name}>
{level3menu}
</SubMenu>
);
} else {
const tmp = this.transFormMenuItem(level2, paths);
paths.pop();
return tmp;
}
});
paths.pop();
let level1Title;
// 同样, 如果没有图标的话取第一个字
if (level1.icon) {
level1Title = <span><Icon type={level1.icon}/><span className="nav-text">{level1.name}</span></span>;
} else {
level1Title = <span><span className="invisible-nav-text">{level1.name[0]}</span><span
className="nav-text">{level1.name}</span></span>;
}
return (
<SubMenu key={level1.key} title={level1Title}>
{level2menu}
</SubMenu>
)
}
// 没有子菜单, 直接转换为MenuItem
else {
const tmp = this.transFormMenuItem(level1, paths, true);
paths.pop(); // return之前别忘了pop
return tmp;
}
});
this.menu = menu;
this.level1KeySet = level1KeySet;
this.level2KeyMap = level2KeyMap;
}
// 我决定在class里面, 只有在碰到this问题时才使用箭头函数, 否则还是优先使用成员方法的形式定义函数
// 因为用箭头函数ESlint总是提示语句最后少一个分号...
// 事件处理的方法统一命名为handleXXX
/**
* 处理子菜单的展开事件
*
* @param openKeys
*/
handleOpenChange = (openKeys) => {
// 如果当前菜单是折叠状态, 就先展开
if (this.props.collapse) {
this.props.handleClickCollapse();
}
if (!globalConfig.sidebar.autoMenuSwitch) { // 不开启这个功能
this.setState({openKeys});
return;
}
logger.debug('old open keys: %o', openKeys);
const newOpenKeys = [];
// 有没有更优雅的写法
let lastKey = ''; // 找到最近被点击的一个顶级菜单, 跟数组中元素的顺序有关
for (let i = openKeys.length; i >= 0; i--) {
if (this.level1KeySet.has(openKeys[i])) {
lastKey = openKeys[i];
break;
}
}
// 过滤掉不在lastKey下面的所有子菜单
for (const key of openKeys) {
const ancestor = this.level2KeyMap.get(key);
if (ancestor === lastKey) {
newOpenKeys.push(key);
}
}
newOpenKeys.push(lastKey);
logger.debug('new open keys: %o', newOpenKeys);
this.setState({openKeys: newOpenKeys});
};
/**
* 处理"叶子"节点的点击事件
*
* @param key
*/
handleSelect = ({key}) => {
if (this.props.collapse) {
this.props.handleClickCollapse();
}
// 如果是level1级别的菜单触发了这个事件, 说明这个菜单没有子项, 需要把其他所有submenu折叠
if (globalConfig.sidebar.autoMenuSwitch && this.level1KeySet.has(key) && this.state.openKeys.length > 0) {
this.setState({openKeys: []});
}
};
render() {
return (
<aside className={this.props.collapse ? "ant-layout-sidebar-collapse" : "ant-layout-sidebar"}>
<Logo collapse={this.props.collapse}/>
<Menu theme="dark" mode="inline"
onOpenChange={this.handleOpenChange}
onSelect={this.handleSelect}
openKeys={this.props.collapse ? [] : this.state.openKeys}>
{this.menu}
</Menu>
<div className="ant-layout-sidebar-trigger" onClick={this.props.handleClickCollapse}>
<Icon type={this.props.collapse ? "right" : "left"}/>
</div>
</aside>
);
}
}
// 什么时候使用箭头函数?
// 1. 碰到this问题的时候
// 2. 要写function关键字的时候
const mapStateToProps = (state) => {
return {
collapse: state.Sidebar.collapse,
};
};
const mapDispatchToProps = (dispatch) => {
return {
// 所有处理事件的方法都以handleXXX命名
handleClickCollapse: bindActionCreators(sidebarCollapseCreator, dispatch),
};
};
export default connect(mapStateToProps, mapDispatchToProps)(Sidebar);
|
client/src/components/chrome/index.js | 15thnight/15thnight | import React from 'react';
import { connect } from 'react-redux';
import {
getCurrentUser,
togglePageContainer,
clearPageScroll
} from 'actions';
import Navbar from './Navbar.js';
import Flash from './Flash';
import styles from './index.css';
class Chrome extends React.Component {
constructor(props) {
super(props);
this.state = {
navbarOpen: false
}
}
componentWillMount() {
let { body } = document;
body.parentElement.style.height = body.style.height = '100%';
this.props.getCurrentUser();
window.addEventListener('resize', this.handleWindowResize.bind(this));
}
componentWillUnmount() {
window.removeEventListener('resize', this.handleWindowResize);
}
componentDidUpdate() {
let { pageContainer } = this.props;
if (!pageContainer.hidden && pageContainer.scroll) {
window.scrollTo(0, pageContainer.scroll);
this.props.clearPageScroll();
}
window.removeEventListener('resize', this.handleWindowResize);
}
handleWindowResize() {
if (window.innerWidth >= 768 && this.props.pageContainer.hidden) {
if (this.props.pageContainer.scroll) {
window.scrollTo(0, this.props.pageContainer.scroll);
}
this.props.togglePageContainer(false);
this.setState({ navbarOpen: false });
}
}
render() {
let { current_user, routing } = this.props;
let className = styles.chrome;
if (this.props.pageContainer.hidden) {
className = className += ' hide-page';
}
return (
<div className={className}>
<Navbar
navbarOpen={this.state.navbarOpen}
toggleNavbar={(navbarOpen) => this.setState({ navbarOpen })}
current_user={current_user}
routing={routing}
togglePageContainer={this.props.togglePageContainer}
/>
<div className="container-fluid container">
<Flash />
{ this.props.children }
</div>
</div>
);
}
}
function mapStateToProps(state, ownProps) {
return {
pageContainer: state.pageContainer,
current_user: state.current_user,
routing: state.routing
}
}
export default connect(mapStateToProps, {
getCurrentUser,
togglePageContainer,
clearPageScroll
})(Chrome); |
src/components/icons/OpenInNewIcon.js | austinknight/ui-components | import React from 'react';
const OpenInNewIcon = props => (
<svg {...props.size || { width: '24px', height: '24px' }} {...props} viewBox="0 0 24 24">
{props.title && <title>{props.title}</title>}
<path d="M0 0h24v24H0z" fill="none" />
<path d="M19 19H5V5h7V3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2v-7h-2v7zM14 3v2h3.59l-9.83 9.83 1.41 1.41L19 6.41V10h2V3h-7z" />
</svg>
);
export default OpenInNewIcon;
|
app/index.js | chenzhq/TagViewer | import 'babel-polyfill'; // generators
require('antd/dist/antd.css')
import {render} from 'react-dom';
import React from 'react';
import {Provider} from 'react-redux'
import MainLayout from './components/MainLayout'
import configureStore from './store/store';
render(
<Provider store={configureStore()}>
<MainLayout />
</Provider>
, document.getElementById('example'));
|
examples/huge-apps/routes/Course/components/Course.js | cold-brew-coding/react-router | import React from 'react';
import Dashboard from './Dashboard';
import Nav from './Nav';
var styles = {};
styles.sidebar = {
float: 'left',
width: 200,
padding: 20,
borderRight: '1px solid #aaa',
marginRight: 20
};
class Course extends React.Component {
render () {
let { children, params } = this.props;
let course = COURSES[params.courseId];
return (
<div>
<h2>{course.name}</h2>
<Nav course={course} />
{children && children.sidebar && children.main ? (
<div>
<div className="Sidebar" style={styles.sidebar}>
{children.sidebar}
</div>
<div className="Main" style={{padding: 20}}>
{children.main}
</div>
</div>
) : (
<Dashboard />
)}
</div>
);
}
}
export default Course;
|
frontend/src/components/siteComponents/UserManagementUI/loginForm.js | webrecorder/webrecorder | import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { Link } from 'react-router-dom';
import { Alert, Button, Col, Form, FormGroup, FormControl, Row } from 'react-bootstrap';
import { guestSessionTimeout, product, userRegex } from 'config';
import { login } from 'helpers/userMessaging';
import { TempUsage } from 'containers';
class LoginForm extends Component {
static propTypes = {
anonCTA: PropTypes.bool,
auth: PropTypes.object,
cb: PropTypes.func,
error: PropTypes.bool,
closeLogin: PropTypes.func
};
constructor(props) {
super(props);
this.state = {
moveTemp: true,
toColl: 'New Collection',
remember_me: false,
username: '',
password: ''
};
}
save = (evt) => {
evt.preventDefault();
const { auth } = this.props;
const { moveTemp, password, toColl, username } = this.state;
let data = { username, password };
if (this.state.remember_me) {
data.remember_me = '1';
}
// check for anon usage
if (auth.getIn(['user', 'anon']) && auth.getIn(['user', 'num_collections']) > 0) {
data = { ...data, moveTemp, toColl };
}
this.props.cb(data);
}
validateUsername = () => {
const pattern = userRegex;
if (typeof this.state.username !== 'undefined') {
return this.state.username.match(pattern) === this.state.username ? null : 'warning';
}
return null;
}
handleChange = (evt) => {
if (evt.target.type === 'radio') {
this.setState({ [evt.target.name]: evt.target.value === 'yes' });
} else {
this.setState({ [evt.target.name]: evt.target.value });
}
}
render() {
const { anonCTA, auth, closeLogin, error } = this.props;
const { moveTemp, password, toColl, username } = this.state;
return (
<React.Fragment>
<Row className="wr-login-form">
<Col>
{
anonCTA &&
<h4>Please sign in to manage collections.</h4>
}
{
error &&
<Alert variant="danger">
{
login[auth.get('loginError')] || <span>Invalid Login. Please Try Again</span>
}
</Alert>
}
<Form id="loginform" onSubmit={this.save}>
<FormGroup
key="username">
<label htmlFor="username" className="sr-only">Username</label>
<FormControl aria-label="username" onChange={this.handleChange} value={username} type="text" id="username" name="username" className="form-control" placeholder="username" required autoFocus />
<div className="help-block with-errors" />
</FormGroup>
<FormGroup key="password">
<label htmlFor="inputPassword" className="sr-only">Password</label>
<FormControl aria-label="password" onChange={this.handleChange} value={password} type="password" id="password" name="password" className="form-control" placeholder="Password" required />
</FormGroup>
<FormGroup key="remember">
<input onChange={this.handleChange} type="checkbox" id="remember_me" name="remember_me" />
<label htmlFor="remember_me">Remember me</label>
<Link to="/_forgot" onClick={closeLogin} style={{ float: 'right' }}>Forgot password or username?</Link>
</FormGroup>
{
auth.getIn(['user', 'anon']) && auth.getIn(['user', 'num_collections']) > 0 &&
<TempUsage
handleInput={this.handleChange}
moveTemp={moveTemp}
toColl={toColl} />
}
<Button size="lg" variant="primary" type="submit" block>Sign in</Button>
</Form>
</Col>
</Row>
{
anonCTA &&
<div className="anon-cta">
<h5>New to {product}? <Link to="/_register" onClick={closeLogin}>Sign up »</Link></h5>
<h5>Or <Button onClick={closeLogin} className="button-link">continue as guest »</Button></h5>
<span className="info">Guest sessions are limited to {guestSessionTimeout}.</span>
</div>
}
</React.Fragment>
);
}
}
export default LoginForm;
|
js/jqwidgets/jqwidgets-react/react_jqxlayout.js | luissancheza/sice | /*
jQWidgets v5.3.2 (2017-Sep)
Copyright (c) 2011-2017 jQWidgets.
License: http://jqwidgets.com/license/
*/
import React from 'react';
const JQXLite = window.JQXLite;
export const jqx = window.jqx;
export default class JqxLayout extends React.Component {
componentDidMount() {
let options = this.manageAttributes();
this.createComponent(options);
};
manageAttributes() {
let properties = ['contextMenu','height','layout','minGroupHeight','minGroupWidth','resizable','rtl','theme','width'];
let options = {};
for(let item in this.props) {
if(item === 'settings') {
for(let itemTwo in this.props[item]) {
options[itemTwo] = this.props[item][itemTwo];
}
} else {
if(properties.indexOf(item) !== -1) {
options[item] = this.props[item];
}
}
}
return options;
};
createComponent(options) {
if(!this.style) {
for (let style in this.props.style) {
JQXLite(this.componentSelector).css(style, this.props.style[style]);
}
}
if(this.props.className !== undefined) {
let classes = this.props.className.split(' ');
for (let i = 0; i < classes.length; i++ ) {
JQXLite(this.componentSelector).addClass(classes[i]);
}
}
if(!this.template) {
JQXLite(this.componentSelector).html(this.props.template);
}
JQXLite(this.componentSelector).jqxLayout(options);
};
setOptions(options) {
JQXLite(this.componentSelector).jqxLayout('setOptions', options);
};
getOptions() {
if(arguments.length === 0) {
throw Error('At least one argument expected in getOptions()!');
}
let resultToReturn = {};
for(let i = 0; i < arguments.length; i++) {
resultToReturn[arguments[i]] = JQXLite(this.componentSelector).jqxLayout(arguments[i]);
}
return resultToReturn;
};
on(name,callbackFn) {
JQXLite(this.componentSelector).on(name,callbackFn);
};
off(name) {
JQXLite(this.componentSelector).off(name);
};
contextMenu(arg) {
if (arg !== undefined) {
JQXLite(this.componentSelector).jqxLayout('contextMenu', arg)
} else {
return JQXLite(this.componentSelector).jqxLayout('contextMenu');
}
};
height(arg) {
if (arg !== undefined) {
JQXLite(this.componentSelector).jqxLayout('height', arg)
} else {
return JQXLite(this.componentSelector).jqxLayout('height');
}
};
layout(arg) {
if (arg !== undefined) {
JQXLite(this.componentSelector).jqxLayout('layout', arg)
} else {
return JQXLite(this.componentSelector).jqxLayout('layout');
}
};
minGroupHeight(arg) {
if (arg !== undefined) {
JQXLite(this.componentSelector).jqxLayout('minGroupHeight', arg)
} else {
return JQXLite(this.componentSelector).jqxLayout('minGroupHeight');
}
};
minGroupWidth(arg) {
if (arg !== undefined) {
JQXLite(this.componentSelector).jqxLayout('minGroupWidth', arg)
} else {
return JQXLite(this.componentSelector).jqxLayout('minGroupWidth');
}
};
resizable(arg) {
if (arg !== undefined) {
JQXLite(this.componentSelector).jqxLayout('resizable', arg)
} else {
return JQXLite(this.componentSelector).jqxLayout('resizable');
}
};
rtl(arg) {
if (arg !== undefined) {
JQXLite(this.componentSelector).jqxLayout('rtl', arg)
} else {
return JQXLite(this.componentSelector).jqxLayout('rtl');
}
};
theme(arg) {
if (arg !== undefined) {
JQXLite(this.componentSelector).jqxLayout('theme', arg)
} else {
return JQXLite(this.componentSelector).jqxLayout('theme');
}
};
width(arg) {
if (arg !== undefined) {
JQXLite(this.componentSelector).jqxLayout('width', arg)
} else {
return JQXLite(this.componentSelector).jqxLayout('width');
}
};
destroy() {
JQXLite(this.componentSelector).jqxLayout('destroy');
};
loadLayout(Layout) {
JQXLite(this.componentSelector).jqxLayout('loadLayout', Layout);
};
refresh() {
JQXLite(this.componentSelector).jqxLayout('refresh');
};
performRender() {
JQXLite(this.componentSelector).jqxLayout('render');
};
saveLayout() {
return JQXLite(this.componentSelector).jqxLayout('saveLayout');
};
render() {
let id = 'jqxLayout' + JQXLite.generateID();
this.componentSelector = '#' + id;
return (
<div id={id}>{this.props.value}{this.props.children}</div>
)
};
};
|
src/react/text-filter/text_filter.js | pivotal-cf/pivotal-ui | // eslint-disable-next-line no-unused-vars
import React from 'react';
import PropTypes from 'prop-types';
import {Grid, FlexCol} from '../flex-grids';
import {Icon} from '../iconography';
export class TextFilter extends React.Component {
static propTypes = {
data: PropTypes.array.isRequired,
emptyState: PropTypes.node,
filter: PropTypes.func.isRequired,
filterPlaceholderText: PropTypes.string,
renderFilteredData: PropTypes.func.isRequired,
};
static defaultProps = {
data: [],
filter: data => data,
renderFilteredData: () => null,
filterPlaceholderText: 'Filter...'
};
constructor(props) {
super(props);
this.state = {filterText: ''};
this.onFilterTextChange = this.onFilterTextChange.bind(this);
}
componentDidMount() {
require('../../css/text-filter');
}
onFilterTextChange({target: {value}}) {
this.setState({filterText: value});
}
render() {
const {data, filter, renderFilteredData, className, filterPlaceholderText, emptyState} = this.props;
const {filterText} = this.state;
const filteredData = filter(data, filterText);
let renderBlock = renderFilteredData(filteredData);
if (filteredData.length === 0 && !!emptyState) {
renderBlock = emptyState;
}
return (
<div className="text-filter">
<Grid {...{className}}>
<FlexCol className="pan" fixed contentAlignment="middle">
<Icon src="filter_list"/>
</FlexCol>
<FlexCol className="pan">
<input placeholder={filterPlaceholderText} type="text" value={filterText} onChange={this.onFilterTextChange}/>
</FlexCol>
<FlexCol className="pan text-filter-counts" fixed alignment="middle">
<span className="filtered-count">{filteredData.length}
</span> / <span className="unfiltered-count">{data.length}</span>
</FlexCol>
</Grid>
{renderBlock}
</div>
);
}
} |
client/src/js/components/LoginPage.js | muhammad-saleh/weightlyio | "use strict";
import React from 'react';
class LoginPage extends React.Component {
componentDidMount(){
var lock = new Auth0Lock('Ak0xmdNNIZNUbwtOYUVt1Y7wKPgPGra5', 'msaleh.auth0.com');
lock.show({
container: 'LoginBox'
});
}
showLock() {
// We receive lock from the parent component in this case
// If you instantiate it in this component, just do this.lock.show()
this.props.lock.show();
}
render() {
return (<div id="LoginBox"></div>)
}
}
LoginPage.path = '/login';
export default LoginPage
|
examples/todo/js/components/TodoListFooter.js | SBUtltmedia/relay | /**
* This file provided by Facebook is for non-commercial testing and evaluation
* purposes only. Facebook reserves all rights not expressly granted.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
import {IndexLink, Link} from 'react-router';
import RemoveCompletedTodosMutation from '../mutations/RemoveCompletedTodosMutation';
import React from 'react';
import Relay from 'react-relay';
class TodoListFooter extends React.Component {
_handleRemoveCompletedTodosClick = () => {
Relay.Store.commitUpdate(
new RemoveCompletedTodosMutation({
todos: this.props.viewer.todos,
viewer: this.props.viewer,
})
);
}
render() {
var numCompletedTodos = this.props.viewer.completedCount;
var numRemainingTodos = this.props.viewer.totalCount - numCompletedTodos;
return (
<footer className="footer">
<span className="todo-count">
<strong>{numRemainingTodos}</strong> item{numRemainingTodos === 1 ? '' : 's'} left
</span>
<ul className="filters">
<li>
<IndexLink to="/" activeClassName="selected">All</IndexLink>
</li>
<li>
<Link to="/active" activeClassName="selected">Active</Link>
</li>
<li>
<Link to="/completed" activeClassName="selected">Completed</Link>
</li>
</ul>
{numCompletedTodos > 0 &&
<button
className="clear-completed"
onClick={this._handleRemoveCompletedTodosClick}>
Clear completed
</button>
}
</footer>
);
}
}
export default Relay.createContainer(TodoListFooter, {
prepareVariables() {
return {
limit: Number.MAX_SAFE_INTEGER || 9007199254740991,
};
},
fragments: {
viewer: () => Relay.QL`
fragment on User {
completedCount,
todos(status: "completed", first: $limit) {
${RemoveCompletedTodosMutation.getFragment('todos')},
},
totalCount,
${RemoveCompletedTodosMutation.getFragment('viewer')},
}
`,
},
});
|
Paths/React/05.Building Scalable React Apps/7-react-boilerplate-building-scalable-apps-m7-exercise-files/After/app/containers/NotFoundPage/index.js | phiratio/Pluralsight-materials | /**
* NotFoundPage
*
* This is the page we show when the user visits a url that doesn't have a route
*
* NOTE: while this component should technically be a stateless functional
* component (SFC), hot reloading does not currently support SFCs. If hot
* reloading is not a neccessity for you then you can refactor it and remove
* the linting exception.
*/
import React from 'react';
import { FormattedMessage } from 'react-intl';
import messages from './messages';
export default class NotFound extends React.Component { // eslint-disable-line react/prefer-stateless-function
render() {
return (
<h1>
<FormattedMessage {...messages.header} />
</h1>
);
}
}
|
fixtures/fiber-debugger/src/Fibers.js | roth1002/react | import React from 'react';
import {Motion, spring} from 'react-motion';
import dagre from 'dagre';
// import prettyFormat from 'pretty-format';
// import reactElement from 'pretty-format/plugins/ReactElement';
function getFiberColor(fibers, id) {
if (fibers.currentIDs.indexOf(id) > -1) {
return 'lightgreen';
}
if (id === fibers.workInProgressID) {
return 'yellow';
}
return 'lightyellow';
}
function Graph(props) {
const {rankdir, trackActive} = props.settings;
var g = new dagre.graphlib.Graph();
g.setGraph({
width: 1000,
height: 1000,
nodesep: 50,
edgesep: 150,
ranksep: 100,
marginx: 100,
marginy: 100,
rankdir,
});
var edgeLabels = {};
React.Children.forEach(props.children, function(child) {
if (!child) {
return;
}
if (child.type.isVertex) {
g.setNode(child.key, {
label: child,
width: child.props.width,
height: child.props.height,
});
} else if (child.type.isEdge) {
const relationshipKey = child.props.source + ':' + child.props.target;
if (!edgeLabels[relationshipKey]) {
edgeLabels[relationshipKey] = [];
}
edgeLabels[relationshipKey].push(child);
}
});
Object.keys(edgeLabels).forEach(key => {
const children = edgeLabels[key];
const child = children[0];
g.setEdge(child.props.source, child.props.target, {
label: child,
allChildren: children.map(c => c.props.children),
weight: child.props.weight,
});
});
dagre.layout(g);
var activeNode = g
.nodes()
.map(v => g.node(v))
.find(node => node.label.props.isActive);
const [winX, winY] = [window.innerWidth / 2, window.innerHeight / 2];
var focusDx = trackActive && activeNode ? winX - activeNode.x : 0;
var focusDy = trackActive && activeNode ? winY - activeNode.y : 0;
var nodes = g.nodes().map(v => {
var node = g.node(v);
return (
<Motion
style={{
x: props.isDragging ? node.x + focusDx : spring(node.x + focusDx),
y: props.isDragging ? node.y + focusDy : spring(node.y + focusDy),
}}
key={node.label.key}>
{interpolatingStyle =>
React.cloneElement(node.label, {
x: interpolatingStyle.x + props.dx,
y: interpolatingStyle.y + props.dy,
vanillaX: node.x,
vanillaY: node.y,
})
}
</Motion>
);
});
var edges = g.edges().map(e => {
var edge = g.edge(e);
let idx = 0;
return (
<Motion
style={edge.points.reduce((bag, point) => {
bag[idx + ':x'] = props.isDragging
? point.x + focusDx
: spring(point.x + focusDx);
bag[idx + ':y'] = props.isDragging
? point.y + focusDy
: spring(point.y + focusDy);
idx++;
return bag;
}, {})}
key={edge.label.key}>
{interpolatedStyle => {
let points = [];
Object.keys(interpolatedStyle).forEach(key => {
const [idx, prop] = key.split(':');
if (!points[idx]) {
points[idx] = {x: props.dx, y: props.dy};
}
points[idx][prop] += interpolatedStyle[key];
});
return React.cloneElement(edge.label, {
points,
id: edge.label.key,
children: edge.allChildren.join(', '),
});
}}
</Motion>
);
});
return (
<div
style={{
position: 'relative',
height: '100%',
}}>
{edges}
{nodes}
</div>
);
}
function Vertex(props) {
if (Number.isNaN(props.x) || Number.isNaN(props.y)) {
return null;
}
return (
<div
style={{
position: 'absolute',
border: '1px solid black',
left: props.x - props.width / 2,
top: props.y - props.height / 2,
width: props.width,
height: props.height,
overflow: 'hidden',
padding: '4px',
wordWrap: 'break-word',
}}>
{props.children}
</div>
);
}
Vertex.isVertex = true;
const strokes = {
alt: 'blue',
child: 'green',
sibling: 'darkgreen',
return: 'red',
fx: 'purple',
};
function Edge(props) {
var points = props.points;
var path = 'M' + points[0].x + ' ' + points[0].y + ' ';
if (!points[0].x || !points[0].y) {
return null;
}
for (var i = 1; i < points.length; i++) {
path += 'L' + points[i].x + ' ' + points[i].y + ' ';
if (!points[i].x || !points[i].y) {
return null;
}
}
var lineID = props.id;
return (
<svg
width="100%"
height="100%"
style={{
position: 'absolute',
left: 0,
right: 0,
top: 0,
bottom: 0,
}}>
<defs>
<path d={path} id={lineID} />
<marker
id="markerCircle"
markerWidth="8"
markerHeight="8"
refX="5"
refY="5">
<circle cx="5" cy="5" r="3" style={{stroke: 'none', fill: 'black'}} />
</marker>
<marker
id="markerArrow"
markerWidth="13"
markerHeight="13"
refX="2"
refY="6"
orient="auto">
<path d="M2,2 L2,11 L10,6 L2,2" style={{fill: 'black'}} />
</marker>
</defs>
<use
xlinkHref={`#${lineID}`}
fill="none"
stroke={strokes[props.kind]}
style={{
markerStart: 'url(#markerCircle)',
markerEnd: 'url(#markerArrow)',
}}
/>
<text>
<textPath xlinkHref={`#${lineID}`}>
{' '}
{props.children}
</textPath>
</text>
</svg>
);
}
Edge.isEdge = true;
function formatPriority(priority) {
switch (priority) {
case 1:
return 'synchronous';
case 2:
return 'task';
case 3:
return 'hi-pri work';
case 4:
return 'lo-pri work';
case 5:
return 'offscreen work';
default:
throw new Error('Unknown priority.');
}
}
export default function Fibers({fibers, show, graphSettings, ...rest}) {
const items = Object.keys(fibers.descriptions).map(
id => fibers.descriptions[id]
);
const isDragging = rest.className.indexOf('dragging') > -1;
const [_, sdx, sdy] =
rest.style.transform.match(/translate\((-?\d+)px,(-?\d+)px\)/) || [];
const dx = Number(sdx);
const dy = Number(sdy);
return (
<div
{...rest}
style={{
width: '100%',
height: '100%',
position: 'absolute',
top: 0,
left: 0,
...rest.style,
transform: null,
}}>
<Graph
className="graph"
dx={dx}
dy={dy}
isDragging={isDragging}
settings={graphSettings}>
{items.map(fiber => [
<Vertex
key={fiber.id}
width={150}
height={100}
isActive={fiber.id === fibers.workInProgressID}>
<div
style={{
width: '100%',
height: '100%',
backgroundColor: getFiberColor(fibers, fiber.id),
}}
title={
/*prettyFormat(fiber, { plugins: [reactElement ]})*/
'todo: this was hanging last time I tried to pretty print'
}>
<small>
{fiber.tag} #{fiber.id}
</small>
<br />
{fiber.type}
<br />
{fibers.currentIDs.indexOf(fiber.id) === -1 ? (
<small>
{fiber.pendingWorkPriority !== 0 && [
<span key="span">
Needs: {formatPriority(fiber.pendingWorkPriority)}
</span>,
<br key="br" />,
]}
{fiber.memoizedProps !== null &&
fiber.pendingProps !== null && [
fiber.memoizedProps === fiber.pendingProps
? 'Can reuse memoized.'
: 'Cannot reuse memoized.',
<br key="br" />,
]}
</small>
) : (
<small>Committed</small>
)}
{fiber.effectTag && [
<br key="br" />,
<small key="small">Effect: {fiber.effectTag}</small>,
]}
</div>
</Vertex>,
fiber.child &&
show.child && (
<Edge
source={fiber.id}
target={fiber.child}
kind="child"
weight={1000}
key={`${fiber.id}-${fiber.child}-child`}>
child
</Edge>
),
fiber.sibling &&
show.sibling && (
<Edge
source={fiber.id}
target={fiber.sibling}
kind="sibling"
weight={2000}
key={`${fiber.id}-${fiber.sibling}-sibling`}>
sibling
</Edge>
),
fiber.return &&
show.return && (
<Edge
source={fiber.id}
target={fiber.return}
kind="return"
weight={1000}
key={`${fiber.id}-${fiber.return}-return`}>
return
</Edge>
),
fiber.nextEffect &&
show.fx && (
<Edge
source={fiber.id}
target={fiber.nextEffect}
kind="fx"
weight={100}
key={`${fiber.id}-${fiber.nextEffect}-nextEffect`}>
nextFx
</Edge>
),
fiber.firstEffect &&
show.fx && (
<Edge
source={fiber.id}
target={fiber.firstEffect}
kind="fx"
weight={100}
key={`${fiber.id}-${fiber.firstEffect}-firstEffect`}>
firstFx
</Edge>
),
fiber.lastEffect &&
show.fx && (
<Edge
source={fiber.id}
target={fiber.lastEffect}
kind="fx"
weight={100}
key={`${fiber.id}-${fiber.lastEffect}-lastEffect`}>
lastFx
</Edge>
),
fiber.alternate &&
show.alt && (
<Edge
source={fiber.id}
target={fiber.alternate}
kind="alt"
weight={10}
key={`${fiber.id}-${fiber.alternate}-alt`}>
alt
</Edge>
),
])}
</Graph>
</div>
);
}
|
fields/types/location/LocationFilter.js | trentmillar/keystone | import React from 'react';
import { findDOMNode } from 'react-dom';
import {
FormField,
FormInput,
Grid,
SegmentedControl,
} from '../../../admin/client/App/elemental';
const INVERTED_OPTIONS = [
{ label: 'Matches', value: false },
{ label: 'Does NOT Match', value: true },
];
function getDefaultValue () {
return {
inverted: INVERTED_OPTIONS[0].value,
street: undefined,
city: undefined,
state: undefined,
code: undefined,
country: undefined,
};
}
var TextFilter = React.createClass({
propTypes: {
filter: React.PropTypes.shape({
inverted: React.PropTypes.boolean,
street: React.PropTypes.string,
city: React.PropTypes.string,
state: React.PropTypes.string,
code: React.PropTypes.string,
country: React.PropTypes.string,
}),
},
statics: {
getDefaultValue: getDefaultValue,
},
getDefaultProps () {
return {
filter: getDefaultValue(),
};
},
updateFilter (key, val) {
const update = {};
update[key] = val;
this.props.onChange(Object.assign(this.props.filter, update));
},
toggleInverted (value) {
this.updateFilter('inverted', value);
findDOMNode(this.refs.focusTarget).focus();
},
updateValue (e) {
this.updateFilter(e.target.name, e.target.value);
},
render () {
const { filter } = this.props;
return (
<div>
<FormField>
<SegmentedControl
equalWidthSegments
onChange={this.toggleInverted}
options={INVERTED_OPTIONS}
value={filter.inverted}
/>
</FormField>
<FormField>
<FormInput
autoFocus
name="street"
onChange={this.updateValue}
placeholder="Address"
ref="focusTarget"
value={filter.street}
/>
</FormField>
<Grid.Row gutter={10}>
<Grid.Col xsmall="two-thirds">
<FormInput
name="city"
onChange={this.updateValue}
placeholder="City"
style={{ marginBottom: '1em' }}
value={filter.city}
/>
</Grid.Col>
<Grid.Col xsmall="one-third">
<FormInput
name="state"
onChange={this.updateValue}
placeholder="State"
style={{ marginBottom: '1em' }}
value={filter.state}
/>
</Grid.Col>
<Grid.Col xsmall="one-third" style={{ marginBottom: 0 }}>
<FormInput
name="code"
onChange={this.updateValue}
placeholder="Postcode"
value={filter.code}
/>
</Grid.Col>
<Grid.Col xsmall="two-thirds" style={{ marginBottom: 0 }}>
<FormInput
name="country"
onChange={this.updateValue}
placeholder="Country"
value={filter.country}
/>
</Grid.Col>
</Grid.Row>
</div>
);
},
});
module.exports = TextFilter;
|
src/js/components/GamesTable.js | bcongdon/sgdq-stats | import React from 'react'
import Stat from './Stat'
import { connect } from 'react-redux'
import { PropTypes } from 'prop-types'
import Col from 'react-bootstrap/lib/Col'
import Row from 'react-bootstrap/lib/Row'
import Grid from 'react-bootstrap/lib/Grid'
import OverlayTrigger from 'react-bootstrap/lib/OverlayTrigger'
import Tooltip from 'react-bootstrap/lib/Tooltip'
import { gameEndTime, gameForId } from '../utils'
import IconLink from './IconLink'
import { toggleNotificationGame, notifyGame } from '../actions'
import ReactDOM from 'react-dom'
import dayjs from 'dayjs'
class GamesTable extends React.Component {
static propTypes = {
schedule: PropTypes.array.isRequired,
notificationGames: PropTypes.array,
toggleNotificationGame: PropTypes.func,
notifyGame: PropTypes.func
}
constructor (props) {
super(props)
this.rows = []
this.initialScroll = false
}
getHeader () {
return (
<Row className='games-list-head'>
<Col sm={4} xs={5}>Title</Col>
<Col sm={3} xsHidden>Runner</Col>
<Col sm={3} xs={4}>Starting Time</Col>
<Col sm={2} xs={3}>Duration</Col>
</Row>
)
}
toRow (game, key) {
const { id, name, runners, startTime, duration } = game
const notificationActive = this.props.notificationGames.includes(id)
const notificationIcon = (
<IconLink
icon='glyphicon glyphicon-bell'
active={notificationActive}
onClick={() => this.props.toggleNotificationGame(id)} />
)
const notificationTooltip = (
<Tooltip
id='notification-tooltip'
style={{color: 'red'}}>
Click to be notified right before<br />'<b>{game.name}</b>'<br /> starts!
</Tooltip>
)
const tooltipAppliedNotification = notificationActive ? notificationIcon : (
<OverlayTrigger placement='top' overlay={notificationTooltip}>
{notificationIcon}
</OverlayTrigger>
)
let status
if (gameEndTime(game).isBefore(dayjs())) {
status = '✓'
} else if (game.startTime.isBefore(dayjs())) {
status = '🎮'
} else {
status = tooltipAppliedNotification
}
const statusNode = <span className='hidden-xs game-table-status'>{status}</span>
const row = (
<Row className='game-list-row' key={key} ref={(e) => { this.rows[key] = e }}>
<Col sm={4} xs={5}>{name}</Col>
<Col sm={3} xsHidden>{runners}</Col>
<Col sm={3} xs={4}>{startTime.format('MMM D, h:mma')} {statusNode}</Col>
<Col sm={2} xs={3}>{duration}</Col>
</Row>
)
return row
}
getRows () {
return this.props.schedule.map((game, idx) => {
return this.toRow(game, idx)
})
}
getGamesCompleted () {
return this.props.schedule.filter((g) => gameEndTime(g).isBefore(dayjs())).length
}
getActiveGame () {
for (let i = 0; i < this.props.schedule.length; i++) {
const game = this.props.schedule[i]
if (game.startTime.isAfter(dayjs())) {
return i - 1
}
}
return 0
}
render () {
const table = (
<div className='section'>
<h2>Games</h2>
<div className='table-content'>
<div id='game-list'>
<Grid id='gamesTable'>
{this.getHeader()}
<div className='games-list-body' ref={(e) => { this.body = e }}>
{this.getRows()}
</div>
</Grid>
</div>
</div>
<div className='current_stats container' style={{padding: 5}}>
<Stat title='Games Completed' emoji='🎮' value={this.getGamesCompleted()} />
</div>
</div>
)
return table
}
componentDidUpdate () {
const activeRow = ReactDOM.findDOMNode(this.rows[this.getActiveGame()])
if (activeRow && !this.initialScroll) {
this.initialScroll = true
this.body.scrollTop = activeRow.offsetTop - this.body.offsetTop
}
}
componentWillMount () {
const checkNotifications = () => {
this.props.notificationGames.map((id) => {
const game = gameForId(id, this.props.schedule)
if (!game) {
return
}
// Notify if game starts within 5 minutes
if (game.startTime.clone().subtract(5, 'minutes').isBefore(dayjs())) {
this.props.notifyGame(id)
}
})
// Force update to catch when a game change occurs
this.forceUpdate()
}
checkNotifications()
setInterval(checkNotifications, 5 * 1000)
}
}
function mapPropsToState (state) {
return {
schedule: state.gdq.schedule,
notificationGames: state.gdq.notificationGames
}
}
export default connect(mapPropsToState, { toggleNotificationGame, notifyGame })(GamesTable)
|
www/components/Navbar/index.js | andrewlinfoot/keystone | import React, { Component } from 'react';
import Link from 'gatsby-link';
// import GithubIcon from 'react-icons/lib/go/mark-github';
import MenuClose from 'react-icons/lib/md/close';
import MenuIcon from 'react-icons/lib/md/menu';
// import TwitterIcon from 'react-icons/lib/ti/social-twitter';
import typography from '../../utils/typography';
import invertedLogo from '../../images/logo-inverted.svg';
import theme from '../../theme';
import { itemsShape } from './utils';
import Menu from './Menu';
import { api, documentation, gettingStarted, guides } from '../../data/navigation';
const sections = [gettingStarted, guides, documentation, api];
console.table(sections);
class Navbar extends Component {
constructor (props) {
super(props);
this.toggleNavMenu = this.toggleNavMenu.bind(this);
this.state = { menuIsOpen: false };
}
toggleNavMenu (menuIsOpen) {
this.setState({ menuIsOpen });
}
render () {
const { menuIsOpen } = this.state;
return (
<aside css={styles.navbar}>
<div css={styles.header}>
<Link to="/" css={styles.brand}>
<img
src={invertedLogo}
css={styles.brandIcon}
/>
</Link>
<div css={styles.github}>
<a href="https://github.com/keystonejs" target="_blank" css={[styles.github__link, styles.github__org]}>KeystoneJS</a>
<span css={styles.github__divider}>/</span>
<a href="https://github.com/keystonejs/keystone" target="_blank" css={[styles.github__link, styles.github__repo]}>Keystone</a>
</div>
{/* <div css={styles.header__links}>
<a href="https://twitter.com/keystonejs" target="_blank" css={styles.header__link}>
<TwitterIcon css={styles.header__linkIcon} />
Twitter
</a>
<a href="https://github.com/keystonejs/keystone" target="_blank" css={styles.header__link}>
<GithubIcon css={styles.header__linkIcon} />
GitHub
</a>
</div> */}
<div css={styles.nav}>
{sections.map(s => (
<Link key={s.slug} to={s.slug} css={styles.navitem}>
{s.section}
</Link>
))}
</div>
<button onClick={() => this.toggleNavMenu(!menuIsOpen)} css={styles.menuButton}>
{menuIsOpen
? <MenuClose css={styles.menuIcon} />
: <MenuIcon css={styles.menuIcon} />}
</button>
</div>
<div css={[styles.menu, menuIsOpen && styles.menu__open]}>
<Menu items={this.props.items} />
</div>
</aside>
);
};
};
Navbar.propTypes = {
items: itemsShape.isRequired,
};
const mobileHeaderHeight = 60;
/* eslint quote-props: ["error", "as-needed"] */
const styles = {
navbar: {
backgroundColor: theme.color.blue,
backgroundImage: 'linear-gradient(160deg, #34b6d9, #3464d9)',
color: 'white',
fontSize: '0.9em',
letterSpacing: '0.01em',
lineHeight: typography.options.baseLineHeight,
position: 'relative',
width: '100%',
zIndex: 1,
[theme.breakpoint.largeUp]: {
bottom: 0,
height: '100%',
left: 0,
overflowY: 'auto',
paddingBottom: '3em',
position: 'fixed',
top: 0,
width: theme.navbar.widthSmall,
},
[theme.breakpoint.xlargeUp]: {
width: theme.navbar.widthLarge,
},
},
// nav
nav: {
display: 'flex',
fontWeight: 'normal',
lineHeight: 1.1,
[theme.breakpoint.mediumDown]: {
flex: '1 1 auto',
},
[theme.breakpoint.largeUp]: {
backgroundColor: 'white',
borderRadius: 4,
boxShadow: '0 2px 1px rgba(0, 0, 0, 0.2)',
marginLeft: '1rem',
marginRight: '1rem',
},
},
navitem: {
alignItems: 'center',
display: 'flex',
flex: '1 0 auto',
justifyContent: 'center',
paddingBottom: '0.5rem',
paddingTop: '0.5rem',
textDecoration: 'none',
[theme.breakpoint.mediumDown]: {
color: 'white',
},
[theme.breakpoint.largeUp]: {
color: theme.color.blue,
':not(:first-child)': {
boxShadow: '-1px 0 0 rgba(0, 0, 0, 0.1)',
},
},
},
// header
header: {
[theme.breakpoint.mediumDown]: {
alignItems: 'center',
borderBottom: `1px solid rgba(0, 0, 0, 0.1)`,
display: 'flex',
height: mobileHeaderHeight,
justifyContent: 'space-between',
paddingLeft: '1em',
paddingRight: '1em',
},
},
// brand
brand: {
// alignItems: 'space-between',
// display: 'flex',
// flexDirection: 'column',
// justifyContent: 'center',
display: 'block',
textAlign: 'center',
textDecoration: 'none',
[theme.breakpoint.largeUp]: {
padding: '2em 0 0',
},
},
brandIcon: {
height: 50,
margin: 0,
[theme.breakpoint.mediumDown]: {
height: 30,
},
},
brandLabel: {
color: 'white',
display: 'none',
[theme.breakpoint.largeUp]: {
display: 'block',
},
},
github: {
display: 'flex',
justifyContent: 'center',
marginBottom: '1em',
[theme.breakpoint.mediumDown]: {
visibility: 'hidden',
position: 'absolute',
height: 1,
width: 1,
},
},
github__link: {
color: 'white',
padding: '0.5em',
textDecoration: 'none',
':hover': {
textDecoration: 'underline',
},
},
github__org: {
opacity: 0.75,
},
github__divider: {
color: 'white',
opacity: 0.75,
paddingBottom: '0.5em',
paddingTop: '0.5em',
},
github__repo: {},
// mobile
menu: {
[theme.breakpoint.mediumDown]: {
backgroundColor: theme.color.blue,
boxShadow: '0 -1px 0 rgba(255, 255, 255, 0.4)',
display: 'none',
position: 'absolute',
top: mobileHeaderHeight,
width: '100%',
},
},
menu__open: {
[theme.breakpoint.mediumDown]: {
display: 'block',
},
},
menuButton: {
background: 'none',
border: 0,
color: 'white',
display: 'none',
fontSize: 32,
lineHeight: 0,
outline: 0,
padding: 0,
[theme.breakpoint.mediumDown]: {
display: 'inline-block',
},
},
menuIcon: {},
};
export default Navbar;
|
src/routes.js | codenamekt/reactive-boiler | import React from 'react';
import { Route, IndexRoute } from 'react-router';
import App from './components/App';
import HomePage from './components/HomePage';
import FuelSavingsPage from './containers/FuelSavingsPage'; // eslint-disable-line import/no-named-as-default
import AboutPage from './components/AboutPage.js';
import NotFoundPage from './components/NotFoundPage.js';
export default (
<Route path="/" component={App}>
<IndexRoute component={HomePage}/>
<Route path="fuel-savings" component={FuelSavingsPage}/>
<Route path="about" component={AboutPage}/>
<Route path="*" component={NotFoundPage}/>
</Route>
);
|
fields/types/url/UrlColumn.js | Tangcuyu/keystone | import React from 'react';
import ItemsTableCell from '../../../admin/client/components/ItemsTable/ItemsTableCell';
import ItemsTableValue from '../../../admin/client/components/ItemsTable/ItemsTableValue';
var UrlColumn = React.createClass({
displayName: 'UrlColumn',
propTypes: {
col: React.PropTypes.object,
data: React.PropTypes.object,
},
renderValue () {
var value = this.props.data.fields[this.props.col.path];
if (!value) return;
// if the value doesn't start with a prototcol, assume http for the href
var href = value;
if (href && !/^(mailto\:)|(\w+\:\/\/)/.test(href)) {
href = 'http://' + value;
}
// strip the protocol from the link if it's http(s)
var label = value.replace(/^https?\:\/\//i, '');
return (
<ItemsTableValue href={href} padded exterior field={this.props.col.type}>
{label}
</ItemsTableValue>
);
},
render () {
const value = this.props.data.fields[this.props.col.path];
return (
<ItemsTableCell>
{this.renderValue()}
</ItemsTableCell>
);
},
});
module.exports = UrlColumn;
|
docs/components/Docs/index.js | jribeiro/storybook | import React from 'react';
import PropTypes from 'prop-types';
import Helmet from 'react-helmet';
import Header from '../Header';
import Container from './Container';
import Footer from '../Footer';
import './style.css';
const Docs = ({ sections, selectedItem, selectedSectionId, selectedItemId }) =>
<div className="container">
<Helmet title={`${selectedItem.title}`} />
<Header currentSection="docs" />
<Container
sections={sections}
selectedItem={selectedItem}
selectedSectionId={selectedSectionId}
selectedItemId={selectedItemId}
/>
<Footer />
</div>;
Docs.propTypes = {
sections: PropTypes.array, // eslint-disable-line
selectedItem: PropTypes.object, // eslint-disable-line
selectedSectionId: PropTypes.string.isRequired,
selectedItemId: PropTypes.string.isRequired,
};
export default Docs;
|
examples/dynamic-segments/app.js | rdjpalmer/react-router | import React from 'react'
import { render } from 'react-dom'
import { browserHistory, Router, Route, Link, Redirect } from 'react-router'
class App extends React.Component {
render() {
return (
<div>
<ul>
<li><Link to="/user/123" activeClassName="active">Bob</Link></li>
<li><Link to="/user/abc" activeClassName="active">Sally</Link></li>
</ul>
{this.props.children}
</div>
)
}
}
class User extends React.Component {
render() {
const { userID } = this.props.params
return (
<div className="User">
<h1>User id: {userID}</h1>
<ul>
<li><Link to={`/user/${userID}/tasks/foo`} activeClassName="active">foo task</Link></li>
<li><Link to={`/user/${userID}/tasks/bar`} activeClassName="active">bar task</Link></li>
</ul>
{this.props.children}
</div>
)
}
}
class Task extends React.Component {
render() {
const { userID, taskID } = this.props.params
return (
<div className="Task">
<h2>User ID: {userID}</h2>
<h3>Task ID: {taskID}</h3>
</div>
)
}
}
render((
<Router history={browserHistory}>
<Route path="/" component={App}>
<Route path="user/:userID" component={User}>
<Route path="tasks/:taskID" component={Task} />
<Redirect from="todos/:taskID" to="tasks/:taskID" />
</Route>
</Route>
</Router>
), document.getElementById('example'))
|
src/svg-icons/editor/insert-invitation.js | ichiohta/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let EditorInsertInvitation = (props) => (
<SvgIcon {...props}>
<path d="M17 12h-5v5h5v-5zM16 1v2H8V1H6v2H5c-1.11 0-1.99.9-1.99 2L3 19c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2h-1V1h-2zm3 18H5V8h14v11z"/>
</SvgIcon>
);
EditorInsertInvitation = pure(EditorInsertInvitation);
EditorInsertInvitation.displayName = 'EditorInsertInvitation';
EditorInsertInvitation.muiName = 'SvgIcon';
export default EditorInsertInvitation;
|
src/components/Checkbox/index.js | TF2PickupNET/components | // @flow strict-local
import React from 'react';
import PropTypes from 'prop-types';
import getNotDeclaredProps from 'react-get-not-declared-props';
import CheckboxBlankOutlineIcon from 'mdi-react/CheckboxBlankOutlineIcon';
import CheckboxMarkedIcon from 'mdi-react/CheckboxMarkedIcon';
import Ripple from '../Ripple';
import Icon from '../Icon';
import {
ENTER,
SPACE_BAR,
} from '../../utils/constants';
import Sheet, { type Data } from './Sheet';
type Props = {
checked: boolean,
onChange: () => void,
disabled: boolean,
className: string,
color: 'primary' | 'accent',
};
type State = { isFocused: boolean };
export default class Checkbox extends React.PureComponent<Props, State> {
static propTypes = {
checked: PropTypes.bool.isRequired,
onChange: PropTypes.func.isRequired,
disabled: PropTypes.bool,
className: PropTypes.string,
color: PropTypes.oneOf(['primary', 'accent']),
};
static defaultProps = {
disabled: false,
className: '',
color: 'primary',
};
state = { isFocused: false };
handleFocus = () => {
this.setState({ isFocused: true });
};
handleBlur = () => {
this.setState({ isFocused: false });
};
handleKeyUp = (ev: SyntheticKeyboardEvent<HTMLSpanElement>) => {
if (ev.keyCode === SPACE_BAR || ev.keyCode === ENTER) {
this.props.onChange();
}
};
/**
* Support for the label click.
*/
handleClick = (ev: SyntheticKeyboardEvent<HTMLSpanElement>) => {
if (ev.target === ev.currentTarget) {
this.props.onChange();
}
};
render() {
const data: Data = {
disabled: this.props.disabled,
checked: this.props.checked,
color: this.props.color,
};
return (
<Sheet data={data}>
{({ classes }) => (
<span
{...getNotDeclaredProps(this.props, Checkbox)}
role="checkbox"
tabIndex={this.props.disabled ? -1 : 0}
aria-disabled={this.props.disabled}
aria-checked={this.props.checked}
className={`${classes.checkbox} ${this.props.className}`}
onKeyUp={this.handleKeyUp}
onFocus={this.handleFocus}
onBlur={this.handleBlur}
onClick={this.handleClick}
>
<Icon
size={24}
className={classes.icon}
>
{this.props.checked ? <CheckboxMarkedIcon /> : <CheckboxBlankOutlineIcon />}
</Icon>
<Ripple
round
center
isFocused={this.state.isFocused}
onPress={this.props.onChange}
/>
</span>
)}
</Sheet>
);
}
}
|
packages/veritone-widgets/src/widgets/EngineSelection/EngineListView/index.js | veritone/veritone-sdk | import React from 'react';
import { connect } from 'react-redux';
import {
bool,
func,
objectOf,
object,
arrayOf,
string,
shape,
any
} from 'prop-types';
import { isEmpty, debounce } from 'lodash';
import Tabs from '@material-ui/core/Tabs';
import Tab from '@material-ui/core/Tab';
import Button from '@material-ui/core/Button';
import { withStyles } from '@material-ui/styles'
import { modules } from 'veritone-redux-common';
const { engine: engineModule } = modules;
import SelectBar from './SelectBar/';
import EnginesSideBar from './SideBar';
import SelectedActionBar from './SelectedActionBar/';
import EngineListContainer from './EngineListContainer';
import * as engineSelectionModule from '../../../redux/modules/engineSelection';
import styles from './styles';
@withStyles(styles)
@connect(
(state, { id }) => ({
currentResults: engineSelectionModule.getCurrentResults(state, id),
allEnginesChecked: engineSelectionModule.allEnginesChecked(state, id),
checkedEngineIds: engineSelectionModule.getCheckedEngineIds(state, id),
isFetchingEngines: engineModule.isFetchingEngines(state, id),
failedToFetchEngines: engineModule.failedToFetchEngines(state, id),
searchQuery: engineSelectionModule.getSearchQuery(state, id),
currentTab: engineSelectionModule.getCurrentTab(state, id),
isSearchOpen: engineSelectionModule.isSearchOpen(state, id)
}),
{
selectEngines: engineSelectionModule.selectEngines,
deselectEngines: engineSelectionModule.deselectEngines,
searchEngines: engineSelectionModule.searchEngines,
checkAllEngines: engineSelectionModule.checkAllEngines,
uncheckAllEngines: engineSelectionModule.uncheckAllEngines,
clearSearch: engineSelectionModule.clearSearch,
changeTab: engineSelectionModule.changeTab,
toggleSearch: engineSelectionModule.toggleSearch
}
)
export default class EngineListView extends React.Component {
static propTypes = {
id: string.isRequired,
allEngines: objectOf(object),
currentResults: arrayOf(string),
allEnginesChecked: bool.isRequired,
selectedEngineIds: arrayOf(string).isRequired,
checkedEngineIds: arrayOf(string).isRequired,
initialSelectedEngineIds: arrayOf(string),
onViewDetail: func.isRequired,
searchQuery: string,
isFetchingEngines: bool.isRequired,
failedToFetchEngines: bool.isRequired,
currentTab: string.isRequired,
isSearchOpen: bool.isRequired,
selectEngines: func.isRequired,
deselectEngines: func.isRequired,
searchEngines: func.isRequired,
checkAllEngines: func.isRequired,
uncheckAllEngines: func.isRequired,
clearSearch: func.isRequired,
changeTab: func.isRequired,
toggleSearch: func.isRequired,
onSave: func.isRequired,
onCancel: func.isRequired,
actionMenuItems: arrayOf(
shape({
buttonText: string,
iconClass: string,
onClick: func.isRequired
})
),
hideActions: bool,
classes: shape({ any }),
};
static defaultProps = {
currentResults: []
};
state = {};
componentDidUpdate(prevProps, prevState, snapshot) {
if (
isEmpty(prevProps.allEngines) &&
!isEmpty(this.props.allEngines) &&
this.props.initialSelectedEngineIds
) {
this.props.selectEngines(
this.props.id,
this.props.initialSelectedEngineIds
);
}
}
handleCheckAll = () => {
const enginesToCheck =
this.props.currentTab === 'explore'
? this.props.currentResults
: this.props.selectedEngineIds;
this.props.allEnginesChecked
? this.props.uncheckAllEngines(this.props.id)
: this.props.checkAllEngines(this.props.id, enginesToCheck);
};
handleSearch = debounce(
name => this.props.searchEngines(this.props.id, { name }),
300
);
handleTabChange = (event, tab) => {
this.props.changeTab(this.props.id, tab);
};
handleSave = () => {
this.props.onSave();
};
handleOnBack = () => {
this.props.uncheckAllEngines(this.props.id);
};
render() {
const { checkedEngineIds, currentTab, classes } = this.props;
return (
<div className={classes.engineSelection}>
<EnginesSideBar id={this.props.id} />
<div className={classes.engineSelectionContent}>
{!isEmpty(checkedEngineIds) && (
<SelectedActionBar
id={this.props.id}
selectedEngines={checkedEngineIds}
disabledSelectAllMessage={currentTab === 'own'}
currentResultsCount={this.props.currentResults.length}
onBack={this.handleOnBack}
onAddSelected={this.props.selectEngines}
onRemoveSelected={this.props.deselectEngines}
onSelectAll={this.props.checkAllEngines}
allEngines={Object.keys(this.props.allEngines)}
/>
)}
{isEmpty(checkedEngineIds) && (
<Tabs
className={classes.tabs}
value={this.props.currentTab}
onChange={this.handleTabChange}
indicatorColor="primary"
textColor="primary"
variant="fullWidth"
>
<Tab
classes={{ selected: classes.tab }}
value="own"
label={`Your Engines (${this.props.selectedEngineIds.length})`}
/>
<Tab
classes={{ selected: classes.tab }}
value="explore"
label="Explore All Engines"
/>
</Tabs>
)}
<div className={classes.engineListContainer}>
{!this.props.failedToFetchEngines && (
<SelectBar
id={this.props.id}
onCheckAll={this.handleCheckAll}
searchQuery={this.props.searchQuery}
onSearch={this.handleSearch}
onClearSearch={this.props.clearSearch}
onToggleSearch={this.props.toggleSearch}
isSearchOpen={this.props.isSearchOpen}
isChecked={this.props.allEnginesChecked}
actionMenuItems={this.props.actionMenuItems}
currentTab={currentTab}
count={
currentTab === 'explore'
? this.props.currentResults.length
: this.props.selectedEngineIds.length
}
/>
)}
<div className={classes.engineList}>
<EngineListContainer
id={this.props.id}
currentTab={this.props.currentTab}
engineIds={
currentTab === 'explore'
? this.props.currentResults
: this.props.selectedEngineIds
}
onViewDetail={this.props.onViewDetail}
isFetchingEngines={this.props.isFetchingEngines}
failedToFetchEngines={this.props.failedToFetchEngines}
onExploreAllEnginesClick={this.handleTabChange}
/>
</div>
{!this.props.hideActions && (
<div className={classes.footer}>
<Button
classes={{ label: classes.footerBtn }}
onClick={this.props.onCancel}
>
Cancel
</Button>
<Button
color="primary"
classes={{ label: classes.footerBtn }}
onClick={this.handleSave}
>
Save
</Button>
</div>
)}
</div>
</div>
</div>
);
}
}
|
node_modules/antd/es/message/index.js | prodigalyijun/demo-by-antd | import React from 'react';
import Notification from 'rc-notification';
import Icon from '../icon';
var defaultDuration = 1.5;
var defaultTop = void 0;
var messageInstance = void 0;
var key = 1;
var prefixCls = 'ant-message';
var getContainer = void 0;
function getMessageInstance() {
messageInstance = messageInstance || Notification.newInstance({
prefixCls: prefixCls,
transitionName: 'move-up',
style: { top: defaultTop },
getContainer: getContainer
});
return messageInstance;
}
function notice(content) {
var duration = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultDuration;
var type = arguments[2];
var onClose = arguments[3];
var iconType = {
info: 'info-circle',
success: 'check-circle',
error: 'cross-circle',
warning: 'exclamation-circle',
loading: 'loading'
}[type];
var instance = getMessageInstance();
instance.notice({
key: key,
duration: duration,
style: {},
content: React.createElement(
'div',
{ className: prefixCls + '-custom-content ' + prefixCls + '-' + type },
React.createElement(Icon, { type: iconType }),
React.createElement(
'span',
null,
content
)
),
onClose: onClose
});
return function () {
var target = key++;
return function () {
instance.removeNotice(target);
};
}();
}
export default {
info: function info(content, duration, onClose) {
return notice(content, duration, 'info', onClose);
},
success: function success(content, duration, onClose) {
return notice(content, duration, 'success', onClose);
},
error: function error(content, duration, onClose) {
return notice(content, duration, 'error', onClose);
},
// Departed usage, please use warning()
warn: function warn(content, duration, onClose) {
return notice(content, duration, 'warning', onClose);
},
warning: function warning(content, duration, onClose) {
return notice(content, duration, 'warning', onClose);
},
loading: function loading(content, duration, onClose) {
return notice(content, duration, 'loading', onClose);
},
config: function config(options) {
if (options.top !== undefined) {
defaultTop = options.top;
messageInstance = null; // delete messageInstance for new defaultTop
}
if (options.duration !== undefined) {
defaultDuration = options.duration;
}
if (options.prefixCls !== undefined) {
prefixCls = options.prefixCls;
}
if (options.getContainer !== undefined) {
getContainer = options.getContainer;
}
},
destroy: function destroy() {
if (messageInstance) {
messageInstance.destroy();
messageInstance = null;
}
}
}; |
src/svg-icons/editor/insert-chart.js | lawrence-yu/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let EditorInsertChart = (props) => (
<SvgIcon {...props}>
<path d="M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM9 17H7v-7h2v7zm4 0h-2V7h2v10zm4 0h-2v-4h2v4z"/>
</SvgIcon>
);
EditorInsertChart = pure(EditorInsertChart);
EditorInsertChart.displayName = 'EditorInsertChart';
EditorInsertChart.muiName = 'SvgIcon';
export default EditorInsertChart;
|
node_modules/react-bootstrap/es/Checkbox.js | vitorgomateus/NotifyMe | import _extends from 'babel-runtime/helpers/extends';
import _objectWithoutProperties from 'babel-runtime/helpers/objectWithoutProperties';
import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn';
import _inherits from 'babel-runtime/helpers/inherits';
import classNames from 'classnames';
import React from 'react';
import warning from 'warning';
import { bsClass, getClassSet, prefix, splitBsProps } from './utils/bootstrapUtils';
var propTypes = {
inline: React.PropTypes.bool,
disabled: React.PropTypes.bool,
/**
* Only valid if `inline` is not set.
*/
validationState: React.PropTypes.oneOf(['success', 'warning', 'error', null]),
/**
* Attaches a ref to the `<input>` element. Only functions can be used here.
*
* ```js
* <Checkbox inputRef={ref => { this.input = ref; }} />
* ```
*/
inputRef: React.PropTypes.func
};
var defaultProps = {
inline: false,
disabled: false
};
var Checkbox = function (_React$Component) {
_inherits(Checkbox, _React$Component);
function Checkbox() {
_classCallCheck(this, Checkbox);
return _possibleConstructorReturn(this, _React$Component.apply(this, arguments));
}
Checkbox.prototype.render = function render() {
var _props = this.props,
inline = _props.inline,
disabled = _props.disabled,
validationState = _props.validationState,
inputRef = _props.inputRef,
className = _props.className,
style = _props.style,
children = _props.children,
props = _objectWithoutProperties(_props, ['inline', 'disabled', 'validationState', 'inputRef', 'className', 'style', 'children']);
var _splitBsProps = splitBsProps(props),
bsProps = _splitBsProps[0],
elementProps = _splitBsProps[1];
var input = React.createElement('input', _extends({}, elementProps, {
ref: inputRef,
type: 'checkbox',
disabled: disabled
}));
if (inline) {
var _classes2;
var _classes = (_classes2 = {}, _classes2[prefix(bsProps, 'inline')] = true, _classes2.disabled = disabled, _classes2);
// Use a warning here instead of in propTypes to get better-looking
// generated documentation.
process.env.NODE_ENV !== 'production' ? warning(!validationState, '`validationState` is ignored on `<Checkbox inline>`. To display ' + 'validation state on an inline checkbox, set `validationState` on a ' + 'parent `<FormGroup>` or other element instead.') : void 0;
return React.createElement(
'label',
{ className: classNames(className, _classes), style: style },
input,
children
);
}
var classes = _extends({}, getClassSet(bsProps), {
disabled: disabled
});
if (validationState) {
classes['has-' + validationState] = true;
}
return React.createElement(
'div',
{ className: classNames(className, classes), style: style },
React.createElement(
'label',
null,
input,
children
)
);
};
return Checkbox;
}(React.Component);
Checkbox.propTypes = propTypes;
Checkbox.defaultProps = defaultProps;
export default bsClass('checkbox', Checkbox); |
src/components/singleNote.js | nrafter/react-native-notes | import React, { Component } from 'react';
import {
Text,
View,
TextInput,
BackAndroid,
StatusBar
} from 'react-native';
import { connect } from 'react-redux';
import { NavigationActions } from 'react-navigation';
import Toolbar from '../lib/Toolbar';
import TitleText from '../lib/TitleText';
import TickBtn from '../lib/TickBtn';
import BackBtn from '../lib/BackBtn';
import { styles } from './styles';
import { getColor } from '../lib/helpers';
import { Typo } from '../lib/Typography';
import { updateNote } from '../actions';
class SingleNote extends Component {
constructor(props) {
super(props);
this._handleBackButton = this._handleBackButton.bind(this);
this.state = {
changed: false,
id: this.props.navigation.state.params.noteId,
title: this.props.navigation.state.params.title,
desc: this.props.navigation.state.params.description,
}
}
static navigationOptions = {
headerTitle: <TitleText title="Edit Note" />,
headerStyle: {
backgroundColor: getColor('paperTeal'),
}
};
componentDidMount() {
BackAndroid.addEventListener('backPressedSingleNote', this._handleBackButton)
}
componentWillUnmount() {
BackAndroid.removeEventListener('backPressedSingleNote', this._handleBackButton)
}
_handleBackButton() {
if (this.state.changed && this.state.title != '') {
this.updateNote()
} else {
this.goBack()
}
return true
}
render() {
return(
<View style={ styles.addNotesContainer }>
<StatusBar
backgroundColor={getColor('paperTeal700')}
barStyle="light-content"
animated={true}
/>
{/*<Toolbar title="Edit Note" color={getColor('paperTeal')}/>*/}
<View style={styles.textInputContainer}>
<TextInput
style={styles.inputTitleStyle}
placeholder='Note Title...'
placeholderTextColor='#aaa'
returnKeyType='next'
underlineColorAndroid="transparent"
selectionColor={getColor('paperTeal')}
onChangeText={(text) => this.setState({ title: text, changed: true })}
value={this.state.title}
/>
<TextInput
style={styles.inputDescriptionStyle}
multiline={true}
placeholder='Note Description...'
placeholderTextColor='#aaa'
returnKeyType='done'
underlineColorAndroid="transparent"
selectionColor={getColor('paperTeal')}
onChangeText={(text) => this.setState({desc: text, changed: true})}
value={this.state.desc}
/>
</View>
<View style={styles.inputScreenBtnContainer}>
<TickBtn onBtnPress={this.updateNote.bind(this)} />
<BackBtn onBtnPress={this.goBack.bind(this)} />
</View>
</View>
)
}
goBack(event) {
this.props.navigator.pop()
}
updateNote() {
if (this.state.changed) {
this.props.updateNote({
id: this.state.id,
title: this.state.title,
description: this.state.desc
})
}
this.goBack()
}
}
const mapStateToProps = state => ({
});
const mapDispatchToProps = dispatch => ({
navigator: {
push: (routeName, params) => { dispatch(NavigationActions.navigate({ routeName, params })); },
pop: () => { dispatch(NavigationActions.back()); },
},
updateNote: note => dispatch(updateNote(note)),
});
export default connect(mapStateToProps, mapDispatchToProps)(SingleNote);
|
packages/ringcentral-widgets-docs/src/app/pages/Components/CallList/index.js | u9520107/ringcentral-js-widget | import React from 'react';
import { parse } from 'react-docgen';
import CodeExample from '../../../components/CodeExample';
import ComponentHeader from '../../../components/ComponentHeader';
import PropTypeDescription from '../../../components/PropTypeDescription';
import Demo from './Demo';
// eslint-disable-next-line
import demoCode from '!raw-loader!./Demo';
// eslint-disable-next-line
import componentCode from '!raw-loader!ringcentral-widgets/components/CallList';
const CallListPage = () => {
const info = parse(componentCode);
return (
<div>
<ComponentHeader name="CallList" description={info.description} />
<CodeExample
code={demoCode}
title="CallList Example"
>
<Demo />
</CodeExample>
<PropTypeDescription componentInfo={info} />
</div>
);
};
export default CallListPage;
|
src/components/basic/Li.js | casesandberg/react-mark | 'use strict';
import React from 'react';
export class LI extends React.Component {
render() {
return <li>{ this.props.children }</li>;
}
}
export default LI;
|
pages/rant/hate_software.js | mvasilkov/mvasilkov.ovh | import React from 'react'
import Article from '../../app/article'
export const pagePath = 'rant/hate_software'
export const pageTitle = 'Ryan Dahl: I hate almost all software'
export default class extends React.Component {
render() {
return (
<Article path={pagePath} title={pageTitle}>
<header>
<h1>I hate almost all software.</h1>
</header>
<p>It's unnecessary and complicated at almost every layer. At best I can congratulate someone for quickly and simply solving a problem on top of the shit that they are given. The only software that I like is one that I can easily understand and solves my problems. The amount of complexity I'm willing to tolerate is proportional to the size of the problem being solved.</p>
<p>In the past year I think I have finally come to understand the ideals of Unix: file descriptors and processes orchestrated with C. It's a beautiful idea. This is not, however, what we interact with. The complexity was not contained. Instead I deal with DBus and /usr/lib and Boost and ioctls and SMF and signals and volatile variables and prototypal inheritance and _C99_FEATURES_ and dpkg and autoconf.</p>
<p>Those of us who build on top of these systems are adding to the complexity. Not only do you have to understand $LD_LIBRARY_PATH to make your system work but now you have to understand $NODE_PATH too — there's my little addition to the complexity you must now know! The users — the ones who just want to see a webpage — don't care. They don't care how we organize /usr, they don't care about zombie processes, they don't care about bash tab completion, they don't care if zlib is dynamically linked or statically linked to Node. There will come a point where the accumulated complexity of our existing systems is greater than the complexity of creating a new one. When that happens all of this shit will be trashed. We can flush Boost and glib and autoconf down the toilet and never think of them again.</p>
<p>Those of you who still find it enjoyable to learn the details of, say, a programming language — being able to happily recite off if NaN equals or does not equal null — you just don't yet understand how utterly fucked the whole thing is. If you think it would be cute to align all of the equals signs in your code, if you spend time configuring your window manager or editor, if you put Unicode check marks in your test runner, if you add unnecessary hierarchies in your code directories, if you are doing anything beyond just solving the problem — you don't understand how fucked the whole thing is. No one gives a fuck about the glib object model.</p>
<p>The only thing that matters in software is the experience of the user.</p>
<footer>
<p>Written by Ryan Dahl in 2011.</p>
</footer>
</Article>
)
}
}
|
codes/reactstrap-demo/src/views/Components/Forms/Forms.js | atlantis1024/react-step-by-step | import React, { Component } from 'react';
import { Button, ButtonDropdown, DropdownToggle, DropdownMenu, DropdownItem } from 'reactstrap';
class Forms extends Component {
constructor(props) {
super(props);
this.state = {};
}
render() {
return (
<div className="animated fadeIn">
<div className="row">
<div className="col-sm-6">
<div className="card">
<div className="card-header">
<strong>Credit Card</strong> <small>Form</small>
</div>
<div className="card-block">
<div className="row">
<div className="col-sm-12">
<div className="form-group">
<label htmlFor="name">Name</label>
<input type="text" className="form-control" id="name" placeholder="Enter your name"/>
</div>
</div>
</div>
<div className="row">
<div className="col-sm-12">
<div className="form-group">
<label htmlFor="ccnumber">Credit Card Number</label>
<input type="text" className="form-control" id="ccnumber" placeholder="0000 0000 0000 0000"/>
</div>
</div>
</div>
<div className="row">
<div className="form-group col-sm-4">
<label htmlFor="ccmonth">Month</label>
<select className="form-control" id="ccmonth">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
<option>9</option>
<option>10</option>
<option>11</option>
<option>12</option>
</select>
</div>
<div className="form-group col-sm-4">
<label htmlFor="ccyear">Year</label>
<select className="form-control" id="ccyear">
<option>2014</option>
<option>2015</option>
<option>2016</option>
<option>2017</option>
<option>2018</option>
<option>2019</option>
<option>2020</option>
<option>2021</option>
<option>2022</option>
<option>2023</option>
<option>2024</option>
<option>2025</option>
</select>
</div>
<div className="col-sm-4">
<div className="form-group">
<label htmlFor="cvv">CVV/CVC</label>
<input type="text" className="form-control" id="cvv" placeholder="123"/>
</div>
</div>
</div>
</div>
</div>
</div>
<div className="col-sm-6">
<div className="card">
<div className="card-header">
<strong>Company</strong> <small>Form</small>
</div>
<div className="card-block">
<div className="form-group">
<label htmlFor="company">Company</label>
<input type="text" className="form-control" id="company" placeholder="Enter your company name"/>
</div>
<div className="form-group">
<label htmlFor="vat">VAT</label>
<input type="text" className="form-control" id="vat" placeholder="PL1234567890"/>
</div>
<div className="form-group">
<label htmlFor="street">Street</label>
<input type="text" className="form-control" id="street" placeholder="Enter street name"/>
</div>
<div className="row">
<div className="form-group col-sm-8">
<label htmlFor="city">City</label>
<input type="text" className="form-control" id="city" placeholder="Enter your city"/>
</div>
<div className="form-group col-sm-4">
<label htmlFor="postal-code">Postal Code</label>
<input type="text" className="form-control" id="postal-code" placeholder="Postal Code"/>
</div>
</div>
<div className="form-group">
<label htmlFor="country">Country</label>
<input type="text" className="form-control" id="country" placeholder="Country name"/>
</div>
</div>
</div>
</div>
</div>
<div className="row">
<div className="col-md-6">
<div className="card">
<div className="card-header">
<strong>Basic Form</strong> Elements
</div>
<div className="card-block">
<form action="" method="post" encType="multipart/form-data" className="form-horizontal">
<div className="form-group row">
<label className="col-md-3 form-control-label">Static</label>
<div className="col-md-9">
<p className="form-control-static">Username</p>
</div>
</div>
<div className="form-group row">
<label className="col-md-3 form-control-label" htmlFor="text-input">Text Input</label>
<div className="col-md-9">
<input type="text" id="text-input" name="text-input" className="form-control" placeholder="Text"/>
<span className="help-block">This is a help text</span>
</div>
</div>
<div className="form-group row">
<label className="col-md-3 form-control-label" htmlFor="email-input">Email Input</label>
<div className="col-md-9">
<input type="email" id="email-input" name="email-input" className="form-control" placeholder="Enter Email"/>
<span className="help-block">Please enter your email</span>
</div>
</div>
<div className="form-group row">
<label className="col-md-3 form-control-label" htmlFor="password-input">Password</label>
<div className="col-md-9">
<input type="password" id="password-input" name="password-input" className="form-control" placeholder="Password"/>
<span className="help-block">Please enter a complex password</span>
</div>
</div>
<div className="form-group row">
<label className="col-md-3 form-control-label" htmlFor="disabled-input">Disabled Input</label>
<div className="col-md-9">
<input type="text" id="disabled-input" name="disabled-input" className="form-control" placeholder="Disabled" disabled/>
</div>
</div>
<div className="form-group row">
<label className="col-md-3 form-control-label" htmlFor="textarea-input">Textarea</label>
<div className="col-md-9">
<textarea id="textarea-input" name="textarea-input" rows="9" className="form-control" placeholder="Content.."></textarea>
</div>
</div>
<div className="form-group row">
<label className="col-md-3 form-control-label" htmlFor="select">Select</label>
<div className="col-md-9">
<select id="select" name="select" className="form-control">
<option value="0">Please select</option>
<option value="1">Option #1</option>
<option value="2">Option #2</option>
<option value="3">Option #3</option>
</select>
</div>
</div>
<div className="form-group row">
<label className="col-md-3 form-control-label" htmlFor="select">Select Large</label>
<div className="col-md-9">
<select id="select" name="select" className="form-control form-control-lg">
<option value="0">Please select</option>
<option value="1">Option #1</option>
<option value="2">Option #2</option>
<option value="3">Option #3</option>
</select>
</div>
</div>
<div className="form-group row">
<label className="col-md-3 form-control-label" htmlFor="select">Select Small</label>
<div className="col-md-9">
<select id="select" name="select" className="form-control form-control-sm">
<option value="0">Please select</option>
<option value="1">Option #1</option>
<option value="2">Option #2</option>
<option value="3">Option #3</option>
</select>
</div>
</div>
<div className="form-group row">
<label className="col-md-3 form-control-label" htmlFor="select">Disabled Select</label>
<div className="col-md-9">
<select id="disabledSelect" className="form-control" disabled>
<option value="0">Please select</option>
<option value="1">Option #1</option>
<option value="2">Option #2</option>
<option value="3">Option #3</option>
</select>
</div>
</div>
<div className="form-group row">
<label className="col-md-3 form-control-label" htmlFor="multiple-select">Multiple select</label>
<div className="col-md-9">
<select id="multiple-select" name="multiple-select" className="form-control" size="5" multiple>
<option value="1">Option #1</option>
<option value="2">Option #2</option>
<option value="3">Option #3</option>
<option value="4">Option #4</option>
<option value="5">Option #5</option>
<option value="6">Option #6</option>
<option value="7">Option #7</option>
<option value="8">Option #8</option>
<option value="9">Option #9</option>
<option value="10">Option #10</option>
</select>
</div>
</div>
<div className="form-group row">
<label className="col-md-3 form-control-label">Radios</label>
<div className="col-md-9">
<div className="radio">
<label htmlFor="radio1">
<input type="radio" id="radio1" name="radios" value="option1"/> Option 1
</label>
</div>
<div className="radio">
<label htmlFor="radio2">
<input type="radio" id="radio2" name="radios" value="option2"/> Option 2
</label>
</div>
<div className="radio">
<label htmlFor="radio3">
<input type="radio" id="radio3" name="radios" value="option3"/> Option 3
</label>
</div>
</div>
</div>
<div className="form-group row">
<label className="col-md-3 form-control-label">Inline Radios</label>
<div className="col-md-9">
<label className="radio-inline" htmlFor="inline-radio1">
<input type="radio" id="inline-radio1" name="inline-radios" value="option1"/> One
</label>
<label className="radio-inline" htmlFor="inline-radio2">
<input type="radio" id="inline-radio2" name="inline-radios" value="option2"/> Two
</label>
<label className="radio-inline" htmlFor="inline-radio3">
<input type="radio" id="inline-radio3" name="inline-radios" value="option3"/> Three
</label>
</div>
</div>
<div className="form-group row">
<label className="col-md-3 form-control-label">Checkboxes</label>
<div className="col-md-9">
<div className="checkbox">
<label htmlFor="checkbox1">
<input type="checkbox" id="checkbox1" name="checkbox1" value="option1"/> Option 1
</label>
</div>
<div className="checkbox">
<label htmlFor="checkbox2">
<input type="checkbox" id="checkbox2" name="checkbox2" value="option2"/> Option 2
</label>
</div>
<div className="checkbox">
<label htmlFor="checkbox3">
<input type="checkbox" id="checkbox3" name="checkbox3" value="option3"/> Option 3
</label>
</div>
</div>
</div>
<div className="form-group row">
<label className="col-md-3 form-control-label">Inline Checkboxes</label>
<div className="col-md-9">
<label className="checkbox-inline" htmlFor="inline-checkbox1">
<input type="checkbox" id="inline-checkbox1" name="inline-checkbox1" value="option1"/>One
</label>
<label className="checkbox-inline" htmlFor="inline-checkbox2">
<input type="checkbox" id="inline-checkbox2" name="inline-checkbox2" value="option2"/>Two
</label>
<label className="checkbox-inline" htmlFor="inline-checkbox3">
<input type="checkbox" id="inline-checkbox3" name="inline-checkbox3" value="option3"/>Three
</label>
</div>
</div>
<div className="form-group row">
<label className="col-md-3 form-control-label" htmlFor="file-input">File input</label>
<div className="col-md-9">
<input type="file" id="file-input" name="file-input"/>
</div>
</div>
<div className="form-group row">
<label className="col-md-3 form-control-label" htmlFor="file-multiple-input">Multiple File input</label>
<div className="col-md-9">
<input type="file" id="file-multiple-input" name="file-multiple-input" multiple/>
</div>
</div>
</form>
</div>
<div className="card-footer">
<button type="submit" className="btn btn-sm btn-primary"><i className="fa fa-dot-circle-o"></i> Submit</button>
<button type="reset" className="btn btn-sm btn-danger"><i className="fa fa-ban"></i> Reset</button>
</div>
</div>
<div className="card">
<div className="card-header">
<strong>Inline</strong> Form
</div>
<div className="card-block">
<form action="" method="post" className="form-inline">
<div className="form-group">
<label htmlFor="exampleInputName2">Name</label>
<input type="text" className="form-control" id="exampleInputName2" placeholder="Jane Doe"/>
</div>
<div className="form-group">
<label htmlFor="exampleInputEmail2">Email</label>
<input type="email" className="form-control" id="exampleInputEmail2" placeholder="[email protected]"/>
</div>
</form>
</div>
<div className="card-footer">
<button type="submit" className="btn btn-sm btn-primary"><i className="fa fa-dot-circle-o"></i> Submit</button>
<button type="reset" className="btn btn-sm btn-danger"><i className="fa fa-ban"></i> Reset</button>
</div>
</div>
</div>
<div className="col-md-6">
<div className="card">
<div className="card-header">
<strong>Horizontal</strong> Form
</div>
<div className="card-block">
<form action="" method="post" className="form-horizontal">
<div className="form-group row">
<label className="col-md-3 form-control-label" htmlFor="hf-email">Email</label>
<div className="col-md-9">
<input type="email" id="hf-email" name="hf-email" className="form-control" placeholder="Enter Email.."/>
<span className="help-block">Please enter your email</span>
</div>
</div>
<div className="form-group row">
<label className="col-md-3 form-control-label" htmlFor="hf-password">Password</label>
<div className="col-md-9">
<input type="password" id="hf-password" name="hf-password" className="form-control" placeholder="Enter Password.."/>
<span className="help-block">Please enter your password</span>
</div>
</div>
</form>
</div>
<div className="card-footer">
<button type="submit" className="btn btn-sm btn-primary"><i className="fa fa-dot-circle-o"></i> Submit</button>
<button type="reset" className="btn btn-sm btn-danger"><i className="fa fa-ban"></i> Reset</button>
</div>
</div>
<div className="card">
<div className="card-header">
<strong>Normal</strong> Form
</div>
<div className="card-block">
<form action="" method="post">
<div className="form-group">
<label htmlFor="nf-email">Email</label>
<input type="email" id="nf-email" name="nf-email" className="form-control" placeholder="Enter Email.."/>
<span className="help-block">Please enter your email</span>
</div>
<div className="form-group">
<label htmlFor="nf-password">Password</label>
<input type="password" id="nf-password" name="nf-password" className="form-control" placeholder="Enter Password.."/>
<span className="help-block">Please enter your password</span>
</div>
</form>
</div>
<div className="card-footer">
<button type="submit" className="btn btn-sm btn-primary"><i className="fa fa-dot-circle-o"></i> Submit</button>
<button type="reset" className="btn btn-sm btn-danger"><i className="fa fa-ban"></i> Reset</button>
</div>
</div>
<div className="card">
<div className="card-header">
Input <strong>Grid</strong>
</div>
<div className="card-block">
<form action="" method="post" className="form-horizontal">
<div className="form-group row">
<div className="col-sm-3">
<input type="text" className="form-control" placeholder=".col-sm-3"/>
</div>
</div>
<div className="form-group row">
<div className="col-sm-4">
<input type="text" className="form-control" placeholder=".col-sm-4"/>
</div>
</div>
<div className="form-group row">
<div className="col-sm-5">
<input type="text" className="form-control" placeholder=".col-sm-5"/>
</div>
</div>
<div className="form-group row">
<div className="col-sm-6">
<input type="text" className="form-control" placeholder=".col-sm-6"/>
</div>
</div>
<div className="form-group row">
<div className="col-sm-7">
<input type="text" className="form-control" placeholder=".col-sm-7"/>
</div>
</div>
<div className="form-group row">
<div className="col-sm-8">
<input type="text" className="form-control" placeholder=".col-sm-8"/>
</div>
</div>
<div className="form-group row">
<div className="col-sm-9">
<input type="text" className="form-control" placeholder=".col-sm-9"/>
</div>
</div>
<div className="form-group row">
<div className="col-sm-10">
<input type="text" className="form-control" placeholder=".col-sm-10"/>
</div>
</div>
<div className="form-group row">
<div className="col-sm-11">
<input type="text" className="form-control" placeholder=".col-sm-11"/>
</div>
</div>
<div className="form-group row">
<div className="col-sm-12">
<input type="text" className="form-control" placeholder=".col-sm-12"/>
</div>
</div>
</form>
</div>
<div className="card-footer">
<button type="submit" className="btn btn-sm btn-primary"><i className="fa fa-user"></i> Login</button>
<button type="reset" className="btn btn-sm btn-danger"><i className="fa fa-ban"></i> Reset</button>
</div>
</div>
<div className="card">
<div className="card-header">
Input <strong>Sizes</strong>
</div>
<div className="card-block">
<form action="" method="post" className="form-horizontal">
<div className="form-group row">
<label className="col-sm-5 form-control-label" htmlFor="input-small">Small Input</label>
<div className="col-sm-6">
<input type="text" id="input-small" name="input-small" className="form-control input-sm" placeholder=".input-sm"/>
</div>
</div>
<div className="form-group row">
<label className="col-sm-5 form-control-label" htmlFor="input-normal">Normal Input</label>
<div className="col-sm-6">
<input type="text" id="input-normal" name="input-normal" className="form-control" placeholder="Normal"/>
</div>
</div>
<div className="form-group row">
<label className="col-sm-5 form-control-label" htmlFor="input-large">Large Input</label>
<div className="col-sm-6">
<input type="text" id="input-large" name="input-large" className="form-control input-lg" placeholder=".input-lg"/>
</div>
</div>
</form>
</div>
<div className="card-footer">
<button type="submit" className="btn btn-sm btn-primary"><i className="fa fa-dot-circle-o"></i> Submit</button>
<button type="reset" className="btn btn-sm btn-danger"><i className="fa fa-ban"></i> Reset</button>
</div>
</div>
</div>
</div>
<div className="row">
<div className="col-sm-6">
<div className="card">
<div className="card-header">
<strong>Validation states</strong> Form
</div>
<div className="card-block">
<div className="form-group has-success">
<label className="form-form-control-label" htmlFor="inputSuccess1">Input with success</label>
<input type="text" className="form-control" id="inputSuccess1"/>
</div>
<div className="form-group has-warning">
<label className="form-form-control-label" htmlFor="inputWarning1">Input with warning</label>
<input type="text" className="form-control" id="inputWarning1"/>
</div>
<div className="form-group has-danger">
<label className="form-form-control-label" htmlFor="inputError1">Input with error</label>
<input type="text" className="form-control" id="inputError1"/>
</div>
</div>
</div>
</div>
<div className="col-sm-6">
<div className="card">
<div className="card-header">
<strong>Validation states</strong> with optional icons
</div>
<div className="card-block">
<div className="form-group has-success">
<label className="form-form-control-label" htmlFor="inputSuccess2">Input with success</label>
<input type="text" className="form-control form-control-success" id="inputSuccess2"/>
</div>
<div className="form-group has-warning">
<label className="form-form-control-label" htmlFor="inputWarning2">Input with warning</label>
<input type="text" className="form-control form-control-warning" id="inputWarning2"/>
</div>
<div className="form-group has-danger has-feedback">
<label className="form-form-control-label" htmlFor="inputError2">Input with error</label>
<input type="text" className="form-control form-control-danger" id="inputError2"/>
</div>
</div>
</div>
</div>
</div>
<div className="row">
<div className="col-sm-4">
<div className="card">
<div className="card-header">
<strong>Icon/Text</strong> Groups
</div>
<div className="card-block">
<form action="" method="post" className="form-horizontal">
<div className="form-group row">
<div className="col-md-12">
<div className="input-group">
<span className="input-group-addon"><i className="fa fa-user"></i></span>
<input type="text" id="input1-group1" name="input1-group1" className="form-control" placeholder="Username"/>
</div>
</div>
</div>
<div className="form-group row">
<div className="col-md-12">
<div className="input-group">
<input type="email" id="input2-group1" name="input2-group1" className="form-control" placeholder="Email"/>
<span className="input-group-addon"><i className="fa fa-envelope-o"></i></span>
</div>
</div>
</div>
<div className="form-group row">
<div className="col-md-12">
<div className="input-group">
<span className="input-group-addon"><i className="fa fa-euro"></i></span>
<input type="text" id="input3-group1" name="input3-group1" className="form-control" placeholder=".."/>
<span className="input-group-addon">.00</span>
</div>
</div>
</div>
</form>
</div>
<div className="card-footer">
<button type="submit" className="btn btn-sm btn-success"><i className="fa fa-dot-circle-o"></i> Submit</button>
<button type="reset" className="btn btn-sm btn-danger"><i className="fa fa-ban"></i> Reset</button>
</div>
</div>
</div>
<div className="col-sm-4">
<div className="card">
<div className="card-header">
<strong>Buttons</strong> Groups
</div>
<div className="card-block">
<form action="" method="post" className="form-horizontal">
<div className="form-group row">
<div className="col-md-12">
<div className="input-group">
<span className="input-group-btn">
<button type="button" className="btn btn-primary"><i className="fa fa-search"></i> Search</button>
</span>
<input type="text" id="input1-group2" name="input1-group2" className="form-control" placeholder="Username"/>
</div>
</div>
</div>
<div className="form-group row">
<div className="col-md-12">
<div className="input-group">
<input type="email" id="input2-group2" name="input2-group2" className="form-control" placeholder="Email"/>
<span className="input-group-btn">
<button type="button" className="btn btn-primary">Submit</button>
</span>
</div>
</div>
</div>
<div className="form-group row">
<div className="col-md-12">
<div className="input-group">
<span className="input-group-btn">
<button type="button" className="btn btn-primary"><i className="fa fa-facebook"></i></button>
</span>
<input type="text" id="input3-group2" name="input3-group2" className="form-control" placeholder="Search"/>
<span className="input-group-btn">
<button type="button" className="btn btn-primary"><i className="fa fa-twitter"></i></button>
</span>
</div>
</div>
</div>
</form>
</div>
<div className="card-footer">
<button type="submit" className="btn btn-sm btn-success"><i className="fa fa-dot-circle-o"></i> Submit</button>
<button type="reset" className="btn btn-sm btn-danger"><i className="fa fa-ban"></i> Reset</button>
</div>
</div>
</div>
<div className="col-sm-4">
<div className="card">
<div className="card-header">
<strong>Dropdowns</strong> Groups
</div>
<div className="card-block">
<form className="form-horizontal">
<div className="form-group row">
<div className="col-md-12">
<div className="input-group">
<div className="input-group-btn">
<ButtonDropdown isOpen={this.state.first} toggle={() => { this.setState({ first: !this.state.first }); }}>
<DropdownToggle caret color="primary">
Button Dropdown
</DropdownToggle>
<DropdownMenu>
<DropdownItem>Action</DropdownItem>
<DropdownItem>Another Action</DropdownItem>
<DropdownItem>Something else here</DropdownItem>
<DropdownItem divider />
<DropdownItem>Separated link</DropdownItem>
</DropdownMenu>
</ButtonDropdown>
</div>
<input type="text" id="input1-group3" name="input1-group3" className="form-control" placeholder="Username"/>
</div>
</div>
</div>
<div className="form-group row">
<div className="col-md-12">
<div className="input-group">
<input type="email" id="input2-group3" name="input2-group3" className="form-control" placeholder="Email"/>
<div className="input-group-btn">
<ButtonDropdown isOpen={this.state.second} toggle={() => { this.setState({ second: !this.state.second }); }}>
<DropdownToggle caret color="primary">
Button Dropdown
</DropdownToggle>
<DropdownMenu>
<DropdownItem>Action</DropdownItem>
<DropdownItem>Another Action</DropdownItem>
<DropdownItem>Something else here</DropdownItem>
<DropdownItem divider />
<DropdownItem>Separated link</DropdownItem>
</DropdownMenu>
</ButtonDropdown>
</div>
</div>
</div>
</div>
<div className="row">
<div className="col-md-12">
<div className="input-group">
<div className="input-group-btn">
<ButtonDropdown isOpen={this.state.third} toggle={() => { this.setState({ third: !this.state.third }); }}>
<Button id="caret" color="primary">Action</Button>
<DropdownToggle caret color="primary" />
<DropdownMenu>
<DropdownItem>Action</DropdownItem>
<DropdownItem>Another Action</DropdownItem>
<DropdownItem>Something else here</DropdownItem>
<DropdownItem divider />
<DropdownItem>Separated link</DropdownItem>
</DropdownMenu>
</ButtonDropdown>
</div>
<input type="text" id="input3-group3" name="input3-group3" className="form-control" placeholder=".."/>
<div className="input-group-btn">
<ButtonDropdown isOpen={this.state.fourth} toggle={() => { this.setState({ fourth: !this.state.fourth }); }}>
<DropdownToggle caret color="primary">
Button Dropdown
</DropdownToggle>
<DropdownMenu>
<DropdownItem>Action</DropdownItem>
<DropdownItem>Another Action</DropdownItem>
<DropdownItem>Something else here</DropdownItem>
<DropdownItem divider />
<DropdownItem>Separated link</DropdownItem>
</DropdownMenu>
</ButtonDropdown>
</div>
</div>
</div>
</div>
</form>
</div>
<div className="card-footer">
<button type="submit" className="btn btn-sm btn-success"><i className="fa fa-dot-circle-o"></i> Submit</button>
<button type="reset" className="btn btn-sm btn-danger"><i className="fa fa-ban"></i> Reset</button>
</div>
</div>
</div>
</div>
<div className="row">
<div className="col-md-6">
<div className="card">
<div className="card-header">
Use the grid for big devices! <small><code>.col-lg-*</code> <code>.col-md-*</code> <code>.col-sm-*</code></small>
</div>
<div className="card-block">
<form action="" method="post" className="form-horizontal">
<div className="form-group row">
<div className="col-md-8">
<input type="text" className="form-control" placeholder=".col-md-8"/>
</div>
<div className="col-md-4">
<input type="text" className="form-control" placeholder=".col-md-4"/>
</div>
</div>
<div className="form-group row">
<div className="col-md-7">
<input type="text" className="form-control" placeholder=".col-md-7"/>
</div>
<div className="col-md-5">
<input type="text" className="form-control" placeholder=".col-md-5"/>
</div>
</div>
<div className="form-group row">
<div className="col-md-6">
<input type="text" className="form-control" placeholder=".col-md-6"/>
</div>
<div className="col-md-6">
<input type="text" className="form-control" placeholder=".col-md-6"/>
</div>
</div>
<div className="form-group row">
<div className="col-md-5">
<input type="text" className="form-control" placeholder=".col-md-5"/>
</div>
<div className="col-md-7">
<input type="text" className="form-control" placeholder=".col-md-7"/>
</div>
</div>
<div className="form-group row">
<div className="col-md-4">
<input type="text" className="form-control" placeholder=".col-md-4"/>
</div>
<div className="col-md-8">
<input type="text" className="form-control" placeholder=".col-md-8"/>
</div>
</div>
</form>
</div>
<div className="card-footer">
<button type="submit" className="btn btn-sm btn-primary">Action</button>
<button type="button" className="btn btn-sm btn-danger">Action</button>
<button type="button" className="btn btn-sm btn-warning">Action</button>
<button type="button" className="btn btn-sm btn-info">Action</button>
<button type="button" className="btn btn-sm btn-success">Action</button>
</div>
</div>
</div>
<div className="col-md-6">
<div className="card">
<div className="card-header">
Input Grid for small devices! <small> <code>.col-*</code></small>
</div>
<div className="card-block">
<form action="" method="post" className="form-horizontal">
<div className="form-group row">
<div className="col-4">
<input type="text" className="form-control" placeholder=".col-4"/>
</div>
<div className="col-8">
<input type="text" className="form-control" placeholder=".col-8"/>
</div>
</div>
<div className="form-group row">
<div className="col-5">
<input type="text" className="form-control" placeholder=".col-5"/>
</div>
<div className="col-7">
<input type="text" className="form-control" placeholder=".col-7"/>
</div>
</div>
<div className="form-group row">
<div className="col-6">
<input type="text" className="form-control" placeholder=".col-6"/>
</div>
<div className="col-6">
<input type="text" className="form-control" placeholder=".col-6"/>
</div>
</div>
<div className="form-group row">
<div className="col-7">
<input type="text" className="form-control" placeholder=".col-5"/>
</div>
<div className="col-5">
<input type="text" className="form-control" placeholder=".col-5"/>
</div>
</div>
<div className="form-group row">
<div className="col-8">
<input type="text" className="form-control" placeholder=".col-8"/>
</div>
<div className="col-4">
<input type="text" className="form-control" placeholder=".col-4"/>
</div>
</div>
</form>
</div>
<div className="card-footer">
<button type="submit" className="btn btn-sm btn-primary">Action</button>
<button type="button" className="btn btn-sm btn-danger">Action</button>
<button type="button" className="btn btn-sm btn-warning">Action</button>
<button type="button" className="btn btn-sm btn-info">Action</button>
<button type="button" className="btn btn-sm btn-success">Action</button>
</div>
</div>
</div>
</div>
<div className="row">
<div className="col-sm-4">
<div className="card">
<div className="card-header">
Example Form
</div>
<div className="card-block">
<form action="" method="post">
<div className="form-group">
<div className="input-group">
<span className="input-group-addon">Username</span>
<input type="text" id="username3" name="username3" className="form-control"/>
<span className="input-group-addon"><i className="fa fa-user"></i></span>
</div>
</div>
<div className="form-group">
<div className="input-group">
<span className="input-group-addon">Email</span>
<input type="email" id="email3" name="email3" className="form-control"/>
<span className="input-group-addon"><i className="fa fa-envelope"></i></span>
</div>
</div>
<div className="form-group">
<div className="input-group">
<span className="input-group-addon">Password</span>
<input type="password" id="password3" name="password3" className="form-control"/>
<span className="input-group-addon"><i className="fa fa-asterisk"></i></span>
</div>
</div>
<div className="form-group form-actions">
<button type="submit" className="btn btn-sm btn-primary">Submit</button>
</div>
</form>
</div>
</div>
</div>
<div className="col-sm-4">
<div className="card">
<div className="card-header">
Example Form
</div>
<div className="card-block">
<form action="" method="post">
<div className="form-group">
<div className="input-group">
<input type="text" id="username2" name="username2" className="form-control" placeholder="Username"/>
<span className="input-group-addon"><i className="fa fa-user"></i></span>
</div>
</div>
<div className="form-group">
<div className="input-group">
<input type="email" id="email2" name="email2" className="form-control" placeholder="Email"/>
<span className="input-group-addon"><i className="fa fa-envelope"></i></span>
</div>
</div>
<div className="form-group">
<div className="input-group">
<input type="password" id="password2" name="password2" className="form-control" placeholder="Password"/>
<span className="input-group-addon"><i className="fa fa-asterisk"></i></span>
</div>
</div>
<div className="form-group form-actions">
<button type="submit" className="btn btn-sm btn-default">Submit</button>
</div>
</form>
</div>
</div>
</div>
<div className="col-sm-4">
<div className="card">
<div className="card-header">
Example Form
</div>
<div className="card-block">
<form action="" method="post">
<div className="form-group">
<div className="input-group">
<span className="input-group-addon"><i className="fa fa-user"></i></span>
<input type="text" id="username" name="username" className="form-control" placeholder="Username"/>
</div>
</div>
<div className="form-group">
<div className="input-group">
<span className="input-group-addon"><i className="fa fa-envelope"></i></span>
<input type="email" id="email" name="email" className="form-control" placeholder="Email"/>
</div>
</div>
<div className="form-group">
<div className="input-group">
<span className="input-group-addon"><i className="fa fa-asterisk"></i></span>
<input type="password" id="password" name="password" className="form-control" placeholder="Password"/>
</div>
</div>
<div className="form-group form-actions">
<button type="submit" className="btn btn-sm btn-success">Submit</button>
</div>
</form>
</div>
</div>
</div>
</div>
<div className="row">
<div className="col-lg-12">
<div className="card">
<div className="card-header">
<i className="fa fa-edit"></i>Form Elements
<div className="card-actions">
<a href="#" className="btn-setting"><i className="icon-settings"></i></a>
<a href="#" className="btn-minimize"><i className="icon-arrow-up"></i></a>
<a href="#" className="btn-close"><i className="icon-close"></i></a>
</div>
</div>
<div className="card-block">
<form className="form-2orizontal">
<div className="form-group">
<label className="form-control-label" htmlFor="prependedInput">Prepended text</label>
<div className="controls">
<div className="input-prepend input-group">
<span className="input-group-addon">@</span>
<input id="prependedInput" className="form-control" size="16" type="text"/>
</div>
<p className="help-block">Here's some help text</p>
</div>
</div>
<div className="form-group">
<label className="form-control-label" htmlFor="appendedInput">Appended text</label>
<div className="controls">
<div className="input-group">
<input id="appendedInput" className="form-control" size="16" type="text"/><span className="input-group-addon">.00</span>
</div>
<span className="help-block">Here's more help text</span>
</div>
</div>
<div className="form-group">
<label className="form-control-label" htmlFor="appendedPrependedInput">Append and prepend</label>
<div className="controls">
<div className="input-prepend input-group">
<span className="input-group-addon">$</span>
<input id="appendedPrependedInput" className="form-control" size="16" type="text"/><span className="input-group-addon">.00</span>
</div>
</div>
</div>
<div className="form-group">
<label className="form-control-label" htmlFor="appendedInputButton">Append with button</label>
<div className="controls">
<div className="input-group">
<input id="appendedInputButton" className="form-control" size="16" type="text"/>
<span className="input-group-btn"><button className="btn btn-default" type="button">Go!</button></span>
</div>
</div>
</div>
<div className="form-group">
<label className="form-control-label" htmlFor="appendedInputButtons">Two-button append</label>
<div className="controls">
<div className="input-group">
<input id="appendedInputButtons" size="16" className="form-control" type="text"/>
<span className="input-group-btn">
<button className="btn btn-default" type="button">Search</button>
<button className="btn btn-default" type="button">Options</button>
</span>
</div>
</div>
</div>
<div className="form-actions">
<button type="submit" className="btn btn-primary">Save changes</button>
<button type="button" className="btn btn-default">Cancel</button>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
)
}
}
export default Forms;
|
src/components/content/home.js | isthereagametoday/is-there-a-cubs-game | import React from 'react';
// components
import Nav from './nav';
import Seo from './seo';
import Header from './header';
import Footer from './footer';
import Yes from './yes';
import No from './no';
// utils
import apiUtils from '../../utils/api-utils';
import dateUtils from '../../utils/date-utils';
import timesUtils from '../../utils/times-utils';
class Home extends React.Component {
constructor() {
super();
this.state = {
result: null,
times: null,
type: null
};
}
componentWillMount() {
this.init();
}
init() {
const today = dateUtils.getToday('', 10);
const eventStatus = apiUtils.getDate(today);
eventStatus.then(date => {
let eventType, eventTimes, check;
if (date.val() != null) {
eventTimes = timesUtils.getTimes(date);
eventType = date.eventType;
check = true;
} else {
check = false;
eventType = eventTimes = null;
}
this.setState({
result: check,
times: eventTimes,
type: eventType,
})
},
(error) => {
console.log('error:', error);
});
}
render() {
let message = null;
if (this.state.result === true) {
message = <Yes times={this.state.times} type={this.state.type} />;
} else if (this.state.result === false) {
message = <No />;
} else {
message = " ";
}
return (
<div className="row middle-xsmall center-xsmall">
<div className="column-xsmall">
<Header />
{message}
<Nav link />
<Seo />
<Footer />
</div>
</div>
);
}
}
export default Home;
|
src/parser/warlock/demonology/modules/talents/DemonicCalling.js | sMteX/WoWAnalyzer | import React from 'react';
import Analyzer, { SELECTED_PLAYER } from 'parser/core/Analyzer';
import Events from 'parser/core/Events';
import SpellUsable from 'parser/shared/modules/SpellUsable';
import SPELLS from 'common/SPELLS';
import SpellLink from 'common/SpellLink';
import { STATISTIC_ORDER } from 'interface/others/StatisticBox';
import StatisticListBoxItem from 'interface/others/StatisticListBoxItem';
const BUFF_DURATION = 20000;
const debug = false;
class DemonicCalling extends Analyzer {
static dependencies = {
spellUsable: SpellUsable,
};
wastedProcs = 0;
_expectedBuffEnd = null;
constructor(...args) {
super(...args);
this.active = this.selectedCombatant.hasTalent(SPELLS.DEMONIC_CALLING_TALENT.id);
this.addEventListener(Events.applybuff.to(SELECTED_PLAYER).spell(SPELLS.DEMONIC_CALLING_BUFF), this.applyDemonicCallingBuff);
this.addEventListener(Events.refreshbuff.to(SELECTED_PLAYER).spell(SPELLS.DEMONIC_CALLING_BUFF), this.refreshDemonicCallingBuff);
this.addEventListener(Events.removebuff.to(SELECTED_PLAYER).spell(SPELLS.DEMONIC_CALLING_BUFF), this.removeDemonicCallingBuff);
}
applyDemonicCallingBuff(event) {
debug && this.log('DC applied');
this._expectedBuffEnd = event.timestamp + BUFF_DURATION;
}
refreshDemonicCallingBuff(event) {
debug && this.log('DC refreshed');
if (this.spellUsable.isAvailable(SPELLS.CALL_DREADSTALKERS.id)) {
this.wastedProcs += 1;
debug && this.log('Dreadstalkers were available, wasted proc');
}
this._expectedBuffEnd = event.timestamp + BUFF_DURATION;
}
removeDemonicCallingBuff(event) {
if (event.timestamp >= this._expectedBuffEnd) {
// the buff fell off, another wasted instant
this.wastedProcs += 1;
debug && this.log('DC fell off, wasted proc');
}
}
get suggestionThresholds() {
const wastedPerMinute = this.wastedProcs / this.owner.fightDuration * 1000 * 60;
return {
actual: wastedPerMinute,
isGreaterThan: {
minor: 1,
average: 1.5,
major: 2,
},
style: 'number',
};
}
suggestions(when) {
when(this.suggestionThresholds)
.addSuggestion((suggest, actual, recommended) => {
return suggest(<>You should try to use your cheaper <SpellLink id={SPELLS.CALL_DREADSTALKERS.id} /> as much as possible as Dreadstalkers make a great portion of your damage.<br /><br /><small>NOTE: Some wasted procs are probably unavoidable (e.g. <SpellLink id={SPELLS.CALL_DREADSTALKERS.id} /> on cooldown, proc waiting but gets overwritten by another)</small></>)
.icon(SPELLS.DEMONIC_CALLING_TALENT.icon)
.actual(`${actual.toFixed(2)} wasted procs per minute`)
.recommended(`< ${recommended} is recommended`);
});
}
subStatistic() {
return (
<StatisticListBoxItem
title={<>Wasted <SpellLink id={SPELLS.DEMONIC_CALLING_TALENT.id} /> procs</>}
value={this.wastedProcs}
/>
);
}
statisticOrder = STATISTIC_ORDER.OPTIONAL(0);
}
export default DemonicCalling;
|
docs/app/Examples/modules/Dropdown/States/DropdownExampleDisabled.js | ben174/Semantic-UI-React | import React from 'react'
import { Dropdown } from 'semantic-ui-react'
const DropdownExampleDisabled = () => (
<Dropdown text='Dropdown' disabled>
<Dropdown.Menu>
<Dropdown.Item>Choice 1</Dropdown.Item>
<Dropdown.Item>Choice 2</Dropdown.Item>
</Dropdown.Menu>
</Dropdown>
)
export default DropdownExampleDisabled
|
src/containers/Home/index.js | hahoocn/react-mobile-boilerplate | import React from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import Helmet from 'react-helmet';
import { showHello, showHelloAsync, showMoviesAsync } from './actions';
import logoImg from '../../assets/images/logo.jpg';
import config from '../../config';
import { selectInfo, selectHome } from './selectors';
class Home extends React.Component {
static propTypes = {
dispatch: PropTypes.func.isRequired,
home: PropTypes.object.isRequired,
homeinfo: PropTypes.string,
history: PropTypes.object.isRequired,
}
static defaultProps = {
homeinfo: undefined,
}
state = {
info: 'Hahoo App!'
}
componentDidMount() {
const { dispatch } = this.props;
if (!this.props.homeinfo) dispatch(showHello('About'));
if (!this.props.home.moviesTotal) dispatch(showMoviesAsync());
if (!this.props.home.name || !this.props.home.infoAsync) {
dispatch(showHelloAsync('This is the content of'));
}
}
render() {
const styles = require('./styles.css');
const { home, homeinfo, history } = this.props;
return (
<div className={styles.main}>
<Helmet title={config.app.title} />
<div className={styles.logo}><img src={logoImg} alt="" /></div>
<h1>{this.state.info}</h1>
<h2 className={styles.aboutBox}>
<span onClick={() => history.push('/about')} role="link" tabIndex="0" className={styles.about}>
{homeinfo}
</span>
</h2>
<h2>Loading remote: movies {home.moviesTotal}</h2>
<h3>{home.name} {home.infoAsync}</h3>
</div>
);
}
}
Home.fetchData = ({ store }) => {
const fetch = Promise.all([
store.dispatch(showHelloAsync('This is the content of')),
store.dispatch(showMoviesAsync()),
store.dispatch(showHello('About'))
]);
return fetch;
};
const mapStateToProps = state => ({
home: selectHome(state).toObject(),
homeinfo: selectInfo(state),
});
export default connect(mapStateToProps)(Home);
|
src/home/home.app.js | joeldenning/single-spa-examples | import React from 'react';
import ReactDOM from 'react-dom';
import singleSpaReact from 'single-spa-react';
import rootComponent from './root.component.js';
const reactLifecyles = singleSpaReact({
React,
ReactDOM,
domElementGetter,
rootComponent,
});
export const bootstrap = [
reactLifecyles.bootstrap,
];
export const mount = [
reactLifecyles.mount,
];
export const unmount = [
reactLifecyles.unmount,
];
function domElementGetter() {
return document.getElementById("home");
}
|
common/views/Pages/Page404/Page404.js | sauleddy/HomePortal | import React, { Component } from 'react';
class Page404 extends Component {
render() {
return (
<div className="container">
<div className="row justify-content-center">
<div className="col-md-6">
<div className="clearfix">
<h1 className="float-left display-3 mr-4">404</h1>
<h4 className="pt-3">Oops! You're lost.</h4>
<p className="text-muted">The page you are looking for was not found.</p>
</div>
<div className="input-prepend input-group">
<span className="input-group-addon"><i className="fa fa-search"></i></span>
<input className="form-control" size="16" type="text" placeholder="What are you looking for?" />
<span className="input-group-btn">
<button className="btn btn-info" type="button">Search</button>
</span>
</div>
</div>
</div>
</div>
);
}
}
export default Page404;
|
src/Collection.js | 15lyfromsaturn/react-materialize | import React from 'react';
import cx from 'classnames';
class Collection extends React.Component {
constructor(props) {
super(props);
this.renderHeader = this.renderHeader.bind(this);
}
render() {
let classes = {
collection: true,
'with-header': !!this.props.header
};
let C = 'ul';
React.Children.forEach(this.props.children, child => {
if (child.props.href) {
C = 'div';
}
});
return (
<C className={cx(classes)}>
{this.props.header ? this.renderHeader() : null}
{this.props.children}
</C>
);
}
renderHeader() {
let header;
if (this.props.header) {
if (React.isValidElement(this.props.header)) {
header = this.props.header;
} else {
header = <h4>{this.props.header}</h4>;
}
return <li className='collection-header'>{header}</li>;
}
}
}
Collection.propTypes = {
header: React.PropTypes.node,
};
export default Collection;
|
app/Components/MainView.js | csujedihy/react-native-textgo | 'use strict';
import React, { Component } from 'react';
import Communications from 'react-native-communications';
import TabBar from '../Components/TabBar';
import ContactCard from './ContactCard';
import MyNavigationBar from './MyNavigationBar';
import {bindActionCreators} from 'redux';
import { connect } from 'react-redux';
import * as userActions from '../actions/userActions';
import {
View,
StyleSheet,
TouchableHighlight,
Navigator,
ListView,
Text
} from 'react-native';
class MainView extends Component{
constructor(props) {
console.log('MainView Constructor');
super(props);
}
componentDidMount(){
console.log("MainView componentDidMount.");
}
rightButtonHandler() {
const {state, actions} = this.props;
const {signOutAsync} = actions;
signOutAsync();
}
render(){
const titleConfig = {
title: 'Contacts',
};
const rightButtonConfig = {
title: 'SIGN OUT',
handler: this.rightButtonHandler.bind(this)
};
console.log("MainView render/re-render.: " + this.props.testData);
console.log("DataSource: " + (this.props.dataSource._dataBlob.s1.length? this.props.dataSource._dataBlob.s1[0].emailAddresses[0].email : "0"));
return(
<View style={styles.container}>
<MyNavigationBar
title={titleConfig}
rightButton={rightButtonConfig}
/>
<TabBar structure={[
{
title: 'Contacts',
iconName: 'user',
renderContent: () => {
console.log("DataSource: " + (this.props.dataSource._dataBlob.s1.length? this.props.dataSource._dataBlob.s1[0].emailAddresses[0].email : "0"));
return (
<ListView
enableEmptySections={true}
dataSource={this.props.dataSource}
renderRow={(row) => this.renderListViewRow.bind(this)(row, 'Contacts')}
/>
);
}
},
{
title: 'Keypad',
iconName: 'phone',
renderContent: () => {
return (
<ListView
enableEmptySections={true}
dataSource={this.props.dataSource}
renderRow={(row) => this.renderListViewRow.bind(this)(row, 'Keypad') }
/>
);
}
}
]}
selectedTab={0}
activeTintColor={'#ff8533'}
iconSize={25}
/>
</View>
);
}
renderListViewRow(row, pushNavBarTitle) {
console.log("MainView.js: renderListViewRow(), row: " + row.givenName);
return (
<TouchableHighlight
underlayColor={'#f3f3f2'}
onPress={() => {return this.selectRow.bind(this)(row, pushNavBarTitle)}}>
<View style={styles.rowContainer}>
<View style={styles.rowDetailsContainer}>
<Text style={styles.rowDetailsLine}>
Name: {row.givenName}
</Text>
<Text style={styles.rowDetailsLine}>
Phone: {(typeof row.phoneNumbers[0] === 'undefined') ? 0 : row.phoneNumbers[0].number}
</Text>
<Text style={styles.rowDetailsLine}>
Label: {(typeof row.phoneNumbers[0] === 'undefined') ? 0 : row.phoneNumbers[0].label}
</Text>
<Text style={styles.rowDetailsLine}>
Email: {(typeof row.emailAddresses[0] === 'undefined') ? 0 : row.emailAddresses[0].email}
</Text>
<View style={styles.separator}/>
</View>
</View>
</TouchableHighlight>
);
}
selectRow(row, pushNavBarTitle) {
this.props.navigator.push({
component: ContactCard,
passProps: {
row: row
}
})
}
}
var styles = StyleSheet.create({
container: {
flex: 1,
flexDirection: 'column'
},
navigator: {
flex: 1,
backgroundColor: '#F6F6EF',
},
rowContainer: {
flex: 1,
flexDirection: 'row',
alignItems: 'center',
},
rowCount: {
fontSize: 20,
textAlign: 'right',
color: 'gray',
margin: 10,
marginLeft: 15,
},
rowDetailsContainer: {
flex: 1,
},
rowTitle: {
fontSize: 15,
textAlign: 'left',
marginTop: 10,
marginBottom: 4,
marginRight: 10,
color: '#FF6600'
},
rowDetailsLine: {
fontSize: 12,
marginBottom: 10,
color: 'gray',
},
listview: {
marginBottom: 49
},
separator: {
height: 1,
backgroundColor: '#CCCCCC'
}
});
export default connect(state => ({
state: state.user
}),
(dispatch) => ({
actions: bindActionCreators(userActions, dispatch)
})
)(MainView); |
dynamic-react-router demo/src/Components/App/index.js | gabriel-lopez-lopez/dynamic-react-route | import React, { Component } from 'react';
import Layout from '../Layout';
import DynamicReactRouter from 'dynamic-react-router';
// Configuración del Enrutador
import { ROUTES_CONFIG } from '../../route';
class App extends Component {
constructor(props) {
super(props);
}
// Funcioón booleana para las rutas del enrutador que requieren de autenticación
isAuth() {
if (store.get('jwt')) {
return true;
}
return false;
}
render() {
return (
<DynamicReactRouter config={ROUTES_CONFIG} layout={Layout} isAuth={this.isAuth} />
);
}
}
export default App;
|
src/js/components/correspondence-definitions.js | Antoine-Dreyer/Classification-Explorer | import React from 'react'
import { sparqlConnect } from '../sparql//configure-sparql'
import { LOADING, LOADED, FAILED } from 'sparql-connect'
import { toggleCorrespondenceDefinitions } from '../actions/app-state'
import { connect } from 'react-redux'
//a sparql component can be passed additional props (either by its parent or
//thanks to `mapStateToProps`and `mapDispatchToProps`)
function CorrespondenceDefinitions({ loaded, definitions,
correspondence, showDef, toggleDef }) {
if (loaded !== LOADED) return null
return (
<span>
<span style={{ cursor: 'pointer' }}
onClick={() => toggleDef(correspondence) }>
▾
</span>
{ showDef &&
<div>{definitions.map(({ definition }) => definition).join('/')}</div>
}
</span>
)
}
const mapStateToProps = (state, { correspondence }) => ({
showDef: state.appState.showCorrespondenceDefs.hasOwnProperty(correspondence)
})
const mapDispatchToProps = {
toggleDef: toggleCorrespondenceDefinitions
}
//sparqlConnect functions can be passed `mapStateToProps` and
//`mapDispatchToProps` in almost the same way than `redux.connect`
export default connect(mapStateToProps, mapDispatchToProps)(
sparqlConnect.correspondenceDefinitions(CorrespondenceDefinitions)) |
docs/src/app/components/pages/components/Table/ExampleSimple.js | hai-cea/material-ui | import React from 'react';
import {
Table,
TableBody,
TableHeader,
TableHeaderColumn,
TableRow,
TableRowColumn,
} from 'material-ui/Table';
/**
* A simple table demonstrating the hierarchy of the `Table` component and its sub-components.
*/
const TableExampleSimple = () => (
<Table>
<TableHeader>
<TableRow>
<TableHeaderColumn>ID</TableHeaderColumn>
<TableHeaderColumn>Name</TableHeaderColumn>
<TableHeaderColumn>Status</TableHeaderColumn>
</TableRow>
</TableHeader>
<TableBody>
<TableRow>
<TableRowColumn>1</TableRowColumn>
<TableRowColumn>John Smith</TableRowColumn>
<TableRowColumn>Employed</TableRowColumn>
</TableRow>
<TableRow>
<TableRowColumn>2</TableRowColumn>
<TableRowColumn>Randal White</TableRowColumn>
<TableRowColumn>Unemployed</TableRowColumn>
</TableRow>
<TableRow>
<TableRowColumn>3</TableRowColumn>
<TableRowColumn>Stephanie Sanders</TableRowColumn>
<TableRowColumn>Employed</TableRowColumn>
</TableRow>
<TableRow>
<TableRowColumn>4</TableRowColumn>
<TableRowColumn>Steve Brown</TableRowColumn>
<TableRowColumn>Employed</TableRowColumn>
</TableRow>
<TableRow>
<TableRowColumn>5</TableRowColumn>
<TableRowColumn>Christopher Nolan</TableRowColumn>
<TableRowColumn>Unemployed</TableRowColumn>
</TableRow>
</TableBody>
</Table>
);
export default TableExampleSimple;
|
packages/material-ui-icons/src/Https.js | cherniavskii/material-ui | import React from 'react';
import createSvgIcon from './utils/createSvgIcon';
export default createSvgIcon(
<g><path d="M18 8h-1V6c0-2.76-2.24-5-5-5S7 3.24 7 6v2H6c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V10c0-1.1-.9-2-2-2zm-6 9c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2zm3.1-9H8.9V6c0-1.71 1.39-3.1 3.1-3.1 1.71 0 3.1 1.39 3.1 3.1v2z" /></g>
, 'Https');
|
imports/ui/Login.js | dandev237/short-lnk | /**
* Created by Daniel on 18/06/2017.
*/
import React from 'react';
import {Link} from 'react-router-dom';
import {Meteor} from 'meteor/meteor';
export default class Login extends React.Component {
constructor(props) {
super(props);
this.state = { //Component state
error: ''
};
}
onSubmit(e) {
e.preventDefault(); //Prevent browser default action (full refresh)
let email = this.refs.email.value.trim();
let password = this.refs.password.value.trim();
Meteor.loginWithPassword({email}, password, (err) => {
if(err){
this.setState({error: err.reason});
}else{
this.setState({error: ''});
}
});
}
render() {
return (
<div className="boxed-view">
<div className="boxed-view__box">
<h1>Short Lnk</h1>
{this.state.error ? <p>{this.state.error}</p> : undefined}
<form className="boxed-view__form" onSubmit={this.onSubmit.bind(this)} noValidate>
<input type="email" ref="email" name="email" placeholder="e-mail"/>
<input type="password" ref="password" name="password" placeholder="password"/>
<button className="button">Login</button>
</form>
<Link to="/signup">Create an account</Link>
</div>
</div>
);
}
}
|
examples/redirect-using-index/app.js | whouses/react-router | import React from 'react';
import { Router, Route, IndexRoute, Link } from 'react-router';
var App = React.createClass({
render() {
return (
<div>
{this.props.children}
</div>
);
}
});
var Index = React.createClass({
render () {
return (
<div>
<h1>You should not see this.</h1>
{this.props.children}
</div>
)
}
});
var Child = React.createClass({
render () {
return (
<div>
<h2>Redirected to "/child"</h2>
<Link to="/">Try going to "/"</Link>
</div>
)
}
});
function redirectToChild(location, replaceWith) {
replaceWith(null, '/child');
}
React.render((
<Router>
<Route path="/" component={App}>
<IndexRoute component={Index} onEnter={redirectToChild}/>
<Route path="/child" component={Child}/>
</Route>
</Router>
), document.getElementById('example'));
|
app/client/components/map/Story.js | breakfast-mimes/cyber-mimes | import React from 'react';
export default class Story extends React.Component {
constructor(props) {
super(props);
this.state = {
}
}
render(){
const { row, col, messages} = this.props;
return(
<div className='noSelect'>
{messages[row] ? messages[row][col] : "No Messages"}
</div>
)
}
} |
src/index.js | gaoqiang19514/blog | import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import * as serviceWorker from './serviceWorker';
ReactDOM.render(<App />, document.getElementById('root'));
// If you want your app to work offline and load faster, you can change
// unregister() to register() below. Note this comes with some pitfalls.
// Learn more about service workers: http://bit.ly/CRA-PWA
serviceWorker.unregister();
|
src/docs/examples/Label/ExampleRequired.js | wsherman67/UBA | import React from 'react';
import Label from 'ps-react/Label';
/** Required label */
export default function ExampleRequired() {
return <Label htmlFor="test" label="test" required />
}
|
app/containers/LocaleToggle/index.js | jwarning/react-ci-test | /*
*
* LanguageToggle
*
*/
import React from 'react';
import { connect } from 'react-redux';
import { createSelector } from 'reselect';
import Toggle from 'components/Toggle';
import Wrapper from './Wrapper';
import messages from './messages';
import { appLocales } from '../../i18n';
import { changeLocale } from '../LanguageProvider/actions';
import { makeSelectLocale } from '../LanguageProvider/selectors';
export class LocaleToggle extends React.PureComponent { // eslint-disable-line react/prefer-stateless-function
render() {
return (
<Wrapper>
<Toggle value={this.props.locale} values={appLocales} messages={messages} onToggle={this.props.onLocaleToggle} />
</Wrapper>
);
}
}
LocaleToggle.propTypes = {
onLocaleToggle: React.PropTypes.func,
locale: React.PropTypes.string,
};
const mapStateToProps = createSelector(
makeSelectLocale(),
(locale) => ({ locale })
);
export function mapDispatchToProps(dispatch) {
return {
onLocaleToggle: (evt) => dispatch(changeLocale(evt.target.value)),
dispatch,
};
}
export default connect(mapStateToProps, mapDispatchToProps)(LocaleToggle);
|
src/components/common/svg-icons/image/image-aspect-ratio.js | abzfarah/Pearson.NAPLAN.GnomeH | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let ImageImageAspectRatio = (props) => (
<SvgIcon {...props}>
<path d="M16 10h-2v2h2v-2zm0 4h-2v2h2v-2zm-8-4H6v2h2v-2zm4 0h-2v2h2v-2zm8-6H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 14H4V6h16v12z"/>
</SvgIcon>
);
ImageImageAspectRatio = pure(ImageImageAspectRatio);
ImageImageAspectRatio.displayName = 'ImageImageAspectRatio';
ImageImageAspectRatio.muiName = 'SvgIcon';
export default ImageImageAspectRatio;
|
assets/javascripts/kitten/components/structure/cards/summary-card/components/cell.js | KissKissBankBank/kitten | import React from 'react'
import classNames from 'classnames'
import PropTypes from 'prop-types'
export const Cell = ({ name, className, style, ...props }) => {
return (
<div
{...props}
className={classNames(
'k-SummaryCard__cell',
className,
`k-SummaryCard__cell__${name}`,
)}
style={{ ...style, '--summaryCardCell-name': name }}
/>
)
}
Cell.propTypes = {
name: PropTypes.string.isRequired,
}
|
src/search.js | baherami/bookapp | import * as BooksAPI from'./BooksAPI'
import React, { Component } from 'react';
import {Link } from 'react-router-dom';
import Shelf from './shelf'
class Search extends Component{
state = {
books:''
}
searchBooks=(e)=>{
e.preventDefault();
let searchTerm=e.target.value
BooksAPI.search(searchTerm,10).then((data)=>{
console.log('BooksAPI search finished')
this.setState({books:data})
})
}
render(){
let searchResult=this.state.books
return(
<div className="search-books">
<div className="search-books-bar">
<Link className="close-search" to="/">Close</Link>
<div className="search-books-input-wrapper">
<input type="text" onInput={this.searchBooks} name="search" placeholder="Search by title or author"/>
</div>
</div>
<Shelf onBookChange={this.props.onBookChange} shelfName="Search Results" shelfBooks={searchResult}/>
</div>
)}
}
export default Search;
|
app/components/Toggle/index.js | samit4me/react-boilerplate | /**
*
* LocaleToggle
*
*/
import React from 'react';
import Select from './Select';
import ToggleOption from '../ToggleOption';
function Toggle(props) {
let content = (<option>--</option>);
// If we have items, render them
if (props.values) {
content = props.values.map((value) => (
<ToggleOption key={value} value={value} message={props.messages[value]} />
));
}
return (
<Select value={props.value} onChange={props.onToggle}>
{content}
</Select>
);
}
Toggle.propTypes = {
onToggle: React.PropTypes.func,
values: React.PropTypes.array,
value: React.PropTypes.string,
messages: React.PropTypes.object,
};
export default Toggle;
|
source/common/components/Prompt/index.js | shery15/react | import React from 'react';
import {
BrowserRouter as Router,
Route,
Link,
Prompt
} from 'react-router-dom';
const PreventingTransitionsExample = () => (
<Router>
<div>
<ul>
<li><Link to="/">Form</Link></li>
<li><Link to="/one">One</Link></li>
<li><Link to="/two">Two</Link></li>
</ul>
<Route path="/" exact component={Form} />
<Route path="/one" render={() => <h3>One</h3>} />
<Route path="/two" render={() => <h3>Two</h3>} />
</div>
</Router>
);
class Form extends React.Component {
constructor(props) {
super(props);
this.state = {
isBlocking: false
};
}
render() {
const { isBlocking } = this.state;
return (
<form
onSubmit={(event) => {
event.preventDefault();
event.target.reset();
this.setState({
isBlocking: false
});
}}
>
<Prompt
when={isBlocking}
message={location => (
`Are you sure you want to go to ${location.pathname}`
)}
/>
<p>
Blocking? {isBlocking ? 'Yes, click a link or the back button' : 'Nope'}
</p>
<p>
<input
size="50"
placeholder="type something to block transitions"
onChange={(event) => {
this.setState({
isBlocking: event.target.value.length > 0
});
}}
/>
</p>
<p>
<button>Submit to stop blocking</button>
</p>
</form>
);
}
}
export default PreventingTransitionsExample;
|
src/parser/shared/modules/spells/bfa/azeritetraits/OverwhelmingPower.js | sMteX/WoWAnalyzer | import React from 'react';
import SPELLS from 'common/SPELLS';
import { formatPercentage } from 'common/format';
import { calculateAzeriteEffects } from 'common/stats';
import UptimeIcon from 'interface/icons/Uptime';
import HasteIcon from 'interface/icons/Haste';
import AzeritePowerStatistic from 'interface/statistics/AzeritePowerStatistic';
import BoringSpellValueText from 'interface/statistics/components/BoringSpellValueText';
import Analyzer from 'parser/core/Analyzer';
import StatTracker from 'parser/shared/modules/StatTracker';
const MAX_OVERWHELMING_POWER_STACKS = 25;
const overWhelmingPowerStats = traits => Object.values(traits).reduce((obj, rank) => {
const [haste] = calculateAzeriteEffects(SPELLS.OVERWHELMING_POWER.id, rank);
obj.haste += haste;
return obj;
}, {
haste: 0,
});
/**
* Overwhelming Power
* Gain 25 stacks of Overwhelming Power, granting x haste per stack
* Lose 1 stack each second and when taking damage (has a 1sec ICD independant of the normal decay)
*
* Example report: https://www.warcraftlogs.com/reports/jBthQCZcWRNGyAk1#fight=29&type=auras&source=18
*/
class OverWhelmingPower extends Analyzer {
static dependencies = {
statTracker: StatTracker,
};
haste = 0;
totalHaste = 0;
lastTimestamp = 0;
overwhelmingPowerProcs = 0;
currentStacks = 0;
constructor(...args) {
super(...args);
this.active = this.selectedCombatant.hasTrait(SPELLS.OVERWHELMING_POWER.id);
if (!this.active) {
return;
}
const { haste } = overWhelmingPowerStats(this.selectedCombatant.traitsBySpellId[SPELLS.OVERWHELMING_POWER.id]);
this.haste = haste;
this.statTracker.add(SPELLS.OVERWHELMING_POWER_BUFF.id, {
haste,
});
}
on_byPlayer_applybuff(event) {
this.handleStacks(event);
}
on_byPlayer_applybuffstack(event) {
this.handleStacks(event);
}
on_byPlayer_removebuff(event) {
this.handleStacks(event);
}
on_byPlayer_removebuffstack(event) {
this.handleStacks(event);
}
on_byPlayer_refreshbuff(event) {
this.handleStacks(event);
}
handleStacks(event) {
if (event.ability.guid !== SPELLS.OVERWHELMING_POWER_BUFF.id) {
return;
}
if (this.currentStacks !== 0 && this.lastTimestamp !== 0) {
const uptimeOnStack = event.timestamp - this.lastTimestamp;
this.totalHaste += this.currentStacks * this.haste * uptimeOnStack;
}
if (event.type === "applybuff") {
this.currentStacks = MAX_OVERWHELMING_POWER_STACKS;
} else if (event.type === "removebuff") {
this.currentStacks = 0;
} else {
this.currentStacks = event.stack;
}
if (this.currentStacks === MAX_OVERWHELMING_POWER_STACKS) {
this.overwhelmingPowerProcs += 1;
}
this.lastTimestamp = event.timestamp;
}
get uptime() {
return this.selectedCombatant.getBuffUptime(SPELLS.OVERWHELMING_POWER_BUFF.id) / this.owner.fightDuration;
}
get averageHaste() {
return (this.totalHaste / this.owner.fightDuration).toFixed(0);
}
statistic() {
return (
<AzeritePowerStatistic
size="flexible"
tooltip={(
<>
{SPELLS.OVERWHELMING_POWER.name} grants <strong>{this.haste} haste per stack</strong> ({this.haste * MAX_OVERWHELMING_POWER_STACKS} haste @{MAX_OVERWHELMING_POWER_STACKS} stacks) while active.<br />
You procced <strong>{SPELLS.OVERWHELMING_POWER.name} {this.overwhelmingPowerProcs} times</strong> with an uptime of {formatPercentage(this.uptime)}%.
</>
)}
>
<BoringSpellValueText
spell={SPELLS.OVERWHELMING_POWER}
>
<UptimeIcon /> {formatPercentage(this.uptime, 0)}% <small>uptime</small><br />
<HasteIcon /> {this.averageHaste} <small>average Haste gained</small>
</BoringSpellValueText>
</AzeritePowerStatistic>
);
}
}
export default OverWhelmingPower;
|
web/src/components/Pagination/index.js | trendmicro/serverless-survey-forms | /**
* @module Pagination
* Pagination component, only appeared if paging is more than one
*
**/
import styles from './style.css';
import React from 'react';
import PropTypes from 'prop-types';
import PureComponent from 'react-pure-render/component';
import classNames from 'classnames';
import Button from '../Button';
class Pagination extends PureComponent {
constructor() {
super();
this._prev = this._prev.bind(this);
this._next = this._next.bind(this);
this._done = this._done.bind(this);
}
render() {
const { settings, currentPage, pages } = this.props;
return (
<div
className={classNames({
[`${styles.pagination}`]: settings.type !== 'default',
[`${styles.paginationPreview}`]: settings.type === 'default',
'ut-pagination': true
})}
>
{
pages > 1 && currentPage < pages ?
<div
className={
settings.type === 'default' ?
styles.btnWrapperNextPreview : styles.btnWrapperNext
}
>
<Button
string={'next'}
onClick={this._next}
extraClass={{
'ut-next': true,
[`${styles.pagingBtnNext}`]: true
}}
/>
</div> : ''
}
{
pages > 1 && currentPage < pages ?
<div
className={classNames({
[`${styles.nextMobile}`]: true,
'ut-next': true
})}
onClick={this._next}
/> : ''
}
{
currentPage === pages ?
<div
className={
settings.type === 'default' ?
styles.btnWrapperNextPreview : styles.btnWrapperNext
}
>
<Button
string={'submit'}
onClick={this._done}
extraClass={{
'ut-done': true,
[`${styles.pagingBtnNext}`]: true
}}
/>
</div> : ''
}
{
currentPage === pages ?
<div
className={classNames({
[`${styles.doneMobile}`]: true,
'ut-done': true
})}
onClick={this._done}
/> : ''
}
{
pages > 1 ?
<div
className={
settings.type === 'default' ?
styles.progressWrapperPreview : styles.progressWrapper
}
>
<span
className={styles.progressText}
>
{`${currentPage} / ${pages}`}
</span>
<div
className={classNames({
[`${styles.progress}`]: (currentPage / pages) !== 1,
[`${styles.progressComplete}`]: (currentPage / pages) === 1
})}
style={{
width: `${((currentPage / pages) * 100)}%`
}}
/>
</div> : ''
}
</div>
);
}
_prev() {
this.props.feedbackActions.checkRequired('prev', this.props.currentPage - 1);
}
_next() {
this.props.feedbackActions.checkRequired('next', this.props.currentPage + 1);
}
_done() {
this.props.feedbackActions.checkRequired('done');
}
}
Pagination.propTypes = {
pages: PropTypes.number.isRequired,
currentPage: PropTypes.number
};
Pagination.defaultProps = {
currentPage: 1
};
export default Pagination;
|
app/javascript/mastodon/components/autosuggest_emoji.js | ashfurrow/mastodon | import React from 'react';
import PropTypes from 'prop-types';
import unicodeMapping from '../features/emoji/emoji_unicode_mapping_light';
import { assetHost } from 'mastodon/utils/config';
export default class AutosuggestEmoji extends React.PureComponent {
static propTypes = {
emoji: PropTypes.object.isRequired,
};
render () {
const { emoji } = this.props;
let url;
if (emoji.custom) {
url = emoji.imageUrl;
} else {
const mapping = unicodeMapping[emoji.native] || unicodeMapping[emoji.native.replace(/\uFE0F$/, '')];
if (!mapping) {
return null;
}
url = `${assetHost}/emoji/${mapping.filename}.svg`;
}
return (
<div className='autosuggest-emoji'>
<img
className='emojione'
src={url}
alt={emoji.native || emoji.colons}
/>
{emoji.colons}
</div>
);
}
}
|
actor-apps/app-web/src/app/components/activity/UserProfile.react.js | chengjunjian/actor-platform | import React from 'react';
import { PureRenderMixin } from 'react/addons';
import ContactActionCreators from 'actions/ContactActionCreators';
import DialogActionCreators from 'actions/DialogActionCreators';
import PeerStore from 'stores/PeerStore';
import DialogStore from 'stores/DialogStore';
import AvatarItem from 'components/common/AvatarItem.react';
import UserProfileContactInfo from 'components/activity/UserProfileContactInfo.react';
const getStateFromStores = (userId) => {
const thisPeer = PeerStore.getUserPeer(userId);
return {
thisPeer: thisPeer,
isNotificationsEnabled: DialogStore.isNotificationsEnabled(thisPeer)
};
};
var UserProfile = React.createClass({
propTypes: {
user: React.PropTypes.object.isRequired
},
mixins: [PureRenderMixin],
getInitialState() {
return getStateFromStores(this.props.user.id);
},
componentWillMount() {
DialogStore.addNotificationsListener(this.whenNotificationChanged);
},
componentWillUnmount() {
DialogStore.removeNotificationsListener(this.whenNotificationChanged);
},
componentWillReceiveProps(newProps) {
this.setState(getStateFromStores(newProps.user.id));
},
addToContacts() {
ContactActionCreators.addContact(this.props.user.id);
},
removeFromContacts() {
ContactActionCreators.removeContact(this.props.user.id);
},
onNotificationChange(event) {
DialogActionCreators.changeNotificationsEnabled(this.state.thisPeer, event.target.checked);
},
whenNotificationChanged() {
this.setState(getStateFromStores(this.props.user.id));
},
render() {
const user = this.props.user;
const isNotificationsEnabled = this.state.isNotificationsEnabled;
let addToContacts;
if (user.isContact === false) {
addToContacts = <a className="link__blue" onClick={this.addToContacts}>Add to contacts</a>;
} else {
addToContacts = <a className="link__red" onClick={this.removeFromContacts}>Remove from contacts</a>;
}
return (
<div className="activity__body profile">
<div className="profile__name">
<AvatarItem image={user.bigAvatar}
placeholder={user.placeholder}
size="medium"
title={user.name}/>
<h3>{user.name}</h3>
</div>
<div className="notifications">
<label htmlFor="notifications">Enable Notifications</label>
<div className="switch pull-right">
<input checked={isNotificationsEnabled} id="notifications" onChange={this.onNotificationChange} type="checkbox"/>
<label htmlFor="notifications"></label>
</div>
</div>
<UserProfileContactInfo phones={user.phones}/>
<ul className="profile__list profile__list--usercontrols">
<li className="profile__list__item">
{addToContacts}
</li>
</ul>
</div>
);
}
});
export default UserProfile;
|
app/javascript/mastodon/components/missing_indicator.js | Nyoho/mastodon | import React from 'react';
import PropTypes from 'prop-types';
import { FormattedMessage } from 'react-intl';
import illustration from 'mastodon/../images/elephant_ui_disappointed.svg';
import classNames from 'classnames';
const MissingIndicator = ({ fullPage }) => (
<div className={classNames('regeneration-indicator', { 'regeneration-indicator--without-header': fullPage })}>
<div className='regeneration-indicator__figure'>
<img src={illustration} alt='' />
</div>
<div className='regeneration-indicator__label'>
<FormattedMessage id='missing_indicator.label' tagName='strong' defaultMessage='Not found' />
<FormattedMessage id='missing_indicator.sublabel' defaultMessage='This resource could not be found' />
</div>
</div>
);
MissingIndicator.propTypes = {
fullPage: PropTypes.bool,
};
export default MissingIndicator;
|
src/shared/components/modal/modal.js | OperationCode/operationcode_frontend | import React from 'react';
import PropTypes from 'prop-types';
import ReactModal from 'react-modal';
import Section from 'shared/components/section/section';
import styles from './modal.css';
const Modal = ({
isOpen, title, onRequestClose, children
}) => (
<ReactModal
isOpen={isOpen}
contentLabel={title}
shouldCloseOnOverlayClick
onRequestClose={onRequestClose}
>
<Section title={title} theme="white" className={styles.modal}>
<div className={styles.scrollable}>
{children}
</div>
</Section>
<button className={styles.close} onClick={() => onRequestClose()} />
</ReactModal>
);
Modal.propTypes = {
children: PropTypes.element,
isOpen: PropTypes.bool,
onRequestClose: PropTypes.func,
title: PropTypes.string
};
Modal.defaultProps = {
children: <span />,
isOpen: false,
onRequestClose: () => {},
title: ''
};
export default Modal;
|
frontend/src/Settings/Profiles/Quality/EditQualityProfileModalContentConnector.js | lidarr/Lidarr | import _ from 'lodash';
import PropTypes from 'prop-types';
import React, { Component } from 'react';
import { connect } from 'react-redux';
import { createSelector } from 'reselect';
import { fetchQualityProfileSchema, saveQualityProfile, setQualityProfileValue } from 'Store/Actions/settingsActions';
import createProfileInUseSelector from 'Store/Selectors/createProfileInUseSelector';
import createProviderSettingsSelector from 'Store/Selectors/createProviderSettingsSelector';
import EditQualityProfileModalContent from './EditQualityProfileModalContent';
function getQualityItemGroupId(qualityProfile) {
// Get items with an `id` and filter out null/undefined values
const ids = _.filter(_.map(qualityProfile.items.value, 'id'), (i) => i != null);
return Math.max(1000, ...ids) + 1;
}
function parseIndex(index) {
const split = index.split('.');
if (split.length === 1) {
return [
null,
parseInt(split[0]) - 1
];
}
return [
parseInt(split[0]) - 1,
parseInt(split[1]) - 1
];
}
function createQualitiesSelector() {
return createSelector(
createProviderSettingsSelector('qualityProfiles'),
(qualityProfile) => {
const items = qualityProfile.item.items;
if (!items || !items.value) {
return [];
}
return _.reduceRight(items.value, (result, { allowed, id, name, quality }) => {
if (allowed) {
if (id) {
result.push({
key: id,
value: name
});
} else {
result.push({
key: quality.id,
value: quality.name
});
}
}
return result;
}, []);
}
);
}
function createMapStateToProps() {
return createSelector(
createProviderSettingsSelector('qualityProfiles'),
createQualitiesSelector(),
createProfileInUseSelector('qualityProfileId'),
(qualityProfile, qualities, isInUse) => {
return {
qualities,
...qualityProfile,
isInUse
};
}
);
}
const mapDispatchToProps = {
fetchQualityProfileSchema,
setQualityProfileValue,
saveQualityProfile
};
class EditQualityProfileModalContentConnector extends Component {
//
// Lifecycle
constructor(props, context) {
super(props, context);
this.state = {
dragQualityIndex: null,
dropQualityIndex: null,
dropPosition: null,
editGroups: false
};
}
componentDidMount() {
if (!this.props.id && !this.props.isPopulated) {
this.props.fetchQualityProfileSchema();
}
}
componentDidUpdate(prevProps, prevState) {
if (prevProps.isSaving && !this.props.isSaving && !this.props.saveError) {
this.props.onModalClose();
}
}
//
// Control
ensureCutoff = (qualityProfile) => {
const cutoff = qualityProfile.cutoff.value;
const cutoffItem = _.find(qualityProfile.items.value, (i) => {
if (!cutoff) {
return false;
}
return i.id === cutoff || (i.quality && i.quality.id === cutoff);
});
// If the cutoff isn't allowed anymore or there isn't a cutoff set one
if (!cutoff || !cutoffItem || !cutoffItem.allowed) {
const firstAllowed = _.find(qualityProfile.items.value, { allowed: true });
let cutoffId = null;
if (firstAllowed) {
cutoffId = firstAllowed.quality ? firstAllowed.quality.id : firstAllowed.id;
}
this.props.setQualityProfileValue({ name: 'cutoff', value: cutoffId });
}
}
//
// Listeners
onInputChange = ({ name, value }) => {
this.props.setQualityProfileValue({ name, value });
}
onCutoffChange = ({ name, value }) => {
const id = parseInt(value);
const item = _.find(this.props.item.items.value, (i) => {
if (i.quality) {
return i.quality.id === id;
}
return i.id === id;
});
const cutoffId = item.quality ? item.quality.id : item.id;
this.props.setQualityProfileValue({ name, value: cutoffId });
}
onSavePress = () => {
this.props.saveQualityProfile({ id: this.props.id });
}
onQualityProfileItemAllowedChange = (id, allowed) => {
const qualityProfile = _.cloneDeep(this.props.item);
const items = qualityProfile.items.value;
const item = _.find(qualityProfile.items.value, (i) => i.quality && i.quality.id === id);
item.allowed = allowed;
this.props.setQualityProfileValue({
name: 'items',
value: items
});
this.ensureCutoff(qualityProfile);
}
onItemGroupAllowedChange = (id, allowed) => {
const qualityProfile = _.cloneDeep(this.props.item);
const items = qualityProfile.items.value;
const item = _.find(qualityProfile.items.value, (i) => i.id === id);
item.allowed = allowed;
// Update each item in the group (for consistency only)
item.items.forEach((i) => {
i.allowed = allowed;
});
this.props.setQualityProfileValue({
name: 'items',
value: items
});
this.ensureCutoff(qualityProfile);
}
onItemGroupNameChange = (id, name) => {
const qualityProfile = _.cloneDeep(this.props.item);
const items = qualityProfile.items.value;
const group = _.find(items, (i) => i.id === id);
group.name = name;
this.props.setQualityProfileValue({
name: 'items',
value: items
});
}
onCreateGroupPress = (id) => {
const qualityProfile = _.cloneDeep(this.props.item);
const items = qualityProfile.items.value;
const item = _.find(items, (i) => i.quality && i.quality.id === id);
const index = items.indexOf(item);
const groupId = getQualityItemGroupId(qualityProfile);
const group = {
id: groupId,
name: item.quality.name,
allowed: item.allowed,
items: [
item
]
};
// Add the group in the same location the quality item was in.
items.splice(index, 1, group);
this.props.setQualityProfileValue({
name: 'items',
value: items
});
this.ensureCutoff(qualityProfile);
}
onDeleteGroupPress = (id) => {
const qualityProfile = _.cloneDeep(this.props.item);
const items = qualityProfile.items.value;
const group = _.find(items, (i) => i.id === id);
const index = items.indexOf(group);
// Add the items in the same location the group was in
items.splice(index, 1, ...group.items);
this.props.setQualityProfileValue({
name: 'items',
value: items
});
this.ensureCutoff(qualityProfile);
}
onQualityProfileItemDragMove = (options) => {
const {
dragQualityIndex,
dropQualityIndex,
dropPosition
} = options;
const [dragGroupIndex, dragItemIndex] = parseIndex(dragQualityIndex);
const [dropGroupIndex, dropItemIndex] = parseIndex(dropQualityIndex);
if (
(dropPosition === 'below' && dropItemIndex - 1 === dragItemIndex) ||
(dropPosition === 'above' && dropItemIndex + 1 === dragItemIndex)
) {
if (
this.state.dragQualityIndex != null &&
this.state.dropQualityIndex != null &&
this.state.dropPosition != null
) {
this.setState({
dragQualityIndex: null,
dropQualityIndex: null,
dropPosition: null
});
}
return;
}
let adjustedDropQualityIndex = dropQualityIndex;
// Correct dragging out of a group to the position above
if (
dropPosition === 'above' &&
dragGroupIndex !== dropGroupIndex &&
dropGroupIndex != null
) {
// Add 1 to the group index and 2 to the item index so it's inserted above in the correct group
adjustedDropQualityIndex = `${dropGroupIndex + 1}.${dropItemIndex + 2}`;
}
// Correct inserting above outside a group
if (
dropPosition === 'above' &&
dragGroupIndex !== dropGroupIndex &&
dropGroupIndex == null
) {
// Add 2 to the item index so it's entered in the correct place
adjustedDropQualityIndex = `${dropItemIndex + 2}`;
}
// Correct inserting below a quality within the same group (when moving a lower item)
if (
dropPosition === 'below' &&
dragGroupIndex === dropGroupIndex &&
dropGroupIndex != null &&
dragItemIndex < dropItemIndex
) {
// Add 1 to the group index leave the item index
adjustedDropQualityIndex = `${dropGroupIndex + 1}.${dropItemIndex}`;
}
// Correct inserting below a quality outside a group (when moving a lower item)
if (
dropPosition === 'below' &&
dragGroupIndex === dropGroupIndex &&
dropGroupIndex == null &&
dragItemIndex < dropItemIndex
) {
// Leave the item index so it's inserted below the item
adjustedDropQualityIndex = `${dropItemIndex}`;
}
if (
dragQualityIndex !== this.state.dragQualityIndex ||
adjustedDropQualityIndex !== this.state.dropQualityIndex ||
dropPosition !== this.state.dropPosition
) {
this.setState({
dragQualityIndex,
dropQualityIndex: adjustedDropQualityIndex,
dropPosition
});
}
}
onQualityProfileItemDragEnd = (didDrop) => {
const {
dragQualityIndex,
dropQualityIndex
} = this.state;
if (didDrop && dropQualityIndex != null) {
const qualityProfile = _.cloneDeep(this.props.item);
const items = qualityProfile.items.value;
const [dragGroupIndex, dragItemIndex] = parseIndex(dragQualityIndex);
const [dropGroupIndex, dropItemIndex] = parseIndex(dropQualityIndex);
let item = null;
let dropGroup = null;
// Get the group before moving anything so we know the correct place to drop it.
if (dropGroupIndex != null) {
dropGroup = items[dropGroupIndex];
}
if (dragGroupIndex == null) {
item = items.splice(dragItemIndex, 1)[0];
} else {
const group = items[dragGroupIndex];
item = group.items.splice(dragItemIndex, 1)[0];
// If the group is now empty, destroy it.
if (!group.items.length) {
items.splice(dragGroupIndex, 1);
}
}
if (dropGroupIndex == null) {
items.splice(dropItemIndex, 0, item);
} else {
dropGroup.items.splice(dropItemIndex, 0, item);
}
this.props.setQualityProfileValue({
name: 'items',
value: items
});
this.ensureCutoff(qualityProfile);
}
this.setState({
dragQualityIndex: null,
dropQualityIndex: null,
dropPosition: null
});
}
onToggleEditGroupsMode = () => {
this.setState({ editGroups: !this.state.editGroups });
}
//
// Render
render() {
if (_.isEmpty(this.props.item.items) && !this.props.isFetching) {
return null;
}
return (
<EditQualityProfileModalContent
{...this.state}
{...this.props}
onSavePress={this.onSavePress}
onInputChange={this.onInputChange}
onCutoffChange={this.onCutoffChange}
onCreateGroupPress={this.onCreateGroupPress}
onDeleteGroupPress={this.onDeleteGroupPress}
onQualityProfileItemAllowedChange={this.onQualityProfileItemAllowedChange}
onItemGroupAllowedChange={this.onItemGroupAllowedChange}
onItemGroupNameChange={this.onItemGroupNameChange}
onQualityProfileItemDragMove={this.onQualityProfileItemDragMove}
onQualityProfileItemDragEnd={this.onQualityProfileItemDragEnd}
onToggleEditGroupsMode={this.onToggleEditGroupsMode}
/>
);
}
}
EditQualityProfileModalContentConnector.propTypes = {
id: PropTypes.number,
isFetching: PropTypes.bool.isRequired,
isPopulated: PropTypes.bool.isRequired,
isSaving: PropTypes.bool.isRequired,
saveError: PropTypes.object,
item: PropTypes.object.isRequired,
setQualityProfileValue: PropTypes.func.isRequired,
fetchQualityProfileSchema: PropTypes.func.isRequired,
saveQualityProfile: PropTypes.func.isRequired,
onModalClose: PropTypes.func.isRequired
};
export default connect(createMapStateToProps, mapDispatchToProps)(EditQualityProfileModalContentConnector);
|
client/admin/info/DescriptionList.js | subesokun/Rocket.Chat | import { Box, Table } from '@rocket.chat/fuselage';
import React from 'react';
const style = { wordBreak: 'break-word' };
export const DescriptionList = ({ children, title, ...props }) => <>
{title && <Box display='flex' justifyContent='flex-end' width='30%' paddingInline='x8'>
{title}
</Box>}
<Table striped marginBlockEnd='x32' width='full' {...props}>
<Table.Body>
{children}
</Table.Body>
</Table>
</>;
const Entry = ({ children, label, ...props }) =>
<Table.Row {...props}>
<Table.Cell is='th' scope='col' width='30%' align='end' color='hint' backgroundColor='surface' fontScale='p2' style={style}>{label}</Table.Cell>
<Table.Cell width='70%' align='start' color='default' style={style}>{children}</Table.Cell>
</Table.Row>;
DescriptionList.Entry = Entry;
|
node_modules/react-bootstrap/es/Row.js | premcool/getmydeal | import _extends from 'babel-runtime/helpers/extends';
import _objectWithoutProperties from 'babel-runtime/helpers/objectWithoutProperties';
import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn';
import _inherits from 'babel-runtime/helpers/inherits';
import classNames from 'classnames';
import React from 'react';
import elementType from 'react-prop-types/lib/elementType';
import { bsClass, getClassSet, splitBsProps } from './utils/bootstrapUtils';
var propTypes = {
componentClass: elementType
};
var defaultProps = {
componentClass: 'div'
};
var Row = function (_React$Component) {
_inherits(Row, _React$Component);
function Row() {
_classCallCheck(this, Row);
return _possibleConstructorReturn(this, _React$Component.apply(this, arguments));
}
Row.prototype.render = function render() {
var _props = this.props,
Component = _props.componentClass,
className = _props.className,
props = _objectWithoutProperties(_props, ['componentClass', 'className']);
var _splitBsProps = splitBsProps(props),
bsProps = _splitBsProps[0],
elementProps = _splitBsProps[1];
var classes = getClassSet(bsProps);
return React.createElement(Component, _extends({}, elementProps, {
className: classNames(className, classes)
}));
};
return Row;
}(React.Component);
Row.propTypes = propTypes;
Row.defaultProps = defaultProps;
export default bsClass('row', Row); |
src/routes/workTeamManager/RequestsView.js | nambawan/g-old | import React from 'react';
import PropTypes from 'prop-types';
import Request from '../../components/Request';
import AssetsTable from '../../components/AssetsTable';
import RequestRow from './RequestRow';
const RequestsView = ({
showRequest,
updates,
request,
onAllowRequest,
onDenyRequest,
onCancel,
onRequestClick,
requests,
}) => {
if (showRequest) {
return (
<Request
onAllow={onAllowRequest}
onDeny={onDenyRequest}
onCancel={onCancel}
{...request}
updates={updates}
/>
);
}
return (
<AssetsTable
onClickMenu={onRequestClick}
allowMultiSelect
searchTerm=""
noRequestsFound="No requests found"
checkedIndices={[]}
assets={requests || []}
row={RequestRow}
tableHeaders={['Requester', 'Created', 'Denied', 'Processor']}
/>
);
};
RequestsView.propTypes = {
showRequest: PropTypes.func.isRequired,
updates: PropTypes.shape({}).isRequired,
request: PropTypes.shape({}).isRequired,
onAllowRequest: PropTypes.func.isRequired,
onDenyRequest: PropTypes.func.isRequired,
onCancel: PropTypes.func.isRequired,
onRequestClick: PropTypes.func.isRequired,
requests: PropTypes.arrayOf(PropTypes.shape({})).isRequired,
};
export default RequestsView;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.