path
stringlengths 5
296
| repo_name
stringlengths 5
85
| content
stringlengths 25
1.05M
|
|---|---|---|
source/patterns/00-atoms/progress-tracker-step/__tests__/progress-tracker-step.spec.js
|
apparena/patterns
|
/* eslint-env mocha */
import React from 'react';
import {shallow, mount, configure} from 'enzyme';
import {spy} from 'sinon';
import ProgressTrackerStep from '../index';
import style from '../index.module.scss';
import Adapter from 'enzyme-adapter-react-16';
configure({adapter: new Adapter()});
test('DUMMY', () => {
expect(true).toBe(true);
});
/*test('one inactive step', (t) => {
const wrapper = shallow(
<ProgressTrackerStep/>
);
t.is(wrapper.find(`.${style['progress-tracker-step-active']}`).length, 0);
});
test('one active step', (t) => {
const wrapper = shallow(
<ProgressTrackerStep active />
);
t.is(wrapper.find(`.${style['progress-tracker-step-active']}`).length, 1);
});
test('two steps one active', (t) => {
const wrapper = shallow(
<div>
<ProgressTrackerStep active/>
<ProgressTrackerStep/>
</div>
);
t.is(wrapper.html().includes('progress-tracker-step'), true);
t.is(wrapper.html().includes('progress-tracker-step-active'), true);
});
test('reacts on change', (t) => {
const onClick = spy();
const wrapper = mount(
<div>
<ProgressTrackerStep onClick={onClick}/>
</div>
);
t.is(wrapper.html().includes('progress-tracker-step'), true);
wrapper.find('li').simulate('click');
t.is(onClick.calledOnce, true)
});
*/
|
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'))
|
RefreshDemo/__tests__/index.android.js
|
shiwenwen/react-native-swRefresh
|
import 'react-native';
import React from 'react';
import Index from '../index.android.js';
// Note: test renderer must be required after react-native.
import renderer from 'react-test-renderer';
it('renders correctly', () => {
const tree = renderer.create(
<Index />
);
});
|
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;
|
app/components/__tests__/App_test.js
|
keathley/webpack-react-skeleton
|
import React from 'react'
import { shallow } from 'enzyme'
import { expect } from 'chai'
import App from '../App'
describe('App', () => {
it('renders', () => {
const component = shallow(<App />)
expect(component.find('h1').text()).to.equal("Test Application")
})
})
|
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="jane.doe@example.com"/>
</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;
|
test/daypicker/localization.js
|
saenglert/react-day-picker
|
import React from 'react';
import { mount } from 'enzyme';
import DayPicker from '../../src/DayPicker';
import * as LocaleUtils from '../../src/LocaleUtils';
describe('DayPicker’s localization', () => {
it('should use the months prop to localize the month names', () => {
const wrapper = mount(
<DayPicker
initialMonth={new Date(2015, 0)}
months={[
'Gennaio',
'Febbraio',
'Marzo',
'Aprile',
'Maggio',
'Giugno',
'Luglio',
'Agosto',
'Settembre',
'Ottobre',
'Novembre',
'Dicembre',
]}
/>
);
expect(wrapper.find('.DayPicker-Caption')).toHaveText('Gennaio 2015');
});
it('should use the firstDayOfWeek prop to set the first day of the week', () => {
const wrapper = mount(
<DayPicker initialMonth={new Date(2015, 0)} firstDayOfWeek={1} />
);
expect(wrapper.find('.DayPicker-Weekday').first()).toHaveText('Mo');
expect(wrapper.find('.DayPicker-Day').at(3)).toHaveText('1');
});
it('should use the weekdaysShort prop to localize the weekday names', () => {
const wrapper = mount(
<DayPicker
initialMonth={new Date(2015, 0)}
weekdaysShort={['Do', 'Lu', 'Ma', 'Me', 'Gi', 'Ve', 'Sa']}
/>
);
expect(wrapper.find('.DayPicker-Weekday').first()).toHaveText('Do');
});
it('should use the weekdaysLong prop to localize the weekday names', () => {
const wrapper = mount(
<DayPicker
initialMonth={new Date(2015, 0)}
weekdaysLong={[
'Domenica',
'Lunedì',
'Martedì',
'Mercoledì',
'Giovedì',
'Venerdì',
'Sabato',
]}
/>
);
expect(wrapper.find('.DayPicker-Weekday > abbr').first()).toHaveProp(
'title',
'Domenica'
);
});
it('should render weekday labels accounting for locale settings', () => {
const localeUtils = Object.assign({}, LocaleUtils, {
getFirstDayOfWeek: () => 1,
});
const wrapper = mount(<DayPicker localeUtils={localeUtils} />);
expect(wrapper.find('.DayPicker-Weekday').first()).toHaveText('Mo');
});
});
|
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);
|
tests/PlayerRow.spec.js
|
flocks/deeprun-front
|
import React from 'react';
import renderer from 'react-test-renderer';
import PlayerRow from '../app/components/PlayerRow';
describe('<PlayerRow />', () => {
it('should render properly with empty value', () => {
const component = renderer.create(
<PlayerRow
label="player 1"
/>
);
const tree = component.toJSON();
expect(tree).toMatchSnapshot();
});
it('should render properly with cards', () => {
const cards = 'AhKd';
const component = renderer.create(
<PlayerRow
label="player 1"
equity={45}
cards={cards}
/>
);
const tree = component.toJSON();
expect(tree).toMatchSnapshot();
});
});
|
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);
|
swagger-editor/test/unit/plugins/editor/editor.js
|
thomaxxl/safrs
|
import rewiremock from 'rewiremock';
import Enzyme, { shallow } from 'enzyme';
import Adapter from '@wojtekmaj/enzyme-adapter-react-17';
import React from 'react';
import FakeAce, { Session } from 'test/unit/mocks/ace.js';
import { fromJS } from 'immutable';
import makeEditor from 'plugins/editor/components/editor';
const pause = (ms) => new Promise((res) => setTimeout(res, ms));
const EVENTUALLY = 900; // ms
/**
* We're mocking out the editor,
* so uses of the phrase "should see this in editor",
* will match to the following Ace methods:
*
* - "what user see's in editor" => fakeAce.userSees()
* - "user types something (end of document)" => fakeAce.userTypes("hi")
* - "Ctrl-Z" => fakeAce.userUndo()
* - "Ctrl-Shift-Z" => fakeAce.userRedo()
**/
describe('editor', () => {
beforeAll(() => {
// Enzyme.configure({ adapter: new Adapter()})
Enzyme.configure({ adapter: new Adapter()});
// Whole bunch of mocks!
rewiremock.enable();
rewiremock('brace/mode/yaml').with({});
rewiremock('brace/theme/tomorrow_night_eighties').with({});
rewiremock('brace/ext/language_tools').with({});
rewiremock('brace/ext/searchbox').with({});
rewiremock('./brace-snippets-yaml').with({});
rewiremock('./editor.less').with({});
});
afterAll(() => {
rewiremock.disable();
});
beforeEach(() => {
// delete require.cache[require.resolve("react-ace")]
});
describe('fake ace', () => {
it('should be an event emitter', () => {
// Given
const fakeAce = new FakeAce();
const spy = jest.fn();
fakeAce.on('foo', spy);
// When
fakeAce.emit('foo', 'bar');
// Then
expect(spy.mock.calls.length).toEqual(1);
expect(spy.mock.calls[0][0]).toEqual('bar');
});
it('should return `this`, when calling .edit', () => {
// Given
const fakeAce = new FakeAce();
// When
const res = fakeAce.edit();
// Then
expect(res).toBe(fakeAce);
});
it('should keep track of setValue', () => {
// Given
const fakeAce = new FakeAce();
// When
fakeAce.setValue('foo');
// Then
const res = fakeAce.getValue();
expect(res).toEqual('foo');
});
it('should spy on setValue', () => {
// Given
const fakeAce = new FakeAce();
// When
fakeAce.setValue('foo');
// Then
expect(fakeAce.setValue.mock.calls.length).toEqual(1);
expect(fakeAce.setValue.mock.calls[0][0]).toEqual('foo');
});
it('should return a single session, with getSession', () => {
// Given
const fakeAce = new FakeAce();
// When
const res = fakeAce.getSession();
// Then
expect(res).toBeInstanceOf(Session);
});
it('should add options via setOptions', () => {
// Given
const fakeAce = new FakeAce();
// When
fakeAce.setOptions({one: 'uno'});
// Then
const res = fakeAce.getOption('one');
expect(res).toEqual('uno');
});
describe('userUndo/Redo', () => {
it('should revert to last input', () => {
// Given
const fakeAce = new FakeAce();
fakeAce.userTypes('one');
// When
fakeAce.userTypes('two');
// Then
fakeAce.userUndo();
expect(fakeAce.userSees()).toEqual('one');
});
it('should revert to empty document, no changes were made', () => {
// Given
const fakeAce = new FakeAce();
// When
fakeAce.userUndo();
// Then
expect(fakeAce.userSees()).toEqual('');
});
it('should revert to empty document, after arbitrary undos', () => {
// Given
const fakeAce = new FakeAce();
// When
fakeAce.userUndo();
fakeAce.userUndo();
fakeAce.userUndo();
fakeAce.userUndo();
// Then
expect(fakeAce.userSees()).toEqual('');
});
it('should not extend redos after last change', () => {
// Given
const fakeAce = new FakeAce();
fakeAce.userTypes('x');
// When
fakeAce.userRedo();
fakeAce.userRedo();
fakeAce.userRedo();
// Then
expect(fakeAce.userSees()).toEqual('x');
});
it('should allow redo after single undo', () => {
// Given
const fakeAce = new FakeAce();
fakeAce.userTypes('x');
fakeAce.userTypes('x');
fakeAce.userUndo();
// When
fakeAce.userRedo();
// Then
expect(fakeAce.userSees()).toEqual('xx');
});
it('should create new thread of undo stack, after new change', () => {
// Given
const fakeAce = new FakeAce();
fakeAce.userTypes('1');
fakeAce.userTypes('2');
fakeAce.userTypes('3');
fakeAce.userTypes('4');
fakeAce.userUndo(); // 123
fakeAce.userUndo(); // 12
fakeAce.userTypes('5'); // 125
// When
fakeAce.userRedo(); // 125, don't extend beyond
// Then
expect(fakeAce.userSees()).toEqual('125');
});
});
describe('fake session', () => {
it('should keep add state for markers', () => {
// Given
const fakeAce = new FakeAce();
const fakeSession = fakeAce.getSession();
// When
fakeSession.addMarker({one: 1});
// Then
const res = fakeSession.getMarkers();
// expect(typeof res).toBe("array")
expect(res).toBeInstanceOf(Array);
expect(res.length).toEqual(1);
expect(res[0]).toEqual({id: 0, one: 1});
});
it('should keep remove state for markers', () => {
// Given
const fakeAce = new FakeAce();
const fakeSession = fakeAce.getSession();
fakeSession.addMarker({one: 1});
// When
fakeSession.removeMarker(0);
// Then
const res = fakeSession.getMarkers();
// expect(typeof res).toBe("array")
expect(res).toBeInstanceOf(Array);
expect(res.length).toEqual(0);
});
it('should spy on addMarker', () => {
// Given
const fakeAce = new FakeAce();
const fakeSession = fakeAce.getSession();
// When
fakeSession.addMarker({one: 1});
// Then
expect(fakeSession.addMarker.mock.calls.length).toEqual(1);
});
it('should spy on setMode', () => {
// Given
const fakeAce = new FakeAce();
const fakeSession = fakeAce.getSession();
// When
fakeSession.setMode();
// Then
expect(fakeSession.setMode.mock.calls.length).toEqual(1);
});
it('should have a .selection which includes toJSON, fromJSON', () => {
// Given
const fakeAce = new FakeAce();
// When
const fakeSession = fakeAce.getSession();
// Then
expect(Object.keys(fakeSession.selection)).toContain('toJSON');
expect(Object.keys(fakeSession.selection)).toContain('fromJSON');
});
describe('userTypes', () => {
it('should emit \'change\'', () => {
// Given
const fakeAce = new FakeAce();
const spy = jest.fn();
fakeAce.on('change', spy);
// When
fakeAce.userTypes('hello');
// Then
expect(spy.mock.calls.length).toBeGreaterThan(1);
});
it('should change the value', () => {
// Given
const fakeAce = new FakeAce();
// When
fakeAce.userTypes('hello');
// Then
expect(fakeAce.getValue()).toEqual('hello');
});
});
describe('userSees', () => {
it('should match userTypes', () => {
// Given
const fakeAce = new FakeAce();
// When
fakeAce.userTypes('hi');
// Then
const res = fakeAce.userSees();
expect(res).toEqual('hi');
});
it('should match setValue', () => {
// Given
const fakeAce = new FakeAce();
// When
fakeAce.setValue('hello');
// Then
const res = fakeAce.userSees();
expect(res).toEqual('hello');
});
});
});
describe('renderer', () => {
it('should have a stub for setShowGutter', () => {
// Given
const fakeAce = new FakeAce();
// When
fakeAce.renderer.setShowGutter('foo');
// Then
expect(fakeAce.renderer.setShowGutter.mock.calls.length).toEqual(1);
expect(fakeAce.renderer.setShowGutter.mock.calls[0][0]).toEqual('foo');
});
});
});
describe.skip('editor component', () => {
it('should EVENTUALLY call onChange when user enters input', (done) => {
// Given
const fakeAce = new FakeAce();
rewiremock('brace').with(fakeAce);
// we should not use require
// const makeEditor = require("plugins/editor/components/editor.jsx").default
const Editor = makeEditor({});
const spy = jest.fn();
const wrapper = shallow(
<Editor onChange={spy} />
);
wrapper
.find('ReactAce').shallow();
// When
// Simulate user input
fakeAce.userTypes('hello');
// Then
setTimeout(() => {
expect(spy.mock.calls.length).toEqual(1);
expect(spy.mock.calls[0][0]).toEqual('hello');
done();
}, EVENTUALLY);
});
it(
'should EVENTUALLY put the contents of `value` prop into editor, without regard to `origin` property',
(done) => {
// Given
const fakeAce = new FakeAce();
rewiremock('brace').with(fakeAce);
// const makeEditor = require("plugins/editor/components/editor.jsx").default
const Editor = makeEditor({});
// When
const wrapper = shallow(
<Editor value={'original value'} />
);
wrapper.find('ReactAce').shallow();
// Then
setTimeout(() => {
expect(fakeAce.userSees()).toEqual('original value');
done();
}, EVENTUALLY);
}
);
it(
'should EVENTUALLY put the contents of `value` prop into editor, with `foo` origin property ',
(done) => {
// Given
const fakeAce = new FakeAce();
rewiremock('brace').with(fakeAce);
// const makeEditor = require("plugins/editor/components/editor.jsx").default
const Editor = makeEditor({});
// When
const wrapper = shallow(
<Editor value={'original value'} origin="foo" />
);
wrapper.find('ReactAce').shallow();
// Then
setTimeout(() => {
expect(fakeAce.userSees()).toEqual('original value');
done();
}, EVENTUALLY);
}
);
it('should NEVER update ace if the yaml originated in editor', async () => {
// Given
const fakeAce = new FakeAce();
rewiremock('brace').with(fakeAce);
// const makeEditor = require("plugins/editor/components/editor.jsx").default
const Editor = makeEditor({});
// When
const wrapper = shallow(
<Editor value="original value" />
);
wrapper.find('ReactAce').shallow();
wrapper.setProps({value: 'new value', origin: 'editor'});
// Then
await pause(EVENTUALLY);
expect(fakeAce.userSees()).toEqual('original value');
});
// SKIPPED: Does this have any value at this level? And not editor-container?
it.skip(
'SKIP: should EVENTUALLY call onChange ONCE if the user types/pauses/types',
async function() {
this.timeout(10000);
// Given
const fakeAce = new FakeAce();
rewiremock('brace').with(fakeAce);
// const makeEditor = require("plugins/editor/components/editor.jsx").default
const Editor = makeEditor({});
const spy = jest.fn();
const wrapper = shallow(
<Editor value="original value" onChange={spy}/>
);
wrapper.find('ReactAce').shallow();
// When
fakeAce.userTypes(' one');
await pause(EVENTUALLY / 2);
fakeAce.userTypes('two');
await pause(EVENTUALLY / 2);
fakeAce.userTypes('three');
await pause(EVENTUALLY / 2);
await pause(EVENTUALLY * 2);
expect(fakeAce.userSees()).toEqual('original value onetwothree');
expect(spy.mock.calls.length).toEqual(1);
}
);
it('should EVENTUALLY call onChange when ctrl-z', async () => {
// Given
const fakeAce = new FakeAce();
rewiremock('react-ace').with(fakeAce);
// const makeEditor2 = require("plugins/editor/components/editor.jsx").default
const Editor = makeEditor({});
const spy = jest.fn();
const wrapper = shallow(
<Editor value="original value CTRL-Z" onChange={spy}/>
);
/** Dev wip notes:
* At this point rendering Editor with the above value is correct
* e.g. the "render once of this.props.value" includes "CTRL-Z"
* But using fakeAce.userSees() yields "undefined", returning ""
* Then, after fakeAce.userTypes(), spy.mock.calls.length still === 0
* So Editor component is not seeing the rewired fakeAce
*/
// wrapper.find("ReactAce").shallow()
await wrapper.instance().busy;
// console.log("DEBUG here")
// expect(fakeAce.userSees()).toEqual("original value")
// expect(wrapper.find("ReactAce")).toHaveLength(1) // pass, but why pass?
fakeAce.userTypes('one');
expect(fakeAce.userSees()).toEqual('one');
await pause(EVENTUALLY);
// second wip: 2nd user input
fakeAce.userTypes('two');
expect(fakeAce.userSees()).toEqual('onetwo');
expect(spy.mock.calls.length).toEqual(1);
// When
fakeAce.userUndo();
fakeAce.userTypes('three');
await pause(EVENTUALLY);
expect(spy.mock.calls.length).toEqual(1);
expect(fakeAce.userSees()).toEqual('original value');
});
describe('markers', () => {
it('should place markers into editor', async () => {
// Given
const fakeAce = new FakeAce();
const spy = jest.fn();
rewiremock('brace').with(fakeAce);
rewiremock('../editor-helpers/marker-placer').with({placeMarkerDecorations: spy});
// const makeEditor = require("plugins/editor/components/editor.jsx").default
const Editor = makeEditor({});
const dummy = fromJS({one: 1});
const wrapper = shallow(
<Editor markers={dummy} />
);
// When
wrapper.find('ReactAce').shallow();
await pause(EVENTUALLY);
// Then
expect(spy.mock.calls.length).toEqual(1);
expect(spy.mock.calls[0][0]).toContain({markers: {one: 1}});
});
it('should place markers after yaml', async () => {
// Given
const order = [];
const fakeAce = new FakeAce();
fakeAce.setValue.andCall(() => order.push('setValue'));
const spy = jest.fn().mockImplementation(() => order.push('placeMarkers'));
rewiremock('brace').with(fakeAce);
rewiremock('../editor-helpers/marker-placer').with({placeMarkerDecorations: spy});
// const makeEditor = require("plugins/editor/components/editor.jsx").default
const Editor = makeEditor({});
const wrapper = shallow(
<Editor value="original value" markers={{}} />
);
// When
wrapper.find('ReactAce').shallow();
await pause(EVENTUALLY);
// Then
expect(order).toEqual(['setValue', 'placeMarkers']);
});
it.skip(
'should Test for markers being disabled/enabled during a yaml update',
async function() {
// Given
const order = [];
const fakeAce = new FakeAce();
fakeAce.setValue.andCall(() => order.push('setValue'));
const spy = jest.fn().mockImplementation(() => {
order.push('placeMarkers');
return () => order.push('removeMarkers');
});
rewiremock('brace').with(fakeAce);
rewiremock('../editor-helpers/marker-placer').with({placeMarkerDecorations: spy});
// const makeEditor = require("plugins/editor/components/editor.jsx").default
const Editor = makeEditor({});
const wrapper = shallow(
<Editor value="original value" markers={{}} />
);
wrapper.find('ReactAce').shallow();
// When
wrapper.setProps({value: 'new value', origin: 'bob'});
await pause(EVENTUALLY);
// Then
expect(order).toEqual(['setValue', 'placeMarkers', 'removeMarkers', 'setValue', 'placeMarkers']);
}
);
it.skip(
'should Test for markers being disabled/enabled during ctrl-z',
async function() {
// Given
const order = [];
const fakeAce = new FakeAce();
fakeAce.setValue.andCall(() => order.push('setValue'));
const spy = jest.fn().mockImplementation(() => {
order.push('placeMarkers');
return () => order.push('removeMarkers');
});
rewiremock('brace').with(fakeAce);
rewiremock('../editor-helpers/marker-placer').with({placeMarkerDecorations: spy});
// const makeEditor = require("plugins/editor/components/editor.jsx").default
const Editor = makeEditor({});
const wrapper = shallow(
<Editor value="original value" markers={{}} />
);
wrapper.find('ReactAce').shallow();
// When
fakeAce.userUndo();
await pause(EVENTUALLY);
// Then
expect(order).toEqual(['setValue', 'placeMarkers', 'removeMarkers', 'setValue', 'placeMarkers']);
}
);
});
});
});
|
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;
|
rojak-ui-web/src/Routes.js
|
rawgni/rojak
|
import { Route, IndexRoute } from 'react-router';
import React from 'react';
import Container from './app/utils/Container';
import HomePage from './app/home/HomePage';
export default (
<Route component={Container}>
<Route path="/(search/:keyword)" component={HomePage} />
</Route>
)
|
frontend/src/components/submitcast/ShowInput.js
|
tanzdervampire/website
|
// @flow
import React from 'react';
import PropTypes from 'prop-types';
import moment from 'moment';
import { red500 } from 'material-ui/styles/colors';
import CircularProgress from 'material-ui/CircularProgress';
import { Card, CardHeader, CardText, CardActions } from 'material-ui/Card';
import DropDownMenu from 'material-ui/DropDownMenu';
import MenuItem from 'material-ui/MenuItem';
import FlatButton from 'material-ui/FlatButton';
import Done from 'material-ui/svg-icons/action/done';
import ShowPickerDatePicker from '../showpicker/ShowPickerDatePicker';
import ShowTimePicker from '../submitcast/ShowTimePicker';
const Step = {
DATE: 1,
TIME: 2,
LOCATION: 3,
};
function getStyles() {
return {
cardText: {
textAlign: 'center',
},
dropdown: {
width: '100%',
},
};
}
class ShowInput extends React.Component {
static propTypes = {
onFinish: PropTypes.func.isRequired,
cardStyle: PropTypes.object,
};
static defaultProps = {
cardStyle: {},
};
state = {
selectedDate: null,
selectedTime: null,
selectedLocation: null,
step: Step.DATE,
productions: [],
filteredProductions: [],
fetchFailed: false,
};
componentDidMount() {
this.loadProductions();
};
loadProductions() {
fetch(`/api/productions`, {
accept: 'application/json',
}).then(response => {
if (!response.ok) {
throw new Error();
}
return response.json();
}).then(productions => {
this.setState({ productions });
}).catch(err => {
console.log(`Failed to load productions!`);
this.setState({ fetchFailed: true });
});
};
handleOnDateSelected = date => {
const { productions, step } = this.state;
const mDate = moment(date);
const filteredProductions = productions.filter(production => {
const start = moment(production.start, 'YYYY-MM-DD');
const end = moment(production.end, 'YYYY-MM-DD');
return mDate.isBetween(start, end, 'day', '[]');
});
this.setState({
filteredProductions,
selectedDate: date,
selectedLocation: filteredProductions[0],
step: Math.max(step, Step.TIME),
});
};
handleOnTimeSelected = time => {
const { step } = this.state;
this.setState({
selectedTime: time,
step: Math.max(step, Step.LOCATION),
});
};
renderDatePicker() {
const { selectedDate } = this.state;
return (
<ShowPickerDatePicker
selectedDate={selectedDate}
onDateSelected={this.handleOnDateSelected}
/>
);
};
renderTimePicker() {
const { selectedTime, step } = this.state;
if (step < Step.TIME) {
return null;
}
return (
<ShowTimePicker
selectedTime={selectedTime}
onTimeSelected={this.handleOnTimeSelected}
openDialog={!selectedTime}
/>
);
};
renderLocationPicker() {
const { selectedLocation, filteredProductions, step } = this.state;
if (step < Step.LOCATION) {
return null;
}
if (filteredProductions.length === 0) {
return (
<p>An diesem Datum wurde das Musical nicht aufgeführt.</p>
);
}
const items = filteredProductions.map(production => {
const label = `${production.location}, ${production.theater}`;
return (
<MenuItem
key={production.location}
value={production}
primaryText={label}
/>
);
});
const styles = getStyles();
return (
<DropDownMenu
value={selectedLocation}
onChange={(_, index, value) => this.setState({ selectedLocation: value })}
disabled={filteredProductions.length <= 1}
autoWidth={false}
style={styles.dropdown}
>
{items}
</DropDownMenu>
);
};
renderActions() {
const { selectedDate, selectedTime, selectedLocation } = this.state;
return (
<FlatButton
label="Weiter"
onTouchTap={() => this.props.onFinish(selectedDate, selectedTime, selectedLocation)}
primary={true}
icon={<Done />}
disabled={!(selectedDate && selectedTime && selectedLocation)}
/>
);
};
render() {
const { productions, fetchFailed } = this.state;
const { cardStyle } = this.props;
const styles = getStyles();
return (
<Card style={cardStyle}>
<CardHeader
title="Vorstellung"
subtitle="Wann fand die Vorstellung statt?"
expandable={false}
/>
<CardText style={styles.cardText}>
{ fetchFailed && (
<p>Ups! Leider gab es ein Problem.</p>
) }
{ !fetchFailed && productions.length === 0 && (
<CircularProgress color={red500} />
) }
{ productions.length !== 0 && (
<div>
{this.renderDatePicker()}
{this.renderTimePicker()}
{this.renderLocationPicker()}
</div>
) }
</CardText>
<CardActions>
{this.renderActions()}
</CardActions>
</Card>
);
};
}
export default ShowInput;
|
src/components/topic/platforms/PlatformSizeNotice.js
|
mitmedialab/MediaCloud-Web-Tools
|
import PropTypes from 'prop-types';
import React from 'react';
import { connect } from 'react-redux';
import { injectIntl, FormattedMessage } from 'react-intl';
import { Grid, Row, Col } from 'react-flexbox-grid/lib';
import Permissioned from '../../common/Permissioned';
import { PERMISSION_TOPIC_WRITE } from '../../../lib/auth';
import { DetailNotice } from '../../common/Notice';
const localMessages = {
maxSize: { id: 'topic.maxSize', defaultMessage: 'Your topic size limit is {limit} stories. If your platforms and spidering discover more than that, your topic will fail to build.' },
maxSizeDetails: { id: 'topic.maxSize.details', defaultMessage: 'Try to keep your start and end dates small, or be more specific in your queries. Email support@mediacloud.org if you have questions.' },
};
export function platformIncomplete(initializedPlatform) {
return !initializedPlatform;
}
/**
* If the user has a topic size limitation, add a note about it here
*/
const PlatformSizeNotice = ({ initializedPlatform, isAdmin, userMaxSize, topicMaxSize }) => (
<Permissioned onlyTopic={PERMISSION_TOPIC_WRITE}>
{initializedPlatform && !isAdmin && (
<div className="notice detail-background">
<Grid>
<Row>
<Col lg={12}>
<DetailNotice details={localMessages.maxSizeDetails}>
<FormattedMessage {...localMessages.maxSize} values={{ limit: Math.max(userMaxSize, topicMaxSize) }} />
</DetailNotice>
</Col>
</Row>
</Grid>
</div>
)}
</Permissioned>
);
PlatformSizeNotice.propTypes = {
// from state
initializedPlatform: PropTypes.bool.isRequired,
userMaxSize: PropTypes.number.isRequired,
topicMaxSize: PropTypes.number.isRequired,
isAdmin: PropTypes.bool.isRequired,
// from compositional chain
intl: PropTypes.object.isRequired,
};
const mapStateToProps = state => ({
userMaxSize: state.user.profile.limits.max_topic_stories,
topicMaxSize: state.topics.selected.info.max_stories,
isAdmin: state.user.isAdmin,
initializedPlatform: state.topics.selected.platforms.all.initialized,
});
export default
injectIntl(
connect(mapStateToProps)(
PlatformSizeNotice
)
);
|
examples/html-table/SortableList.js
|
danielstocks/react-sortable
|
import React from 'react'
import SortableListItem from './SortableItem'
export default class SortableList extends React.Component {
state = {
items: this.props.items
};
onSortItems = (items) => {
this.setState({
items: items
});
}
render() {
const { items } = this.state;
var listItems = items.map((item, i) => {
return (
<SortableListItem
key={i}
onSortItems={this.onSortItems}
items={items}
sortId={i}>{item}</SortableListItem>
);
});
return (
<table className='sortable-list'>
<tbody>{listItems}</tbody>
</table>
)
}
}
|
src/app/components/task/DatetimeTaskResponse.js
|
meedan/check-web
|
import React from 'react';
import { FormattedMessage, FormattedDate } from 'react-intl';
import { convertNumbers2English } from '../../helpers';
const DateDisplay = ({ isoDate }) => (
<time dateTime={isoDate}>
<FormattedDate value={new Date(isoDate)} day="numeric" month="long" year="numeric" />
</time>
);
function tzOffsetHoursToIso8601Offset(nHours) {
if (nHours === 0) {
return 'Z';
}
const sign = nHours > 0 ? '+' : '-';
return `${sign}${String(Math.abs(nHours)).padStart(2, '0')}:00`;
}
function DateTimeDisplay({
isoDate, hourString, minuteString, tzOffsetHours, tzString,
}) {
const dateString = `${isoDate}T${hourString.padStart(2, '0')}:${minuteString.padStart(2, '0')}`;
const iso8601TzOffset = tzOffsetHoursToIso8601Offset(tzOffsetHours);
const date = new Date(`${dateString}${iso8601TzOffset}`);
// We can't format `date`, because we don't know its timezone. All we
// have is its offset, and that isn't enough: `Intl.DateTimeFormat` needs
// an IANA timezone. TODO fix https://mantis.meedan.com/view.php?id=8437,
// then format with `value={date}`.
// `Date.parse("YYYY-MM-DDThh:mm")` will parse in user's local timezone.
// This date may not exist! Hence https://mantis.meedan.com/view.php?id=8437
const displayDate = new Date(dateString);
const urlDate = encodeURIComponent(`${isoDate} ${hourString}:${minuteString} ${tzString}`);
return (
<time dateTime={date.toISOString()}>
<FormattedDate
value={displayDate /* https://mantis.meedan.com/view.php?id=8437 */}
year="numeric"
month="long"
day="numeric"
hour="numeric"
minute="numeric"
/>
{' '}
<FormattedMessage
id="datetimeTaskResponse.timeIs"
defaultMessage="View this timezone on time.is"
>
{title => (
<a
href={`https://time.is/${urlDate}`}
target="_blank"
rel="noreferrer noopener"
title={title}
>
{tzString}
</a>
)}
</FormattedMessage>
</time>
);
}
const DatetimeTaskResponse = (props) => {
if (!props.response) {
return null;
}
const response = convertNumbers2English(props.response);
const values = response.match(/^(\d+-\d+-\d+) (\d+):(\d+) ([+-]?\d+) (.*)$/);
if (!values) {
return (
<FormattedMessage
id="datetimeTaskResponse.invalidTimestamp"
defaultMessage="Error: Invalid timestamp"
/>
);
}
const noTime = /notime/.test(response);
return noTime ? (
<DateDisplay isoDate={values[1]} />
) : (
<DateTimeDisplay
isoDate={values[1]}
hourString={values[2]}
minuteString={values[3]}
tzOffsetHours={Number(values[4])}
tzString={values[5]}
/>
);
};
export default DatetimeTaskResponse;
|
src/components/Main.js
|
chiefwhitecloud/running-man-frontend
|
import React from 'react';
import { Switch, Route } from 'react-router-dom';
import RacePageLayout from './Races/PageLayout';
import FilterableRaceResults from './FilterableRaceResults';
import RacerContainer from './RacerContainer';
const containerStyle = {
maxWidth: '1200px',
margin: '0px auto',
};
const Main = () => (
<div style={containerStyle}>
<Switch>
<Route path="/races" component={RacePageLayout} />
<Route path="/race/:raceId" component={FilterableRaceResults} />
<Route path="/racer/:racerId" component={RacerContainer} />
</Switch>
</div>
);
export default Main;
|
components/Nav/Social.js
|
styled-components/styled-components-website
|
import React from 'react';
import styled from 'styled-components';
import { Github, MediumM } from '@styled-icons/fa-brands';
import rem from '../../utils/rem';
import { navbarHeight } from '../../utils/sizes';
import Link from '../Link';
const Wrapper = styled.nav`
display: flex;
align-items: center;
flex: 1 1 auto;
`;
const SocialLink = styled(Link).attrs((/* props */) => ({
unstyled: true,
}))`
display: flex;
margin-right: ${rem(20)};
line-height: ${rem(navbarHeight)};
transition: opacity 0.2s, transform 0.2s;
cursor: pointer;
&:last-child {
margin-right: 0;
}
&:hover,
&:focus {
opacity: 0.8;
}
&:active {
transform: scale(0.95);
opacity: 0.6;
}
svg {
path {
fill: currentColor;
}
}
`;
const Svg = styled.svg`
width: ${p => rem(Number(p.width))};
height: ${p => rem(Number(p.height))};
`;
const StyledIcon = styled.div`
&& {
width: ${p => rem(Number(p.width))};
height: ${p => rem(Number(p.height))};
}
`;
// const Twitter = () => (
// <Svg xmlns="http://www.w3.org/2000/svg" width="19" height="15" viewBox="0 0 19 15" xmlnsXlink="http://www.w3.org/1999/xlink">
// <title>twitter-logo</title>
// <use fill="#FFF" xlinkHref="#b"/>
// <defs>
// <path id="b" d="M18.2 1.8l-2 .6c.6-.5 1.2-1.2 1.5-2l-2.4.8C14.7.5 13.7 0 12.6 0 10.6 0 9 1.7 9 3.8v1C6 4.4 3 3 1.3.8 1 1 .8 1.8.8 2.4c0 1.3.6 2.5 1.6 3-.6 0-1.2 0-1.7-.3 0 2 1.3 3.7 3 4H2c.5 1.6 2 2.7 3.5 2.7-1.2 1-3 1.6-4.6 1.6H0c1.7 1 3.6 1.7 5.7 1.7 7 0 10.7-6 10.7-11v-.5c.7-.5 1.3-1.2 1.8-2z"/>
// </defs>
// </Svg>
// )
const Spectrum = () => (
<Svg width="14" height="14" viewBox="0 0 15 15">
<title>spectrum</title>
<path
fill="#FFF"
d="M0 6.5V1c0-.6.4-1 1-1 9 .3 13.7 5 14 14 0 .6-.4 1-1 1H8.5c-.6 0-1-.4-1-1-.3-4.4-2-6.2-6.5-6.5-.6 0-1-.4-1-1z"
/>
</Svg>
);
const Social = props => (
<Wrapper {...props}>
<SocialLink href="https://spectrum.chat/styled-components/">
<Spectrum />
</SocialLink>
{/* <SocialLink href="https://twitter.com/someone">
<Twitter />
</SocialLink> */}
<SocialLink href="https://github.com/styled-components">
<StyledIcon as={Github} height="18" />
</SocialLink>
<SocialLink href="https://medium.com/styled-components">
<StyledIcon as={MediumM} height="18" />
</SocialLink>
</Wrapper>
);
export default Social;
|
client/components/operations/label.js
|
jankeromnes/kresus
|
import React from 'react';
import { connect } from 'react-redux';
import PropTypes from 'prop-types';
import { translate as $t } from '../../helpers';
import { actions } from '../../store';
// If the length of the short label (of an operation) is smaller than this
// threshold, the raw label of the operation will be displayed in lieu of the
// short label, in the operations list.
// TODO make this a parameter in settings
const SMALL_TITLE_THRESHOLD = 4;
class LabelComponent_ extends React.Component {
constructor(props) {
super(props);
this.state = {
editedValue: null
};
this.handleChange = this.handleChange.bind(this);
this.handleFocus = this.handleFocus.bind(this);
this.handleKeyUp = this.handleKeyUp.bind(this);
this.handleBlur = this.handleBlur.bind(this);
}
handleChange(e) {
this.setState({
editedValue: e.target.value
});
}
handleFocus(event) {
// Set the caret at the end of the text.
let end = (event.target.value || '').length;
event.target.selectionStart = end;
event.target.selectionEnd = end;
}
handleKeyUp(event) {
if (event.key === 'Enter') {
event.target.blur();
} else if (event.key === 'Escape') {
let { target } = event;
this.setState({
editedValue: null
}, () => target.blur());
}
}
handleBlur() {
if (this.state.editedValue === null)
return;
let label = this.state.editedValue.trim();
// If the custom label is equal to the label, remove the custom label.
if (label === this.getLabel()) {
label = '';
}
let { customLabel } = this.props.operation;
if (label !== customLabel && (label || customLabel)) {
this.props.setCustomLabel(label);
}
this.setState({ editedValue: null });
}
getCustomLabel() {
let { customLabel } = this.props.operation;
if (customLabel === null || !customLabel.trim().length) {
return '';
}
return customLabel;
}
// Returns the label (or even the raw label if the label is too short).
getLabel() {
let op = this.props.operation;
let label;
if (op.title.length < SMALL_TITLE_THRESHOLD) {
label = op.raw;
if (op.title.length) {
label += ` (${op.title})`;
}
} else {
label = op.title;
}
return label.trim();
}
getDefaultValue() {
let label = this.getCustomLabel();
if (!label && this.props.displayLabelIfNoCustom) {
label = this.getLabel();
}
return label;
}
render() {
let label = this.state.editedValue !== null ?
this.state.editedValue :
this.getDefaultValue();
let labelVisibility = 'hidden';
let inputVisibility = '';
if (this.props.readonlyOnSmallScreens) {
labelVisibility = 'visible-xs-inline';
inputVisibility = 'hidden-xs';
}
return (<div className="label-component-container">
<span className={ `text-uppercase label-component ${labelVisibility}` }>
{ label }
</span>
<input
className={ `form-control operation-label-input ${inputVisibility}` }
type="text"
value={ label }
onChange={ this.handleChange }
onFocus={ this.handleFocus }
onKeyUp={ this.handleKeyUp }
onBlur={ this.handleBlur }
placeholder={ $t('client.operations.add_custom_label') }
/>
</div>);
}
}
LabelComponent_.propTypes = {
// The operation from which to get the label.
operation: PropTypes.object.isRequired,
// Whether to display the operation label if there is no custom label.
displayLabelIfNoCustom: PropTypes.bool,
// A function to set the custom label when modified.
setCustomLabel: PropTypes.func.isRequired,
// Whether the label is readonly on small screens.
readonlyOnSmallScreens: PropTypes.bool
};
LabelComponent_.defaultProps = {
displayLabelIfNoCustom: true,
readonlyOnSmallScreens: false
};
function mapDispatch(component) {
return connect(() => {
// no state
return {};
}, (dispatch, props) => {
return {
setCustomLabel(label) {
actions.setOperationCustomLabel(dispatch, props.operation, label);
}
};
})(component);
}
export const LabelComponent = mapDispatch(LabelComponent_);
const OperationListViewLabel_ = props => {
let label = (
<LabelComponent
operation={ props.operation }
setCustomLabel={ props.setCustomLabel }
readonlyOnSmallScreens={ true }
/>
);
if (typeof props.link === 'undefined') {
return label;
}
return (
<div className="input-group">
{ props.link }
{ label }
</div>
);
};
OperationListViewLabel_.propTypes = {
// The operation from which to get the label.
operation: PropTypes.object.isRequired,
// A function to set the custom label when modified.
setCustomLabel: PropTypes.func.isRequired,
// A link associated to the label
link: PropTypes.object
};
export const OperationListViewLabel = mapDispatch(OperationListViewLabel_);
|
src/containers/Home/index.js
|
anitrack/anitrack-web
|
import React, { Component } from 'react';
import { Col, Row, Button, Form, FormGroup, Label, Input, InputGroup, InputGroupButton, UncontrolledDropdown, DropdownToggle, DropdownMenu, DropdownItem } from 'reactstrap';
import MediaQuery from 'react-responsive';
import * as css from './css';
const flexItem = [
{icon: "fa-code", title: "Open Source", desc: "All of the codes used to power this project is available publicly. Anyone can modify and contribute to make it better!"},
{icon: "fa-flash", title: "Simple and Fast", desc: "The Process is extremely simple. Simply enter your username and view the results compiled into a single list."},
{icon: "fa-unlock", title: "Free of Charge", desc: "Best of all, the service is free of charge! Feel free to enjoy and keep track of those anime you can't wait to watch."}
];
class Home extends Component {
constructor(props){
super(props);
this.state = {userName: "", provider: "mal"};
}
linkState(state, val){
const obj = {};
obj[state] = val;
this.setState(obj);
}
onClick(event){
if(this.state.userName !== ''){
this.props.history.push(`/${this.state.provider}/${this.state.userName}`)
}
event.preventDefault();
}
render() {
let provider = "";
switch(this.state.provider){
case "mal":
provider = "MAL";
break;
case "alist":
provider = "AniList";
break;
default:
}
return (
<div style={css.background} >
<Row style={css.topRow}>
<Col>
<h1 style={css.heading}><strong>ANIME TRACKER</strong></h1>
<Form onSubmit={(e) => {this.onClick(e)}} >
<FormGroup style={css.formGroup}>
<Label for="userName" style={css.formLabel}>Username</Label>
<div style={css.inputDiv}>
<InputGroup>
<InputGroupButton>
<UncontrolledDropdown>
<DropdownToggle caret style={css.inputDropdown}>
{provider}
</DropdownToggle>
<DropdownMenu>
<DropdownItem onClick={() => {this.setState({provider: "mal"})}}>MAL</DropdownItem>
<DropdownItem onClick={() => {this.setState({provider: "alist"})}}>AniList</DropdownItem>
</DropdownMenu>
</UncontrolledDropdown>
</InputGroupButton>
<Input style={css.input} placeholder="Username" value={this.state.userName} onChange={(e) => {this.linkState('userName', e.target.value)}} />
</InputGroup>
</div>
</FormGroup>
<Button style={css.inputButton} >Search</Button>
</Form>
<br />
</Col>
</Row>
<Row style={css.botRow}>
<Col>
<div style={css.flexRow}>
{
flexItem.map((item, i) => {
return (
<MediaQuery maxWidth={768} key={i}>
{(matches) => {
return (
<div style={matches? css.flexItemSmall : css.flexItem }>
<i className={`fa ${item.icon}`} style={css.flexLogo} />
<h4>{item.title}</h4>
<p style={css.flexDesc}>{item.desc}</p>
</div>
)
}}
</MediaQuery>
)
})
}
</div>
</Col>
</Row>
</div>
);
}
}
export default Home;
|
UI/src/components/common/Spinner.js
|
ssvictorlin/PI
|
import React from 'react';
import { View, ActivityIndicator } from 'react-native';
const Spinner = ({ size }) => {
return (
<View style={ styles.spinnerStyle }>
<ActivityIndicator size={ size || 'large' } />
</View>
);
};
const styles = {
spinnerStyle: {
flex: 1,
justifyContent: 'center',
alignItems: 'center'
}
}
export { Spinner };
|
ux/Selector.js
|
rameshvk/j0
|
'use strict';
import BaseComponent from './BaseComponent.js';
import React from 'react';
import SelectView from './SelectView.js';
function getState(props) {
return {optionIndex: props.model.get(React.Children.count(props.children))};
}
export default class Selector extends BaseComponent {
constructor(props) {
super(props);
this.state = getState(props);
this._onChange = () => this.setState(getState(this.props));
this.props.model.on('change', this._onChange);
}
componentWillUnmount() {
this.props.model.removeListener('change', this._onChange);
}
render() {
return SelectView.create({
optionIndex: this.state.optionIndex,
children: this.props.children
});
}
};
Selector.propTypes = {
model: React.PropTypes.object.isRequired
};
|
wwwroot/app/src/components/MealPlannerPage/Meal/index.js
|
AlinCiocan/PlanEatSave
|
import React from 'react';
import Routes from '../../../services/Routes';
import Link from '../../base/Link';
import RemoveIcon from '../../base/icons/RemoveIcon';
const Meal = ({ meal, onRemoveMeal }) => (
<div className="pes-meal">
<div className="pes-meal__divider"></div>
<Link
undecorated
to={Routes.viewRecipe(meal.recipeId)}
className="pes-meal__recipe-name">
{meal.recipeName}
</Link>
<button
onClick={() => onRemoveMeal(meal.id, meal.recipeName)}
className="pes-meal__remove-button">
<RemoveIcon />
</button>
</div>
);
export default Meal;
|
boxroom/archive/backup-js-glow-2018-01-28/boxroom/archive/js-surface-2018-01-27/boxroom/archive/2017-10-23-before-redesign/src/demo/pagination/pagination.js
|
mcjazzyfunky/js-surface
|
import {
defineClassComponent,
defineFunctionalComponent,
hyperscript as h,
mount
} from 'js-surface';
import { Seq } from 'js-essential';
import PaginationHelper from './helper/PaginationHelper.js';
import ComponentHelper from './helper/ComponentHelper.js';
import React from 'react';
import ReactDOM from 'react-dom';
const
number = 20,
pageSize = 25,
totalItemCount = 1220;
export const Pagination = defineFunctionalComponent({
displayName: 'Pagination',
properties: {
className: {
type: String,
defaultValue: null
},
pageIndex: {
type: Number,
defaultValue: null
},
pageSize: {
type: Number,
defaultValue: null
},
totalItemCount: {
type: Number,
defaultValue: null
},
showFirstButton: {
type: Boolean,
defaultValue: true
},
showLastButton: {
type: Boolean,
defaultValue: true
},
showPreviousButton: {
type: Boolean,
defaultValue: true
},
showNextButton: {
type: Boolean,
defaultValue: true
},
onChange: {
type: Function,
defaultValue: null
}
},
render(props) {
const
pageIndex = props.pageIndex,
metrics =
PaginationHelper.calcPaginationMetrics(
props.pageIndex,
props.pageSize,
props.totalItemCount),
paginationInfo =
PaginationHelper.determineVisiblePaginationButtons(
props.pageIndex,
metrics.pageCount,
6),
classNameOuter =
ComponentHelper.buildCssClass(
'fk-pagination',
props.className),
classNameInner = 'pagination',
moveToPage = targetPage => {
if (props.onChange) {
props.onChange({targetPage});
}
},
firstPageLink =
metrics.pageCount > 0
? buildLinkListItem(
1,
pageIndex === 0,
() => moveToPage(0))
: null,
precedingEllipsis =
paginationInfo.firstButtonIndex > 1
? buildLinkListItem(
'...',
false)
: null,
succeedingEllipsis =
paginationInfo.lastButtonIndex < metrics.pageCount - 2
? buildLinkListItem(
'...',
false)
: null,
lastPageLink =
metrics.pageCount > 0
? buildLinkListItem(
metrics.pageCount,
pageIndex === metrics.pageCount - 1,
() => moveToPage(metrics.pageCount - 1))
: null,
buttons =
Seq.range(
paginationInfo.firstButtonIndex ,
paginationInfo.lastButtonIndex + 1)
.map(
index => buildLinkListItem(
index + 1,
index === pageIndex,
() => moveToPage(index))
);
return (
h('div',
{className: classNameOuter},
h('ul',
{className: classNameInner},
firstPageLink,
precedingEllipsis,
buttons.toArray(),
succeedingEllipsis,
lastPageLink))
);
}
});
function buildLinkListItem(text, isActive, moveToPage) {
return (
h('li.page-item',
{
className: isActive ? 'active' : '',
key: text !== '...' ? text + '-' + isActive : undefined
},
h('a.page-link',
{ onClick: moveToPage },
text))
);
}
const DemoOfPagination = defineClassComponent({
displayName: 'DemoOfPagination',
constructor() {
this.state = { pageIndex: 0 };
},
moveToPage(pageIndex) {
this.state = { pageIndex };
},
render() {
return (
h('div',
{className: 'container-fluid'},
Seq.range(1, number).map(() =>
h('div',
Pagination({
pageIndex: this.state.pageIndex,
pageSize: pageSize,
totalItemCount: totalItemCount,
onChange: evt => this.moveToPage(evt.targetPage)})))));
}
});
// -----------------
class RPaginationClass extends React.Component {
render() {
const
pageIndex = this.props.pageIndex,
metrics = PaginationHelper.calcPaginationMetrics(
this.props.pageIndex,
this.props.pageSize,
this.props.totalItemCount),
paginationInfo = PaginationHelper.determineVisiblePaginationButtons(
this.props.pageIndex,
metrics.pageCount,
6),
classNameOuter = ComponentHelper.buildCssClass(
'fk-pagination',
this.props.className),
classNameInner = 'pagination',
firstPageLink = metrics.pageCount > 0
? buildLinkListItem2(
1,
pageIndex === 0,
this.props,
0)
: null,
precedingEllipsis = paginationInfo.firstButtonIndex > 1
? buildLinkListItem2(
'...',
false,
this.props)
: null,
succeedingEllipsis = paginationInfo.lastButtonIndex < metrics.pageCount - 2
? buildLinkListItem2(
'...',
false,
this.props)
: null,
lastPageLink = metrics.pageCount > 0
? buildLinkListItem2(
metrics.pageCount,
pageIndex === metrics.pageCount - 1,
this.props,
metrics.pageCount - 1)
: null,
buttons = Seq.range(
paginationInfo.firstButtonIndex ,
paginationInfo.lastButtonIndex + 1)
.map(index => buildLinkListItem2(
index + 1,
index === pageIndex,
this.props,
index));
return (
React.createElement('div',
{className: classNameOuter},
React.createElement('ul',
{className: classNameInner},
firstPageLink,
precedingEllipsis,
buttons,
succeedingEllipsis,
lastPageLink))
);
}
}
function buildLinkListItem2(text, isActive, props, pageIndexToMove = null) {
const
onChangeProp = props.onChange,
onClick = !isActive && pageIndexToMove !== null && typeof onChangeProp === 'function'
? () => onChangeProp({targetPage: pageIndexToMove})
: null;
return (
React.createElement('li',
{ className: 'page-item ' + (isActive ? 'active' : ''), key: (pageIndexToMove === null ? undefined : pageIndexToMove + text + isActive)},
React.createElement('a',
{ className: 'page-link', onClick: onClick },
text))
);
}
class RDemoOfPaginationClass extends React.Component {
constructor() {
super();
this.state = {currPageIdx: 0};
}
render() {
return (
React.createElement('div',
{className: 'container-fluid'},
...Seq.range(1, number).map(() =>
React.createElement('div',
{className: 'row'},
RPagination({
pageIndex: this.state.currPageIdx,
pageSize: pageSize,
totalItemCount: totalItemCount,
onChange: evt => this.setState({currPageIdx: evt.targetPage})
})
)))
);
}
}
const
RPagination = React.createFactory(RPaginationClass),
RDemoOfPagination = React.createFactory(RDemoOfPaginationClass);
const container = document.getElementById('main-content');
container.innerHTML =
'<div class="row" style="margin: 0 0 0 50px">'
+ '<div class="col-md-6"><b>js-surface:</b></div>'
+ '<div class="col-md-6"><b>React:</b></div>'
+ '<div id="section-surface" class="col-md-6"></div>'
+ '<div id="section-react" class="col-md-6"></div>'
+ '</div>';
mount(
DemoOfPagination(),
'section-surface');
ReactDOM.render(
RDemoOfPagination(),
document.getElementById('section-react'));
|
src/components/Footer/Footer.js
|
stinkyfingers/IsoTest
|
/**
* React Starter Kit (https://www.reactstarterkit.com/)
*
* Copyright © 2014-2016 Kriasoft, LLC. All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE.txt file in the root directory of this source tree.
*/
import React, { Component } from 'react';
import withStyles from 'isomorphic-style-loader/lib/withStyles';
import s from './Footer.scss';
import Link from '../Link';
class Footer extends Component {
render() {
return (
<div className={s.root}>
<div className={s.container}>
<span className={s.text}>© Your Company</span>
<span className={s.spacer}>·</span>
<Link className={s.link} to="/">Home</Link>
<span className={s.spacer}>·</span>
<Link className={s.link} to="/privacy">Privacy</Link>
<span className={s.spacer}>·</span>
<Link className={s.link} to="/not-found">Not Found</Link>
</div>
</div>
);
}
}
export default withStyles(Footer, s);
|
src/svg-icons/communication/location-on.js
|
lawrence-yu/material-ui
|
import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let CommunicationLocationOn = (props) => (
<SvgIcon {...props}>
<path d="M12 2C8.13 2 5 5.13 5 9c0 5.25 7 13 7 13s7-7.75 7-13c0-3.87-3.13-7-7-7zm0 9.5c-1.38 0-2.5-1.12-2.5-2.5s1.12-2.5 2.5-2.5 2.5 1.12 2.5 2.5-1.12 2.5-2.5 2.5z"/>
</SvgIcon>
);
CommunicationLocationOn = pure(CommunicationLocationOn);
CommunicationLocationOn.displayName = 'CommunicationLocationOn';
CommunicationLocationOn.muiName = 'SvgIcon';
export default CommunicationLocationOn;
|
client/components/TableBeta2.js
|
ForestJS/ForestJS-Production
|
import React, { Component } from 'react';
class TableBeta2 extends Component {
constructor(props) {
super(props);
this.state = {
login: null,
user: null
}
this.createTable = this.createTable.bind(this);
this.detailView = this.props.detailView.bind(this);
}
createTable(){
const activeTree = '';
}
render() {
let view = this.createTable();
return (
<div id="tablecontainer">
{view}
</div>
)
}
}
export default Table;
|
src/components/sandbox/Sandbox.js
|
gtdudu/hapi-wurb
|
import React from 'react';
import PropTypes from 'prop-types';
const Sandbox = () => {
return (
<div className="outer_face">
<div className="marker oneseven"></div>
<div className="marker twoeight"></div>
<div className="marker fourten"></div>
<div className="marker fiveeleven"></div>
<div className="inner_face">
<div className="hand hour"></div>
<div className="hand minute"></div>
<div className="hand second"></div>
</div>
</div>
);
};
Sandbox.propTypes = {
children : PropTypes.object
};
export default Sandbox;
|
tests/components/Header/Header.spec.js
|
chenfanggm/steven-mern-starter-kit
|
import React from 'react'
import { Header } from 'components/Header/Header'
import { IndexLink, Link } from 'react-router'
import { shallow } from 'enzyme'
describe('(Component) Header', () => {
let _wrapper
beforeEach(() => {
_wrapper = shallow(<Header />)
})
it('Renders a welcome message', () => {
const welcome = _wrapper.find('h1')
expect(welcome).to.exist
expect(welcome.text()).to.match(/React Redux Starter Kit/)
})
describe('Navigation links...', () => {
it('Should render a Link to Home route', () => {
expect(_wrapper.contains(
<IndexLink activeClassName='route--active' to='/'>
Home
</IndexLink>
)).to.be.true
})
it('Should render a Link to Counter route', () => {
expect(_wrapper.contains(
<Link activeClassName='route--active' to='/counter'>
Counter
</Link>
)).to.be.true
})
})
})
|
src/app/SelectSpotTypePage.js
|
EsriJapan/photospot-finder
|
// Copyright (c) 2016 Esri Japan
import React from 'react';
class SelectSpotTypePage extends React.Component {
constructor (props) {
super(props);
}
render () {
let visibility = 'block';
if (this.props.visibility === false) {
visibility = 'none';
}
return (
<div className="select-photospot-page" style={{ display: visibility, position: 'absolute', top: 0, width: '100%', marginLeft: '-15px', height: window.innerHeight - 50 + 'px' }}>
<style type="text/css">{`
.select-photospot-page > div {
height: 50%;
position: relative;
background-size: cover;
}
.select-photospot-page > div:before {
filter: blur(1px);
}
.select-photospot {
background-image: url(img/photospot-bg.jpg);
}
.select-kujiranspot {
background-image: url(img/kujiranspot-bg.jpg);
}
.select-photospot-page > div > div {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
margin: auto;
height: 34px;
width: 200px;
padding-top: 7px;
color: #fff;
background-color: rgba(0,0,0,0.3);
font-weight: bold;
border-radius: 17px;
border: solid 1px #fff;
text-shadow: none;
text-align: center;
transition: all 0.3s;
cursor: pointer;
}
.select-photospot-page > div > div:hover {
color: #666;
background-color: rgba(255,255,255,1);
}
`}</style>
<div className="select-photospot">
<div onClick={this.props.onSelectPhotoSpot}>
<p>撮影スポットを探す</p>
</div>
</div>
<div className="select-kujiranspot">
<div onClick={this.props.onSelectKujiranSpot}>
<p>くじらんスポットを探す</p>
</div>
</div>
</div>
);
}
}
SelectSpotTypePage.propTypes = {
visibility: React.PropTypes.bool,
onSelectPhotoSpot: React.PropTypes.func,
onSelectKujiranSpot: React.PropTypes.func
};
SelectSpotTypePage.displayName = 'SelectSpotTypePage';
export default SelectSpotTypePage;
|
6.webpack/message/components/Message.js
|
zhufengnodejs/201608node
|
import React from 'react';
export default class Message extends React.Component {
render() {
return (
<li className="list-group-item">{this.props.author}:{this.props.children}
<button onClick={()=>{this.props.click(this.props.id)}} className="btn btn-danger">删除</button> <span className="pull-right">{this.props.date&&this.props.date.toLocaleString()}</span>
</li>
)
}
}
|
src/components/Search/Search-test.js
|
joshblack/carbon-components-react
|
/**
* Copyright IBM Corp. 2016, 2018
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/
import React from 'react';
import Search16 from '@carbon/icons-react/lib/search/16';
import Close20 from '@carbon/icons-react/lib/close/20';
import Search from '../Search';
import SearchSkeleton from '../Search/Search.Skeleton';
import { mount, shallow } from 'enzyme';
describe('Search', () => {
describe('renders as expected', () => {
const wrapper = mount(
<Search
id="test"
className="extra-class"
label="Search Field"
labelText="testlabel"
/>
);
const label = wrapper.find('label');
const textInput = wrapper.find('input');
const container = wrapper.find('[role="search"]');
describe('container', () => {
it('should add extra classes that are passed via className', () => {
expect(container.hasClass('extra-class')).toEqual(true);
});
it('should have the role of search', () => {
expect(container.props().role).toEqual('search');
});
});
describe('input', () => {
it('renders as expected', () => {
expect(textInput.length).toBe(1);
});
it('has the expected classes', () => {
expect(textInput.hasClass('bx--search-input')).toEqual(true);
});
it('should set type as expected', () => {
expect(textInput.props().type).toEqual('text');
wrapper.setProps({ type: 'email' });
expect(wrapper.find('input').props().type).toEqual('email');
});
it('should set value as expected', () => {
expect(textInput.props().defaultValue).toEqual(undefined);
wrapper.setProps({ defaultValue: 'test' });
expect(wrapper.find('input').props().defaultValue).toEqual('test');
expect(wrapper.find('input').props().value).toEqual(undefined);
});
it('should set placeholder as expected', () => {
expect(textInput.props().placeholder).toEqual('');
wrapper.setProps({ placeHolderText: 'Enter text' });
expect(wrapper.find('input').props().placeholder).toEqual('Enter text');
});
});
describe('label', () => {
it('renders a label', () => {
expect(label.length).toBe(1);
});
it('has the expected classes', () => {
expect(label.hasClass('bx--label')).toEqual(true);
});
it('should set label as expected', () => {
expect(wrapper.props().label).toEqual('Search Field');
wrapper.setProps({ label: 'Email Input' });
expect(wrapper.props().label).toEqual('Email Input');
});
});
describe('Large Search', () => {
describe('buttons', () => {
const btns = wrapper.find('button');
it('should be one button', () => {
expect(btns.length).toBe(1);
});
it('should have type="button"', () => {
const type1 = btns
.first()
.instance()
.getAttribute('type');
const type2 = btns
.last()
.instance()
.getAttribute('type');
expect(type1).toEqual('button');
expect(type2).toEqual('button');
});
});
describe('icons', () => {
it('renders "search" icon', () => {
const icons = wrapper.find(Search16);
expect(icons.length).toBe(1);
});
it('renders two Icons', () => {
wrapper.setProps({ small: false });
const iconTypes = [Search16, Close20];
const icons = wrapper.findWhere(n => iconTypes.includes(n.type()));
expect(icons.length).toEqual(2);
});
});
});
describe('Small Search', () => {
const small = mount(
<Search
id="test"
small
className="extra-class"
label="Search Field"
labelText="testlabel"
/>
);
const smallContainer = small.find('[role="search"]');
it('renders correct search icon', () => {
const icons = small.find(Search16);
expect(icons.length).toBe(1);
});
it('should have the expected small class', () => {
expect(smallContainer.hasClass('bx--search--sm')).toEqual(true);
});
it('should only have 1 button (clear)', () => {
const btn = small.find('button');
expect(btn.length).toEqual(1);
});
it('renders two Icons', () => {
const iconTypes = [Search16, Close20];
const icons = wrapper.findWhere(n => iconTypes.includes(n.type()));
expect(icons.length).toEqual(2);
});
});
});
describe('events', () => {
describe('enabled textinput', () => {
const onClick = jest.fn();
const onChange = jest.fn();
const wrapper = shallow(
<Search
id="test"
labelText="testlabel"
onClick={onClick}
onChange={onChange}
/>
);
const input = wrapper.find('input');
const eventObject = {
target: {
defaultValue: 'test',
},
};
it('should invoke onClick when input is clicked', () => {
input.simulate('click');
expect(onClick).toBeCalled();
});
it('should invoke onChange when input value is changed', () => {
input.simulate('change', eventObject);
expect(onChange).toBeCalledWith(eventObject);
});
});
});
});
describe('SearchSkeleton', () => {
describe('Renders as expected', () => {
const wrapper = shallow(<SearchSkeleton />);
it('Has the expected classes', () => {
expect(wrapper.hasClass('bx--skeleton')).toEqual(true);
expect(wrapper.hasClass('bx--search--xl')).toEqual(true);
});
});
});
describe('SearchSkeleton Small', () => {
describe('Renders as expected', () => {
const wrapper = shallow(<SearchSkeleton small />);
it('Has the expected classes', () => {
expect(wrapper.hasClass('bx--skeleton')).toEqual(true);
expect(wrapper.hasClass('bx--search--sm')).toEqual(true);
});
});
});
describe('Detecting change in value from props', () => {
it('changes the hasContent state upon change in props', () => {
const wrapper = shallow(
<Search
id="test"
className="extra-class"
label="Search Field"
labelText="testlabel"
value="foo"
/>
);
expect(wrapper.state().hasContent).toBeTruthy();
wrapper.setProps({ value: '' });
expect(wrapper.state().hasContent).toBeFalsy();
});
it('avoids change the hasContent state upon setting props, unless the value actually changes', () => {
const wrapper = shallow(
<Search
id="test"
className="extra-class"
label="Search Field"
labelText="testlabel"
value="foo"
/>
);
expect(wrapper.state().hasContent).toBeTruthy();
wrapper.setState({ hasContent: false });
wrapper.setProps({ value: 'foo' });
expect(wrapper.state().hasContent).toBeFalsy();
});
});
|
app/react-icons/fa/user-md.js
|
scampersand/sonos-front
|
import React from 'react';
import IconBase from 'react-icon-base';
export default class FaUserMd extends React.Component {
render() {
return (
<IconBase viewBox="0 0 40 40" {...this.props}>
<g><path d="m13.1 30q0 0.6-0.5 1t-1 0.4-1-0.4-0.4-1 0.4-1 1-0.4 1 0.4 0.5 1z m22.8 1.4q0 2.7-1.6 4.2t-4.3 1.5h-19.5q-2.7 0-4.4-1.5t-1.6-4.2q0-1.6 0.1-3t0.6-3 1-3 1.8-2.3 2.7-1.4q-0.5 1.2-0.5 2.7v4.6q-1.3 0.4-2.1 1.5t-0.7 2.5q0 1.8 1.2 3t3 1.3 3.1-1.3 1.2-3q0-1.4-0.8-2.5t-2-1.5v-4.6q0-1.4 0.5-2 3 2.3 6.6 2.3t6.6-2.3q0.6 0.6 0.6 2v1.5q-2.4 0-4.1 1.6t-1.7 4.1v2q-0.7 0.6-0.7 1.5 0 0.9 0.7 1.6t1.5 0.6 1.5-0.6 0.6-1.6q0-0.9-0.7-1.5v-2q0-1.2 0.9-2t2-0.9 2 0.9 0.8 2v2q-0.7 0.6-0.7 1.5 0 0.9 0.6 1.6t1.5 0.6 1.6-0.6 0.6-1.6q0-0.9-0.7-1.5v-2q0-1.5-0.8-2.9t-2.1-2.1q0-0.2 0-0.9t0-1.1 0-0.9-0.2-1.1-0.3-0.8q1.5 0.3 2.7 1.3t1.8 2.3 1.1 3 0.5 3 0.1 3z m-7.1-20q0 3.6-2.5 6.1t-6.1 2.5-6-2.5-2.6-6.1 2.6-6 6-2.5 6.1 2.5 2.5 6z"/></g>
</IconBase>
);
}
}
|
tools/public-components.js
|
joemcbride/react-starter-kit
|
import React from 'react';
import index from '../src/index';
let components = [];
Object.keys(index).forEach(function (item) {
if (index[item] instanceof React.Component.constructor) {
components.push(item);
}
});
export default components;
|
src/svg-icons/navigation/subdirectory-arrow-right.js
|
igorbt/material-ui
|
import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let NavigationSubdirectoryArrowRight = (props) => (
<SvgIcon {...props}>
<path d="M19 15l-6 6-1.42-1.42L15.17 16H4V4h2v10h9.17l-3.59-3.58L13 9l6 6z"/>
</SvgIcon>
);
NavigationSubdirectoryArrowRight = pure(NavigationSubdirectoryArrowRight);
NavigationSubdirectoryArrowRight.displayName = 'NavigationSubdirectoryArrowRight';
NavigationSubdirectoryArrowRight.muiName = 'SvgIcon';
export default NavigationSubdirectoryArrowRight;
|
public/js/components/visits/othersvisits.react.js
|
rajikaimal/Coupley
|
import React from 'react';
import Avatar from 'material-ui/lib/avatar';
import Card from 'material-ui/lib/card/card';
import CardActions from 'material-ui/lib/card/card-actions';
import CardHeader from 'material-ui/lib/card/card-header';
import CardMedia from 'material-ui/lib/card/card-media';
import CardTitle from 'material-ui/lib/card/card-title';
import FlatButton from 'material-ui/lib/flat-button';
import CardText from 'material-ui/lib/card/card-text';
import List from 'material-ui/lib/lists/list';
import ListItem from 'material-ui/lib/lists/list-item';
import TextField from 'material-ui/lib/text-field';
import Divider from 'material-ui/lib/divider';
import IconButton from 'material-ui/lib/icon-button';
import MoreVertIcon from 'material-ui/lib/svg-icons/navigation/more-vert';
import Colors from 'material-ui/lib/styles/colors';
import IconMenu from 'material-ui/lib/menus/icon-menu';
import MenuItem from 'material-ui/lib/menus/menu-item';
import Tabs from 'material-ui/lib/tabs/tabs';
import Tab from 'material-ui/lib/tabs/tab';
import Dialog from 'material-ui/lib/dialog';
import ThreadActions from '../../actions/Thread/ThreadActions';
import VisitsActions from '../../actions/VisitsAction';
const iconButtonElement = (
<IconButton
touch={true}
tooltip="more"
tooltipPosition="bottom-left"
>
<MoreVertIcon color={Colors.grey400} />
</IconButton>
);
const rightIconMenu = (
<IconMenu iconButtonElement={iconButtonElement}>
<MenuItem>Block</MenuItem>
</IconMenu>
);
const othervisits = React.createClass({
handleOpen: function () {
this.setState({ open: true });
},
handleClose: function () {
this.setState({ open: false });
},
deletemyfollow:function () {
console.log('follower deleted!');
},
getInitialState: function () {
return {
open: false,
};
},
blockUser: function () {
ThreadActions.block(this.props.username, localStorage.getItem('username'));
VisitsActions.deleteUserFromOthervisit(this.props.username, localStorage.getItem('username'));
this.setState({ open: false });
},
render:function(){
const actions = [
<FlatButton
label="No"
secondary={true}
onTouchTap={this.handleClose}
/>,
<FlatButton
label="Yes"
primary={true}
keyboardFocused={true}
onTouchTap={this.blockUser}
/>,
];
return(
<div>
<ListItem
primaryText={this.props.fistname}
leftAvatar={<Avatar src={'img/profilepics/'+this.props.username} />}
rightIconButton={ <IconMenu iconButtonElement={iconButtonElement}>
<MenuItem onTouchTap={this.handleOpen}>Block</MenuItem>
</IconMenu>}
/>
<Divider/>
<Dialog
title="Block your Followeres"
actions={actions}
modal={false}
open={this.state.open}
onRequestClose={this.handleClose}
>
Are you sure you want to Block this user?.
</Dialog>
</div>
);
}
});
export default othervisits;
|
react/features/mobile/navigation/functions.js
|
jitsi/jitsi-meet
|
import React from 'react';
import { useTranslation } from 'react-i18next';
import { Platform } from 'react-native';
import { IconClose } from '../../base/icons';
import HeaderNavigationButton from './components/HeaderNavigationButton';
/**
* Close icon/text button based on platform.
*
* @param {Function} goBack - Goes back to the previous screen function.
* @returns {React.Component}
*/
export function screenHeaderCloseButton(goBack: Function) {
const { t } = useTranslation();
if (Platform.OS === 'ios') {
return (
<HeaderNavigationButton
label = { t('dialog.close') }
onPress = { goBack } />
);
}
return (
<HeaderNavigationButton
onPress = { goBack }
src = { IconClose } />
);
}
|
src/Parser/RestoDruid/Modules/Features/NaturesEssence.js
|
mwwscott0/WoWAnalyzer
|
import React from 'react';
import { formatPercentage } from 'common/format';
import SpellLink from 'common/SpellLink';
import Module from 'Parser/Core/Module';
import SPELLS from 'common/SPELLS';
import Combatants from 'Parser/Core/Modules/Combatants';
const MINOR = 0.07;
const AVERAGE = 0.12;
const MAJOR = 0.17;
class NaturesEssence extends Module {
static dependencies = {
combatants: Combatants,
};
effectiveHealing = 0;
overHealing = 0;
on_initialized() {
this.active = this.combatants.selected.traitsBySpellId[SPELLS.NATURES_ESSENCE_TRAIT.id] > 0;
}
on_byPlayer_heal(event) {
const spellId = event.ability.guid;
if (SPELLS.NATURES_ESSENCE_DRUID.id === spellId) {
this.effectiveHealing += event.amount + (event.absorbed || 0);
this.overHealing += (event.overheal !== undefined ? event.overheal : 0);
}
}
suggestions(when) {
const overhealPercent = (this.overHealing + this.effectiveHealing !== 0)
? this.overHealing / (this.effectiveHealing + this.overHealing)
: 0;
when(overhealPercent).isGreaterThan(MINOR)
.addSuggestion((suggest, actual, recommended) => {
return suggest(<span>Your overhealing from <SpellLink id={SPELLS.NATURES_ESSENCE_DRUID.id} /> is high.
You may be casting <SpellLink id={SPELLS.WILD_GROWTH.id} /> when few raiders are injured, or you may be casting it before damage.
Unlike our other HoTs, <SpellLink id={SPELLS.WILD_GROWTH.id} /> heals quickly and has a strong initial heal,
so you should wait until damage has already happened to cast it.</span>)
.icon(SPELLS.NATURES_ESSENCE_DRUID.icon)
.actual(`${formatPercentage(overhealPercent)}% overhealing`)
.recommended(`<${Math.round(formatPercentage(recommended))}% is recommended`)
.regular(AVERAGE).major(MAJOR);
});
}
}
export default NaturesEssence;
|
app/components/AddTask/GMaps/index.js
|
theterra/newsb
|
import React from 'react';
import './MapStyle.css';
let searchBox;
export default class GMaps extends React.Component { //eslint-disable-line
constructor(props) {
super(props);
this.geolocate = this.geolocate.bind(this);
this.initAutocomplete = this.initAutocomplete.bind(this);
this.searchBoxPlaces = this.searchBoxPlaces.bind(this);
this.emitChanges = this.emitChanges.bind(this);
}
componentDidMount() {
this.initAutocomplete();
}
initAutocomplete() {
searchBox = new google.maps.places.SearchBox( //eslint-disable-line
document.getElementById('places-search'));
searchBox.addListener('places_changed', () => { //eslint-disable-line
this.searchBoxPlaces(searchBox);
});
}
geolocate() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition((position) => {
const geolocation = {
lat: position.coords.latitude,
lng: position.coords.longitude,
};
const circle = new google.maps.Circle({ //eslint-disable-line
center: geolocation,
radius: position.coords.accuracy,
});
console.log(circle.getBounds()); //eslint-disable-line
searchBox.setBounds(circle.getBounds());
});
}
}
searchBoxPlaces(searchbox) {
let pLat;
let pLng;
let address = '';
const places = searchbox.getPlaces();
places.forEach((place) => {
pLat = place.geometry.location.lat();
pLng = place.geometry.location.lng();
address = place.formatted_address;
});
this.props.pickupCord({ pLat, pLng });
if (places.length === 0) {
window.alert('We did not find any places matching that search!'); //eslint-disable-line
}
const { pickup } = this.props.stateAddTask;
this.emitChanges({ ...pickup, from_address: address });
}
emitChanges(newFormState) {
this.props.pickupChange(newFormState);
}
render() {
return (
<div className="locationField">
<input
id="places-search"
placeholder="Search address"
onFocus={this.geolocate} type="text"
onChange={this.onChange}
required
/>
</div>
);
}
}
|
src/js/components/Box.js
|
odedre/grommet-final
|
// (C) Copyright 2014-2016 Hewlett Packard Enterprise Development LP
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { findDOMNode } from 'react-dom';
import KeyboardAccelerators from '../utils/KeyboardAccelerators';
import Intl from '../utils/Intl';
import Props from '../utils/Props';
import { checkDarkBackground } from '../utils/DOM';
import SkipLinkAnchor from './SkipLinkAnchor';
import CSSClassnames from '../utils/CSSClassnames';
import { announce } from '../utils/Announcer';
const CLASS_ROOT = CSSClassnames.BOX;
const BACKGROUND_COLOR_INDEX = CSSClassnames.BACKGROUND_COLOR_INDEX;
/**
* @description General purpose flexible box layout. This supports many, but not all, of the [flexbox](#) capabilities.
*
* @example
* import Box from 'grommet/components/Box';
*
* <Box direction='row'
* justify='start'
* align='center'
* wrap={true}
* pad='medium'
* margin='small'
* colorIndex='light-2'
* onClick={...}
* onFocus={...}>
* <Value value={1}
* colorIndex='accent-1' />
* <Box direction='row'
* justify='start'
* align='center'
* wrap={true}
* pad='medium'
* margin='small'
* colorIndex='light-1'
* onClick={...}
* onFocus={...}>
* <Value value={2} />
* </Box>
* <Box direction='row'
* justify='start'
* align='center'
* wrap={true}
* pad='medium'
* margin='small'
* colorIndex='light-1'
* onClick={...}
* onFocus={...}>
* <Value value={3} />
* </Box>
* </Box>
*
*/
export default class Box extends Component {
constructor (props) {
super(props);
this.state = { mouseActive: false };
}
componentDidMount () {
const { onClick } = this.props;
if (onClick) {
let clickCallback = () => {
if (this.boxContainerRef === document.activeElement) {
onClick();
}
};
KeyboardAccelerators.startListeningToKeyboard(this, {
enter: clickCallback,
space: clickCallback
});
}
this._setDarkBackground();
}
componentWillReceiveProps (nextProps) {
if (nextProps.colorIndex !== this.props.colorIndex) {
if (nextProps.colorIndex) {
this.setState({ updateDarkBackground: true });
} else {
this.setState({ darkBackground: undefined });
}
}
}
componentDidUpdate () {
if (this.props.announce) {
announce(this.boxContainerRef.textContent);
}
if (this.state.updateDarkBackground) {
this.setState({ updateDarkBackground: false });
this._setDarkBackground();
}
}
componentWillUnmount () {
if (this.props.onClick) {
KeyboardAccelerators.stopListeningToKeyboard(this);
}
if (this._checkBackground) {
this._checkBackground.stop();
}
}
_setDarkBackground () {
const { colorIndex } = this.props;
const box = findDOMNode(this.boxContainerRef);
if (this._checkBackground) {
this._checkBackground.stop();
}
this._checkBackground = checkDarkBackground(colorIndex, box,
(darkBackground) => this.setState({ darkBackground }));
}
_normalize (string) {
return string.replace('/', '-');
}
_addPropertyClass (classes, property, options = {}) {
const value = (options.object || this.props)[property];
const elementName = options.elementName || CLASS_ROOT;
const prefix = options.prefix || property;
if (value) {
if (typeof value === 'string') {
classes.push(`${elementName}--${prefix}-${this._normalize(value)}`);
} else if (typeof value === 'object') {
Object.keys(value).forEach((key) => {
this._addPropertyClass(classes, key, {
object: value, prefix: `${prefix}-${key}` });
});
} else {
classes.push(`${elementName}--${this._normalize(prefix)}`);
}
}
}
_backgroundContextClass (darkBackground) {
let result;
if (undefined === darkBackground) {
result = `${BACKGROUND_COLOR_INDEX}--pending`;
} else if (darkBackground) {
result = `${BACKGROUND_COLOR_INDEX}--dark`;
} else {
result = `${BACKGROUND_COLOR_INDEX}--light`;
}
return result;
}
render () {
const {
a11yTitle, appCentered, backgroundImage, children, className,
colorIndex, containerClassName, focusable, full, id, onClick, onBlur,
onFocus, onMouseDown, onMouseUp, pad, primary, role, size, tabIndex,
tag, texture
} = this.props;
const { darkBackground, mouseActive } = this.state;
let classes = [CLASS_ROOT];
let containerClasses = [`${CLASS_ROOT}__container`];
let restProps = Props.omit(this.props, Object.keys(Box.propTypes));
this._addPropertyClass(classes, 'full');
if (full && full.responsive === undefined) {
// default is true for backwards compatibility sake
classes.push(`${CLASS_ROOT}--full-responsive`);
}
this._addPropertyClass(classes, 'direction');
this._addPropertyClass(classes, 'justify');
this._addPropertyClass(classes, 'align');
this._addPropertyClass(classes, 'alignContent',
{ prefix: 'align-content' });
this._addPropertyClass(classes, 'alignSelf',
{ prefix: 'align-self' });
this._addPropertyClass(classes, 'reverse');
this._addPropertyClass(classes, 'responsive');
this._addPropertyClass(classes, 'basis');
this._addPropertyClass(classes, 'flex');
this._addPropertyClass(classes, 'pad');
this._addPropertyClass(classes, 'margin');
this._addPropertyClass(classes, 'separator');
this._addPropertyClass(classes, 'textAlign', { prefix: 'text-align' });
this._addPropertyClass(classes, 'wrap');
if (this.props.hasOwnProperty('flex')) {
if (! this.props.flex) {
classes.push(`${CLASS_ROOT}--flex-off`);
}
}
if (size) {
if (typeof size === 'object') {
Object.keys(size).forEach((key) => {
this._addPropertyClass(classes, key, { object: size });
});
} else {
this._addPropertyClass(classes, 'size');
}
if (size) {
if (!(size.width && size.width.max)) {
// don't apply 100% max-width when size using size.width.max option
classes.push(`${CLASS_ROOT}--size`);
}
if (size.width && size.width.max) {
// allow widths to shrink, apply 100% width
classes.push(`${CLASS_ROOT}--width-max`);
}
}
}
// needed to properly set flex-basis for 1/3 & 2/3 basis boxes
if (pad && pad.between && children) {
if (React.Children.count(children) % 3 === 0) {
classes.push(`${CLASS_ROOT}--pad-between-thirds`);
}
}
if (appCentered) {
this._addPropertyClass(containerClasses, 'full',
{ elementName: `${CLASS_ROOT}__container` });
if (colorIndex) {
containerClasses.push(`${BACKGROUND_COLOR_INDEX}-${colorIndex}`);
containerClasses.push(this._backgroundContextClass(darkBackground));
}
if (containerClassName) {
containerClasses.push(containerClassName);
}
} else if (colorIndex) {
classes.push(`${BACKGROUND_COLOR_INDEX}-${colorIndex}`);
classes.push(this._backgroundContextClass(darkBackground));
}
let a11yProps = {};
let clickableProps = {};
if (onClick) {
classes.push(CLASS_ROOT + "--clickable");
clickableProps = {
onMouseDown: (event) => {
this.setState({ mouseActive: true });
if (onMouseDown) {
onMouseDown(event);
}
},
onMouseUp: (event) => {
this.setState({ mouseActive: false });
if (onMouseUp) {
onMouseUp(event);
}
},
onFocus: (event) => {
if (mouseActive === false) {
this.setState({ focus: true });
}
if (onFocus) {
onFocus(event);
}
},
onBlur: (event) => {
this.setState({ focus: false });
if (onBlur) {
onBlur(event);
}
}
};
if (focusable) {
if (this.state.focus) {
classes.push(`${CLASS_ROOT}--focus`);
}
let boxLabel = (typeof a11yTitle !== 'undefined') ?
a11yTitle : Intl.getMessage(this.context.intl, 'Box');
a11yProps.tabIndex = tabIndex || 0;
a11yProps["aria-label"] = this.props['aria-label'] || boxLabel;
a11yProps.role = role || 'group';
}
}
let skipLinkAnchor;
if (primary) {
let mainContentLabel = (
Intl.getMessage(this.context.intl, 'Main Content')
);
skipLinkAnchor = <SkipLinkAnchor label={mainContentLabel} />;
}
if (className) {
classes.push(className);
}
let style = {};
if (texture && 'string' === typeof texture) {
if (texture.indexOf('url(') !== -1) {
style.backgroundImage = texture;
} else {
style.backgroundImage = `url(${texture})`;
}
} else if (backgroundImage) {
style.background = backgroundImage + " no-repeat center center";
style.backgroundSize = "cover";
}
style = {...style, ...restProps.style};
let textureMarkup;
if ('object' === typeof texture) {
textureMarkup = (
<div className={CLASS_ROOT + "__texture"}>{texture}</div>
);
}
const Component = tag;
if (appCentered) {
return (
<div {...restProps} ref={(ref) => this.boxContainerRef = ref}
className={containerClasses.join(' ')}
style={style} role={role} {...a11yProps} {...clickableProps}>
{skipLinkAnchor}
<Component id={id} className={classes.join(' ')}>
{textureMarkup}
{children}
</Component>
</div>
);
} else {
return (
<Component {...restProps} ref={(ref) => this.boxContainerRef = ref}
id={id} className={classes.join(' ')} style={style}
role={role} tabIndex={tabIndex}
onClick={onClick} {...a11yProps} {...clickableProps}>
{skipLinkAnchor}
{textureMarkup}
{children}
</Component>
);
}
}
}
const FIXED_SIZES = ['xsmall', 'small', 'medium', 'large', 'xlarge', 'xxlarge'];
const RELATIVE_SIZES = ['full', '1/2', '1/3', '2/3', '1/4', '3/4'];
const SIZES = FIXED_SIZES.concat(RELATIVE_SIZES);
const MARGIN_SIZES = ['small', 'medium', 'large', 'none'];
const PAD_SIZES = ['small', 'medium', 'large', 'xlarge', 'none'];
Box.propTypes = {
/**
* @property {PropTypes.string} a11yTitle - Custom title used by screen readers. Defaults to 'Box'. Only used if onClick handler is specified.
*/
a11yTitle: PropTypes.string,
announce: PropTypes.bool,
/**
* @property {start|center|end|baseline|stretch} align - How to align the contents along the cross axis.
*/
align: PropTypes.oneOf(['start', 'center', 'end', 'baseline', 'stretch']),
/**
* @property {start|center|end|between|around|stretch} alignContent - How to align the contents when there is extra space in the cross axis. Defaults to stretch
*/
alignContent: PropTypes.oneOf(['start', 'center', 'end', 'between',
'around', 'stretch']),
/**
* @property {start|center|end|stretch} alignSelf - How to align within its container along the cross axis.
*/
alignSelf: PropTypes.oneOf(['start', 'center', 'end', 'stretch']),
/**
* @property {PropTypes.bool} appCentered - Whether the box background should stretch across an App that is centered.
*/
appCentered: PropTypes.bool,
backgroundImage: PropTypes.string,
/**
* @property {SIZES} basis - Whether to use a fixed or relative size within its container.
*/
basis: PropTypes.oneOf(SIZES),
/**
* @property {PropTypes.string} colorIndex - The color identifier to use for the background color. For example: 'neutral-1'. See Color for possible values.
*/
colorIndex: PropTypes.string,
containerClassName: PropTypes.string,
/**
* @property {row|column} direction - The orientation to layout the child components in. Defaults to column.
*/
direction: PropTypes.oneOf(['row', 'column']),
/**
* @property {PropTypes.bool} focusable - Whether keyboard focus should be added for clickable Boxes. Defaults to true.
*/
focusable: PropTypes.bool,
/**
* @property {grow|shrink|true|false} flex - Whether flex-grow and/or flex-shrink is true.
*/
flex: PropTypes.oneOf(['grow', 'shrink', true, false]),
/**
* @property {PropTypes.bool|PropTypes.string|PropTypes.shape} full - Whether the width and/or height should take the full viewport size.]
*/
full: PropTypes.oneOfType(
[
PropTypes.bool,
PropTypes.string,
PropTypes.shape({
vertical: PropTypes.bool,
horizontal: PropTypes.bool,
responsive: PropTypes.bool
})
]
),
/**
* @property {PropTypes.func} onClick - Optional click handler.
*/
// remove in 1.0?
onClick: PropTypes.func,
/**
* @property {start|center|between|end|around} justify - How to align the contents along the main axis.
*/
justify: PropTypes.oneOf(['start', 'center', 'between', 'end', 'around']),
/**
* @property {none|small|medium|large} margin - The amount of margin around the box. An object can be specified to distinguish horizontal margin, vertical margin, and margin on a particular side of the box: {horizontal: none|small|medium|large, vertical: none|small|medium|large, top|left|right|bottom: none|small|medium|large}. Defaults to none.
*/
margin: PropTypes.oneOfType([
PropTypes.oneOf(MARGIN_SIZES),
PropTypes.shape({
bottom: PropTypes.oneOf(MARGIN_SIZES),
horizontal: PropTypes.oneOf(MARGIN_SIZES),
left: PropTypes.oneOf(MARGIN_SIZES),
right: PropTypes.oneOf(MARGIN_SIZES),
top: PropTypes.oneOf(MARGIN_SIZES),
vertical: PropTypes.oneOf(MARGIN_SIZES)
})
]),
/**
* @property {none|small|medium|large} pad - The amount of padding to put around the contents. An object can be specified to distinguish horizontal padding, vertical padding, and padding between child components: {horizontal: none|small|medium|large, vertical: none|small|medium|large, between: none|small|medium|large}. Defaults to none. Padding set using between only affects components based on the direction set (adds horizontal padding between components for row, or vertical padding between components for column).
*/
pad: PropTypes.oneOfType([
PropTypes.oneOf(PAD_SIZES),
PropTypes.shape({
between: PropTypes.oneOf(PAD_SIZES),
horizontal: PropTypes.oneOf(PAD_SIZES),
vertical: PropTypes.oneOf(PAD_SIZES)
})
]),
/**
* @property {PropTypes.bool} primary - Whether this is a primary Box that will receive skip to main content anchor. Defaults to false.
*/
primary: PropTypes.bool,
/**
* @property {PropTypes.bool} reverse - Whether to reverse the order of the child components.
*/
reverse: PropTypes.bool,
/**
* @property {PropTypes.bool} responsive - Whether children laid out in a row direction should be switched to a column layout when the display area narrows. Defaults to true.
*/
responsive: PropTypes.bool,
role: PropTypes.string,
/**
* @property {top|bottom|left|right|horizontal|vertical|all|none} separator - Add a separator.
*/
separator: PropTypes.oneOf(['top', 'bottom', 'left', 'right',
'horizontal', 'vertical', 'all', 'none']),
/**
* @property {auto|xsmall|small|medium|large|xlarge|xxlarge|full|PropTypes.object} size - The width of the Box. Defaults to auto. An object can be specified to distinguish width, height (with additional min and max options for width and height). E.g. {height: small, width: {max: large}}.
*/
size: PropTypes.oneOfType([
PropTypes.oneOf(['auto', 'xsmall', 'small', 'medium', 'large',
'xlarge', 'xxlarge', 'full']), // remove in 1.0?, use basis
PropTypes.shape({
height: PropTypes.oneOfType([
PropTypes.oneOf(SIZES),
PropTypes.shape({
max: PropTypes.oneOf(FIXED_SIZES),
min: PropTypes.oneOf(FIXED_SIZES)
})
]),
width: PropTypes.oneOfType([
PropTypes.oneOf(SIZES),
PropTypes.shape({
max: PropTypes.oneOf(FIXED_SIZES),
min: PropTypes.oneOf(FIXED_SIZES)
})
])
})
]),
/**
* @property {PropTypes.string} tag - The DOM tag to use for the element. Defaults to div.
*/
tag: PropTypes.string,
/**
* @property {left|center|right} textAlign - Set text-align for the Box contents.
*/
textAlign: PropTypes.oneOf(['left', 'center', 'right']),
/**
* @property {PropTypes.node|PropTypes.string} texture - A texture image URL to apply to the background.
*/
texture: PropTypes.oneOfType([
PropTypes.node,
PropTypes.string
]),
/**
* @property {PropTypes.bool} wrap - Whether children can wrap if they can't all fit. Defaults to false.
*/
wrap: PropTypes.bool
};
Box.contextTypes = {
intl: PropTypes.object
};
Box.defaultProps = {
announce: false,
direction: 'column',
pad: 'none',
tag: 'div',
responsive: true,
focusable: true
};
|
packages/material-ui-icons/src/Timer3.js
|
cherniavskii/material-ui
|
import React from 'react';
import createSvgIcon from './utils/createSvgIcon';
export default createSvgIcon(
<g><path d="M11.61 12.97c-.16-.24-.36-.46-.62-.65-.25-.19-.56-.35-.93-.48.3-.14.57-.3.8-.5.23-.2.42-.41.57-.64.15-.23.27-.46.34-.71.08-.24.11-.49.11-.73 0-.55-.09-1.04-.28-1.46-.18-.42-.44-.77-.78-1.06-.33-.28-.73-.5-1.2-.64-.45-.13-.97-.2-1.53-.2-.55 0-1.06.08-1.52.24-.47.17-.87.4-1.2.69-.33.29-.6.63-.78 1.03-.2.39-.29.83-.29 1.29h1.98c0-.26.05-.49.14-.69.09-.2.22-.38.38-.52.17-.14.36-.25.58-.33.22-.08.46-.12.73-.12.61 0 1.06.16 1.36.47.3.31.44.75.44 1.32 0 .27-.04.52-.12.74-.08.22-.21.41-.38.57-.17.16-.38.28-.63.37-.25.09-.55.13-.89.13H6.72v1.57H7.9c.34 0 .64.04.91.11.27.08.5.19.69.35.19.16.34.36.44.61.1.24.16.54.16.87 0 .62-.18 1.09-.53 1.42-.35.33-.84.49-1.45.49-.29 0-.56-.04-.8-.13-.24-.08-.44-.2-.61-.36-.17-.16-.3-.34-.39-.56-.09-.22-.14-.46-.14-.72H4.19c0 .55.11 1.03.32 1.45.21.42.5.77.86 1.05s.77.49 1.24.63.96.21 1.48.21c.57 0 1.09-.08 1.58-.23.49-.15.91-.38 1.26-.68.36-.3.64-.66.84-1.1.2-.43.3-.93.3-1.48 0-.29-.04-.58-.11-.86-.08-.25-.19-.51-.35-.76zm9.26 1.4c-.14-.28-.35-.53-.63-.74-.28-.21-.61-.39-1.01-.53s-.85-.27-1.35-.38c-.35-.07-.64-.15-.87-.23-.23-.08-.41-.16-.55-.25-.14-.09-.23-.19-.28-.3-.05-.11-.08-.24-.08-.39s.03-.28.09-.41c.06-.13.15-.25.27-.34.12-.1.27-.18.45-.24s.4-.09.64-.09c.25 0 .47.04.66.11.19.07.35.17.48.29.13.12.22.26.29.42.06.16.1.32.1.49h1.95c0-.39-.08-.75-.24-1.09-.16-.34-.39-.63-.69-.88-.3-.25-.66-.44-1.09-.59-.43-.15-.92-.22-1.46-.22-.51 0-.98.07-1.39.21-.41.14-.77.33-1.06.57-.29.24-.51.52-.67.84-.16.32-.23.65-.23 1.01s.08.68.23.96c.15.28.37.52.64.73.27.21.6.38.98.53.38.14.81.26 1.27.36.39.08.71.17.95.26s.43.19.57.29c.13.1.22.22.27.34.05.12.07.25.07.39 0 .32-.13.57-.4.77-.27.2-.66.29-1.17.29-.22 0-.43-.02-.64-.08-.21-.05-.4-.13-.56-.24-.17-.11-.3-.26-.41-.44-.11-.18-.17-.41-.18-.67h-1.89c0 .36.08.71.24 1.05.16.34.39.65.7.93.31.27.69.49 1.15.66.46.17.98.25 1.58.25.53 0 1.01-.06 1.44-.19.43-.13.8-.31 1.11-.54.31-.23.54-.51.71-.83.17-.32.25-.67.25-1.06-.02-.4-.09-.74-.24-1.02z" /></g>
, 'Timer3');
|
ui/me/index.js
|
DannyvanderJagt/portfolio
|
import React from 'react';
import Telescope from 'telescope';
import Config from '../../../portfolio.config';
import Button from '../button';
import Svg from '../svg';
class Me extends Telescope.Component{
render(){
return (
<div className='me'>
<div className='image'>
<img src='/assets/images/me.jpg'/>
</div>
<div className='title'>Danny van der Jagt </div>
<div className='subtitle'>A passionated person</div>
<div className='description'>
Hello! I’m a javascript developer who is interested in everything from front-end to backend and IOT. I'm also a hobby photographer and windsurfer for life!
</div>
<a href='/danny'>
<Button> Read more </Button>
</a>
or
<a href={Config.socialmedia.twitter}>
<Svg name='twitter'/>
</a>
</div>
);
}
};
export default Me;
|
app/resources/author/views/Login.react.js
|
shiminghua/front_end_practice
|
'use strict';
import React, { Component } from 'react';
import InputText from '../../../components/inputs/InputText.react';
import InputPassword from '../../../components/inputs/InputPassword.react';
import '../../../browser/javascript/mui';
class Login extends Component {
constructor(props) {
super(props);
this.state = {
name: '',
pass: ''
};
}
handleChange(event) {
let newState = {};
newState[event.target.name] = event.target.value;
this.setState(newState);
}
handleSubmit(event) {
event.preventDefault();
console.log(this.state);
mui.ajax('/author/login', {
type: 'post',
data: this.state,
dataType: 'json',
success: function(data) {
if(data.code === 200) {
console.log('login success');
window.location.href = '/';
}
else {
console.log(data.message);
}
},
error: function() {
console.log('login error');
}
});
}
render() {
return (
<form onSubmit={this.handleSubmit.bind(this)}>
<InputText className='' name='name' onChange={this.handleChange.bind(this)} placeholder='请输入手机号码或邮箱' />
<InputPassword className='' name='pass' onChange={this.handleChange.bind(this)} placeholder='请输入密码' />
<button type="submit">提交</button>
</form>
);
}
}
export default Login;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.