path
stringlengths 5
296
| repo_name
stringlengths 5
85
| content
stringlengths 25
1.05M
|
|---|---|---|
client/src/components/AdditionalFile.js
|
misha-slyusarev/invoices
|
import React, { Component } from 'react';
import { Input, Button } from 'semantic-ui-react'
export default class AdditionalFile extends Component {
constructor() {
super()
this.state = {}
}
updateDescription = (e) => this.props.updateFileDescription(this.props.id, e.target.value)
removeAdditionalFile = (e) => this.props.removeAdditionalFile(this.props.id)
render() {
return <div>
<strong style={{paddingRight: 10 + 'px'}}>{this.props.fileName}</strong>
<Input placeholder='Description' onChange={this.updateDescription}/>
<Button content='Remove' size='mini' floated='right' negative onClick={this.removeAdditionalFile}/>
</div>
}
}
|
client/components/SignupForm/index.js
|
viatsko/codingbox
|
import React from 'react';
import { Link } from 'react-router';
export default () =>
<div>
<h3 className="col-md-12 text-center">Or sign up using your email</h3>
<div className="col-xs-offset-2 col-xs-8 col-md-offset-4 col-md-4">
<form name="userForm" className="signin" noValidate autoComplete="off">
<fieldset>
<div className="form-group" show-errors>
<label htmlFor="firstName">First Name</label>
<input
type="text" id="firstName" name="firstName"
className="form-control" placeholder="First Name" required
/>
</div>
<div className="form-group" show-errors>
<label htmlFor="lastName">Last Name</label>
<input
type="text" id="lastName" name="lastName"
className="form-control" placeholder="Last Name" required
/>
</div>
<div className="form-group" show-errors>
<label htmlFor="email">Email</label>
<input
type="email" id="email" name="email" className="form-control"
placeholder="Email" lowercase required
/>
</div>
<div className="form-group" show-errors>
<label htmlFor="username">Username</label>
<input
type="text" id="username" name="username" className="form-control"
placeholder="Username" lowercase required
/>
</div>
<div className="form-group" show-errors>
<label htmlFor="password">Password</label>
<input
type="password" id="password" name="password" className="form-control"
placeholder="Password" required
/>
</div>
<div className="text-center form-group">
<button type="submit" className="btn btn-primary">Sign up</button>
or
<Link to="/signin" className="show-signup">Sign in</Link>
</div>
</fieldset>
</form>
</div>
</div>;
|
samples/sample1/src/index.js
|
codazen/formulationjs
|
'use strict';
import React from 'react';
import ReactDOM from 'react-dom';
import Formulation from '../../../src';
import FormulationTest from '../../src';
import formDef from './forms/formDef.json';
var form = new FormulationTest(formDef);
form.render('sample-1');
|
lib/button/index.js
|
andyfen/react-native-UIKit
|
import React from 'react';
import {
StyleSheet,
Text,
TouchableOpacity,
} from 'react-native';
import { primary, gutter } from '../variables';
const styles = StyleSheet.create({
text: {
fontSize: 18,
fontWeight: '600',
textAlign: 'center',
},
});
const Button = ({
children, radius, fontWeight, fontSize,
backgroundColor, color, gutter, onPress,
style, textStyle
}) => (
<TouchableOpacity
style={[ { borderRadius: radius, backgroundColor, padding: gutter, marginBottom: gutter }, style ]}
onPress={onPress}
>
<Text style={[ styles.text, { color, fontSize, fontWeight }, textStyle]}>
{children}
</Text>
</TouchableOpacity>
);
Button.defaultProps = {
radius: 4,
backgroundColor: primary,
color: '#fff',
gutter,
style: {},
textStyle: {},
};
Button.propTypes = {
radius: React.PropTypes.number,
type: React.PropTypes.string,
invert: React.PropTypes.bool,
backgroundColor: React.PropTypes.string,
color: React.PropTypes.string,
gutter: React.PropTypes.number,
fontWeight: React.PropTypes.string,
children: React.PropTypes.string.isRequired,
fontSize: React.PropTypes.number,
onPress: React.PropTypes.func,
};
export default Button;
|
modules/components/__tests__/Menu-test.js
|
devrieda/arc-reactor
|
import React from 'react';
import ReactDOM from 'react-dom';
import TestUtils from 'react-addons-test-utils';
import { fromJS } from 'immutable';
import Menu from '../Menu.js';
import ConfigManager from '../../helpers/ConfigManager';
const findByClass = TestUtils.findRenderedDOMComponentWithClass;
const render = TestUtils.renderIntoDocument;
const { click, input, keyUp } = TestUtils.Simulate;
ConfigManager.install({});
describe('Menu', () => {
it('should render', () => {
const content = { sections: [] };
const selection = {
guids: () => {},
offsets: () => {},
showMenuButtons: () => { return true; }
};
const menu = render(
<Menu content={fromJS(content)} selection={selection} />
);
const menuComponent = findByClass(menu, 'arc-Editor-Menu');
expect(menuComponent).to.exist;
});
it('should render buttons', () => {
const content = { sections: [] };
const selection = {
guids: () => {},
offsets: () => {},
showMenuButtons: () => { return true; }
};
const menu = render(
<Menu content={fromJS(content)} selection={selection} />
);
const button = findByClass(menu, 'arc-Editor-MenuButton--strong');
expect(button).to.exist;
});
// events
it('should switch to input mode when clicking button that requires value', () => {
const content = { sections: [] };
const selection = {
guids: () => {},
offsets: () => {},
showMenuButtons: () => { return true; }
};
const menu = render(
<Menu content={fromJS(content)} selection={selection} />
);
const button = findByClass(menu, 'arc-Editor-MenuButton--a');
click(button);
const component = findByClass(menu, 'arc-Editor-Menu__linkinput--active');
expect(component).to.exist;
});
it('should switch back to button mode when entering input value', () => {
const content = { sections: [] };
const selection = {
guids: () => {},
offsets: () => {},
showMenuButtons: () => { return true; }
};
const menu = render(
<Menu content={fromJS(content)} selection={selection} />
);
const button = findByClass(menu, 'arc-Editor-MenuButton--a');
click(button);
input(button, "http://google.com");
keyUp(button, {keyCode: 13});
const component = findByClass(menu, 'arc-Editor-Menu--active');
expect(component).to.exist;
});
// TODO - can test this once we have full plugins working
// need to be able to customize buttons to work
//
// it('should check whether button is visible', () => {
// const content = { sections: [] };
// const selection = {
// guids: () => {},
// offsets: () => {},
// showMenuButtons: () => { return true; }
// };
// const bold = <MenuButtons.Bold />;
// sinon.stub(bold.type, "isVisible", () => true);
// render(
// <Menu content={fromJS(content)} selection={selection} />
// );
// expect(bold.type.isVisible.called).to.be.true;
// bold.type.isVisible.restore();
// });
// classes
it('should be active if text is selected', () => {
const content = { sections: [] };
const selection = {
text: 'hey',
types: ['p'],
guids: () => { return { anchor: '', focus: '' }; },
offsets: () => { return { anchor: 0, focus: 0 }; },
reselect: () => {},
rebound: () => {},
showMenuButtons: () => { return true; }
};
const menu = render(
<Menu content={fromJS(content)} selection={selection} />
);
expect(ReactDOM.findDOMNode(menu).classList.contains('arc-Editor-Menu--active')).to.be.true;
});
it('should build styles based off bounds', () => {
const content = { sections: [] };
const selection = {
text: 'hey',
types: ['p'],
guids: () => { return { anchor: '', focus: '' }; },
offsets: () => { return { anchor: 0, focus: 0 }; },
reselect: () => {},
rebound: () => {},
bounds: {top: 20, left: 20, width: 20},
showMenuButtons: () => { return true; }
};
const menu = render(
<Menu content={fromJS(content)} selection={selection} />
);
const styles = menu.menuStyles();
expect(styles.top).to.be;
expect(styles.left).to.be;
});
});
|
examples/todo/js/components/TodoApp.js
|
meteor/relay-runtime-query
|
/**
* 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 AddTodoMutation from '../mutations/AddTodoMutation';
import TodoListFooter from './TodoListFooter';
import TodoTextInput from './TodoTextInput';
import React from 'react';
import Relay from 'react-relay';
class TodoApp extends React.Component {
_handleTextInputSave = (text) => {
Relay.Store.commitUpdate(
new AddTodoMutation({text, viewer: this.props.viewer})
);
};
render() {
var hasTodos = this.props.viewer.totalCount > 0;
return (
<div>
<section className="todoapp">
<header className="header">
<h1>
todos
</h1>
<TodoTextInput
autoFocus={true}
className="new-todo"
onSave={this._handleTextInputSave}
placeholder="What needs to be done?"
/>
</header>
{this.props.children}
{hasTodos &&
<TodoListFooter
todos={this.props.viewer.todos}
viewer={this.props.viewer}
/>
}
</section>
<footer className="info">
<p>
Double-click to edit a todo
</p>
<p>
Created by the <a href="https://facebook.github.io/relay/">
Relay team
</a>
</p>
<p>
Part of <a href="http://todomvc.com">TodoMVC</a>
</p>
</footer>
</div>
);
}
}
export default Relay.createContainer(TodoApp, {
fragments: {
viewer: () => Relay.QL`
fragment on User {
totalCount,
${AddTodoMutation.getFragment('viewer')},
${TodoListFooter.getFragment('viewer')},
}
`,
},
});
|
packages/react-examples/src/pages/indicators/index.js
|
ustbhuangyi/better-scroll
|
import React from 'react'
import './index.styl'
const examples = [
{
path: '/indicators/minimap',
name: 'minimap',
},
{
path: '/indicators/parallax-scroll',
name: 'parallax scroll',
},
]
const Indicators = (props) => {
const goPage = (path) => {
props.history.push(path)
}
return (
<div className="view core">
<ul className="example-list">
{examples.map((item) => (
<li
className="example-item"
onClick={() => goPage(item.path)}
key={item.path}
>
<span>{item.name}</span>
</li>
))}
</ul>
{props.children}
</div>
)
}
export default Indicators
|
src/components/Form/FormLabel.js
|
sk-iv/iva-app
|
import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
if(process.env.WEBPACK) require('./FormLabel.css');
function FormLabel(props, context) {
const {
children,
classes,
className: classNameProp,
component: Component,
disabled: disabledProp,
error: errorProp,
focused: focusedProp,
required: requiredProp,
...other
} = props;
const { muiFormControl } = context;
let required = requiredProp;
let focused = focusedProp;
let disabled = disabledProp;
let error = errorProp;
if (muiFormControl) {
if (typeof required === 'undefined') {
required = muiFormControl.required;
}
if (typeof focused === 'undefined') {
focused = muiFormControl.focused;
}
if (typeof disabled === 'undefined') {
disabled = muiFormControl.disabled;
}
if (typeof error === 'undefined') {
error = muiFormControl.error;
}
}
const className = classNames(
'form-label',
{
['form-label--focused']: focused,
['form-label--disabled']: disabled,
['form-label--error']: error,
},
classNameProp,
);
const asteriskClassName = classNames({
['form-label--error']: error,
});
return (
<Component className={className} {...other}>
{children}
{required && (
<span className={asteriskClassName} data-mui-test="FormLabelAsterisk">
{'\u2009*'}
</span>
)}
</Component>
);
}
FormLabel.propTypes = {
/**
* The content of the component.
*/
children: PropTypes.node,
/**
* @ignore
*/
className: PropTypes.string,
/**
* The component used for the root node.
* Either a string to use a DOM element or a component.
*/
component: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
/**
* If `true`, the label should be displayed in a disabled state.
*/
disabled: PropTypes.bool,
/**
* If `true`, the label should be displayed in an error state.
*/
error: PropTypes.bool,
/**
* If `true`, the input of this label is focused (used by `FormGroup` components).
*/
focused: PropTypes.bool,
/**
* If `true`, the label will indicate that the input is required.
*/
required: PropTypes.bool,
};
FormLabel.defaultProps = {
component: 'label',
};
FormLabel.contextTypes = {
muiFormControl: PropTypes.object,
};
export default FormLabel;
|
app/containers/App/index.js
|
kathydoody/scalable-react-demo
|
/**
*
* App.react.js
*
* This component is the skeleton around the actual pages, and should only
* contain code that should be seen on all pages. (e.g. navigation bar)
*
* 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 styles from './styles.css';
export default class App extends React.Component { // eslint-disable-line react/prefer-stateless-function
static propTypes = {
children: React.PropTypes.node,
};
render() {
return (
<div className={styles.container}>
{React.Children.toArray(this.props.children)}
</div>
);
}
}
|
src/client/components/Button/__tests__/Topic.js
|
busyorg/busy
|
import React from 'react';
import { shallow } from 'enzyme';
import Topic from '../Topic';
describe('<Topic />', () => {
it('renders without exploding', () => {
const props = {
name: 'exampletopic',
favorite: true,
closable: true,
};
const wrapper = shallow(<Topic {...props} />);
expect(wrapper).toMatchSnapshot();
});
});
|
app/components/SimilarProducts.js
|
Byte-Code/lm-digital-store-private-test
|
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import ImmutablePropTypes from 'react-immutable-proptypes';
import { List } from 'immutable';
import glamorous from 'glamorous';
import ProductBadge from './ProductBadge';
import SimilarProductsDialog from './SimilarProductsDialog';
const Wrapper = glamorous.div({
paddingLeft: '40px',
display: 'flex'
});
const Header = glamorous.div({
width: '130px',
'&>h3': {
fontSize: '16px',
textTransform: 'uppercase',
paddingRight: '60px'
}
});
const Slider = glamorous.div({
display: 'flex',
overflowX: 'auto',
'&>div': {
marginRight: '20px'
}
});
export default class SimilarProducts extends Component {
static propTypes = {
similarProducts: ImmutablePropTypes.list,
title: PropTypes.string.isRequired,
setAnalyticsProductClick: PropTypes.func.isRequired
};
static defaultProps = {
similarProducts: List()
};
constructor(props) {
super(props);
this.state = {
dialogOpen: false,
selectedProduct: ''
};
}
handleOpen = product => {
this.setState({
selectedProduct: product,
dialogOpen: true
});
};
handleClose = () => {
this.setState({ dialogOpen: false });
};
renderProducts() {
const { similarProducts } = this.props;
return similarProducts.map(p => (
<ProductBadge
key={p.get('code')}
productInfo={p}
handleClick={() => this.handleOpen(p.get('code'))}
/>
));
}
render() {
const { similarProducts, title } = this.props;
if (similarProducts.isEmpty()) {
return null;
}
const { dialogOpen, selectedProduct } = this.state;
return (
<Wrapper>
<Header>
<h3>{title}</h3>
</Header>
<Slider>
{this.renderProducts()}
</Slider>
<SimilarProductsDialog
similarProducts={similarProducts}
handleClose={this.handleClose}
isOpen={dialogOpen}
selectedProduct={selectedProduct}
setAnalyticsProductClick={this.props.setAnalyticsProductClick}
/>
</Wrapper>
);
}
}
|
client/src/components/EventIndex/EventPreview.js
|
Stanley288/buddy-finder-app
|
import React from 'react'
import { graphql } from 'react-apollo'
import gql from 'graphql-tag'
import Link from 'react-router'
class EventPreview extends React.Component {
static propTypes = {
event: React.PropTypes.object,
}
render () {
return (
<Link
to={`/view/event/${this.props.event.id}`}
style={{ minWidth: 200 }}
>
<ul>
<li>Event Name: {this.props.event.name}</li>
<li>Time: {this.props.event.dateTime}</li>
<li>Location: {this.props.event.location.lat}, {this.props.event.location.lng}</li>
<li>Guests: {this.props.event.numGuests}</li>
</ul>
</Link>
)
}
}
|
node_modules/@material-ui/core/esm/FormControl/FormControlContext.js
|
pcclarke/civ-techs
|
import React from 'react';
/**
* @ignore - internal component.
*/
var FormControlContext = React.createContext();
export default FormControlContext;
|
src/mui/field/FunctionField.spec.js
|
matteolc/admin-on-rest
|
import React from 'react';
import assert from 'assert';
import { shallow } from 'enzyme';
import FunctionField from './FunctionField';
describe('<FunctionField />', () => {
it('should render using the render function', () => {
const record = { foo: 'bar' };
const wrapper = shallow(<FunctionField record={record} render={r => r['foo'].substr(0,2)} />);
assert.equal(wrapper.html(), '<span>ba</span>');
});
});
|
js/app.js
|
tmck2/rgrjs
|
import React from 'react';
import ReactDOM from 'react-dom';
import Main from "./components/Main";
ReactDOM.render(<Main />, document.getElementById('react'));
|
fields/components/NestedFormField.js
|
dvdcastro/keystone
|
import React from 'react';
import { StyleSheet, css } from 'aphrodite/no-important';
import { FormField, FormLabel } from 'elemental';
import theme from '../../admin/client/theme';
function NestedFormField ({ children, className, label, ...props }) {
return (
<FormField {...props}>
<FormLabel className={css(classes.label)}>{label}</FormLabel>
{children}
</FormField>
);
};
const classes = StyleSheet.create({
label: {
color: theme.color.gray40,
fontSize: theme.font.size.small,
paddingLeft: '1em',
},
});
module.exports = NestedFormField;
|
actor-apps/app-web/src/app/components/modals/AddContact.react.js
|
hejunbinlan/actor-platform
|
import _ from 'lodash';
import React from 'react';
import Modal from 'react-modal';
import pureRender from 'pure-render-decorator';
import { Styles, TextField, FlatButton } from 'material-ui';
import AddContactStore from 'stores/AddContactStore';
import AddContactActionCreators from 'actions/AddContactActionCreators';
import classNames from 'classnames';
import { KeyCodes } from 'constants/ActorAppConstants';
import ActorTheme from 'constants/ActorTheme';
const ThemeManager = new Styles.ThemeManager();
const appElement = document.getElementById('actor-web-app');
Modal.setAppElement(appElement);
const getStateFromStores = () => {
return {
isShown: AddContactStore.isModalOpen(),
message: AddContactStore.getMessage()
};
};
@pureRender
class AddContact extends React.Component {
static childContextTypes = {
muiTheme: React.PropTypes.object
};
getChildContext() {
return {
muiTheme: ThemeManager.getCurrentTheme()
};
}
constructor(props) {
super(props);
this.state = _.assign({
phone: ''
}, getStateFromStores());
AddContactStore.addChangeListener(this.onChange);
document.addEventListener('keydown', this.onKeyDown, false);
ThemeManager.setTheme(ActorTheme);
ThemeManager.setComponentThemes({
textField: {
textColor: 'rgba(0,0,0,.87)',
focusColor: '#68a3e7',
backgroundColor: 'transparent',
borderColor: '#68a3e7'
}
});
}
componentWillUnmount() {
AddContactStore.removeChangeListener(this.onChange);
document.removeEventListener('keydown', this.onKeyDown, false);
}
render() {
const messageClassName = classNames({
'error-message': true,
'error-message--shown': this.state.message
});
return (
<Modal className="modal-new modal-new--add-contact"
closeTimeoutMS={150}
isOpen={this.state.isShown}
style={{width: 320}}>
<header className="modal-new__header">
<a className="modal-new__header__close material-icons"
onClick={this.onClose}>clear</a>
<h3 className="modal-new__header__title">Add contact</h3>
</header>
<div className="modal-new__body">
<TextField className="login__form__input"
floatingLabelText="Phone number"
fullWidth
onChange={this.onPhoneChange}
type="tel"
value={this.state.phone}/>
</div>
<span className={messageClassName}>{this.state.message}</span>
<footer className="modal-new__footer text-right">
<FlatButton hoverColor="rgba(74,144,226,.12)"
label="Add"
onClick={this.onAddContact}
secondary={true} />
</footer>
</Modal>
);
}
onClose = () => {
AddContactActionCreators.closeModal();
}
onPhoneChange = event => {
this.setState({phone: event.target.value});
}
onAddContact = () => {
AddContactActionCreators.findUsers(this.state.phone);
}
onChange = () => {
this.setState(getStateFromStores());
}
onKeyDown = (event) => {
if (event.keyCode === KeyCodes.ESC) {
event.preventDefault();
this.onClose();
}
}
}
export default AddContact;
|
app/javascript/mastodon/features/status/components/action_bar.js
|
Craftodon/Craftodon
|
import React from 'react';
import PropTypes from 'prop-types';
import IconButton from '../../../components/icon_button';
import ImmutablePropTypes from 'react-immutable-proptypes';
import DropdownMenuContainer from '../../../containers/dropdown_menu_container';
import { defineMessages, injectIntl } from 'react-intl';
import { me } from '../../../initial_state';
const messages = defineMessages({
delete: { id: 'status.delete', defaultMessage: 'Delete' },
mention: { id: 'status.mention', defaultMessage: 'Mention @{name}' },
reply: { id: 'status.reply', defaultMessage: 'Reply' },
reblog: { id: 'status.reblog', defaultMessage: 'Boost' },
cannot_reblog: { id: 'status.cannot_reblog', defaultMessage: 'This post cannot be boosted' },
favourite: { id: 'status.favourite', defaultMessage: 'Favourite' },
mute: { id: 'status.mute', defaultMessage: 'Mute @{name}' },
muteConversation: { id: 'status.mute_conversation', defaultMessage: 'Mute conversation' },
unmuteConversation: { id: 'status.unmute_conversation', defaultMessage: 'Unmute conversation' },
block: { id: 'status.block', defaultMessage: 'Block @{name}' },
report: { id: 'status.report', defaultMessage: 'Report @{name}' },
share: { id: 'status.share', defaultMessage: 'Share' },
pin: { id: 'status.pin', defaultMessage: 'Pin on profile' },
unpin: { id: 'status.unpin', defaultMessage: 'Unpin from profile' },
embed: { id: 'status.embed', defaultMessage: 'Embed' },
});
@injectIntl
export default class ActionBar extends React.PureComponent {
static contextTypes = {
router: PropTypes.object,
};
static propTypes = {
status: ImmutablePropTypes.map.isRequired,
onReply: PropTypes.func.isRequired,
onReblog: PropTypes.func.isRequired,
onFavourite: PropTypes.func.isRequired,
onDelete: PropTypes.func.isRequired,
onMention: PropTypes.func.isRequired,
onMute: PropTypes.func,
onMuteConversation: PropTypes.func,
onBlock: PropTypes.func,
onReport: PropTypes.func,
onPin: PropTypes.func,
onEmbed: PropTypes.func,
intl: PropTypes.object.isRequired,
};
handleReplyClick = () => {
this.props.onReply(this.props.status);
}
handleReblogClick = (e) => {
this.props.onReblog(this.props.status, e);
}
handleFavouriteClick = () => {
this.props.onFavourite(this.props.status);
}
handleDeleteClick = () => {
this.props.onDelete(this.props.status);
}
handleMentionClick = () => {
this.props.onMention(this.props.status.get('account'), this.context.router.history);
}
handleMuteClick = () => {
this.props.onMute(this.props.status.get('account'));
}
handleConversationMuteClick = () => {
this.props.onMuteConversation(this.props.status);
}
handleBlockClick = () => {
this.props.onBlock(this.props.status.get('account'));
}
handleReport = () => {
this.props.onReport(this.props.status);
}
handlePinClick = () => {
this.props.onPin(this.props.status);
}
handleShare = () => {
navigator.share({
text: this.props.status.get('search_index'),
url: this.props.status.get('url'),
});
}
handleEmbed = () => {
this.props.onEmbed(this.props.status);
}
render () {
const { status, intl } = this.props;
const publicStatus = ['public', 'unlisted'].includes(status.get('visibility'));
const mutingConversation = status.get('muted');
let menu = [];
if (publicStatus) {
menu.push({ text: intl.formatMessage(messages.embed), action: this.handleEmbed });
}
if (me === status.getIn(['account', 'id'])) {
if (publicStatus) {
menu.push({ text: intl.formatMessage(status.get('pinned') ? messages.unpin : messages.pin), action: this.handlePinClick });
}
menu.push(null);
menu.push({ text: intl.formatMessage(mutingConversation ? messages.unmuteConversation : messages.muteConversation), action: this.handleConversationMuteClick });
menu.push(null);
menu.push({ text: intl.formatMessage(messages.delete), action: this.handleDeleteClick });
} else {
menu.push({ text: intl.formatMessage(messages.mention, { name: status.getIn(['account', 'username']) }), action: this.handleMentionClick });
menu.push(null);
menu.push({ text: intl.formatMessage(messages.mute, { name: status.getIn(['account', 'username']) }), action: this.handleMuteClick });
menu.push({ text: intl.formatMessage(messages.block, { name: status.getIn(['account', 'username']) }), action: this.handleBlockClick });
menu.push({ text: intl.formatMessage(messages.report, { name: status.getIn(['account', 'username']) }), action: this.handleReport });
}
const shareButton = ('share' in navigator) && status.get('visibility') === 'public' && (
<div className='detailed-status__button'><IconButton title={intl.formatMessage(messages.share)} icon='share-alt' onClick={this.handleShare} /></div>
);
let reblogIcon = 'retweet';
if (status.get('visibility') === 'direct') reblogIcon = 'envelope';
else if (status.get('visibility') === 'private') reblogIcon = 'lock';
let reblog_disabled = (status.get('visibility') === 'direct' || status.get('visibility') === 'private');
return (
<div className='detailed-status__action-bar'>
<div className='detailed-status__button'><IconButton title={intl.formatMessage(messages.reply)} icon={status.get('in_reply_to_id', null) === null ? 'reply' : 'reply-all'} onClick={this.handleReplyClick} /></div>
<div className='detailed-status__button'><IconButton disabled={reblog_disabled} active={status.get('reblogged')} title={reblog_disabled ? intl.formatMessage(messages.cannot_reblog) : intl.formatMessage(messages.reblog)} icon={reblogIcon} onClick={this.handleReblogClick} /></div>
<div className='detailed-status__button'><IconButton animate active={status.get('favourited')} title={intl.formatMessage(messages.favourite)} icon='star' onClick={this.handleFavouriteClick} activeStyle={{ color: '#ca8f04' }} /></div>
{shareButton}
<div className='detailed-status__action-bar-dropdown'>
<DropdownMenuContainer size={18} icon='ellipsis-h' items={menu} direction='left' title='More' />
</div>
</div>
);
}
}
|
test/higherOrder.spec.js
|
naoufal/higher-order
|
import expect from 'expect';
import React from 'react';
import higherOrder from '../src/higherOrder';
import MyComponent from './components/MyComponent';
import HigherOrderComponent from './components/HigherOrderComponent';
import AnotherHigherOrderComponent from './components/AnotherHigherOrderComponent';
describe("higherOrder", () => {
it("should build a higher-order component", () => {
const ComposedComponent = higherOrder(MyComponent)(HigherOrderComponent)
expect(ComposedComponent.displayName)
.toBe('HigherOrderComponent(MyComponent)');
});
it("should respect order of higher-order component arguments", () => {
const FirstHigherOrderComponent = HigherOrderComponent;
const SecondHigherOrderComponent = AnotherHigherOrderComponent;
const ComposedComponent = higherOrder(MyComponent)(
FirstHigherOrderComponent,
SecondHigherOrderComponent
);
expect(ComposedComponent.displayName)
.toBe('HigherOrderComponent(AnotherHigherOrderComponent(MyComponent))');
});
});
|
src/Popup/PopupElement.js
|
ctco/rosemary-ui
|
import React from 'react';
import PropTypes from 'prop-types';
class PopupElement extends React.Component {
componentDidMount() {
this.props.didMount(this._popupElement);
}
componentWillUnmount() {
this.props.onUnmount();
}
render() {
let attrForType = this.context.parentType;
let attrForId = this.props.id || this.context.id;
let testId = this.props.testId || (this.context.testId && this.context.testId + '_popup');
return (
<div
ref={popupElement => (this._popupElement = popupElement)}
data-attr-for-type={attrForType}
data-attr-for-id={attrForId}
data-test-id={testId}
className="popup-content-wrapper"
style={this.props.style}
>
<div className="popup-content">
{this.props.modal && (
<i className="im icon-close popup-close icon--xxs" onClick={() => this.props.close()} />
)}
{this.props.children}
</div>
</div>
);
}
}
PopupElement.contextTypes = {
id: PropTypes.string,
parentType: PropTypes.string,
testId: PropTypes.string,
style: PropTypes.any
};
export default PopupElement;
|
app/src/modules/User/components/TestComp/TestComp.js
|
betofigueiredo/homelibraries.org
|
import React from 'react';
// CSS
import CSSModules from 'react-css-modules';
import styles from './style.module.sass';
const TestComp = () => (
<div className="grid-container full" data-test="mybooks-render">
<div className="grid-x">
<div className="medium-12 cell">
<div styleName="top-bar">TestComp</div>
</div>
</div>
</div>
);
export default CSSModules(TestComp, styles, { allowMultiple: true });
|
src/pages/tags.js
|
aberkow/gatsby-blog
|
import React from 'react';
import Link from 'gatsby-link';
import { BlogPostContent, BlogPostContainer, TagList } from '../utils/styles';
import { arrayReducer } from '../utils/helpers';
export default function TagsPage({
data
}) {
const { edges: posts } = data.allMarkdownRemark;
const tagsArray = arrayReducer(posts, 'tags');
const tagLinks = tagsArray.map((tag, index) => {
return (
<li className="tag-item" key={index}>
<Link className='tag-list-link' to={`/tags/${tag}`} key={index}>{tag}</Link>
</li>
)
});
return (
<BlogPostContainer>
<BlogPostContent>
<h2>Tags</h2>
<TagList className='tags-list'>{tagLinks}</TagList>
</BlogPostContent>
</BlogPostContainer>
);
}
export const query = graphql`
query TagPage {
allMarkdownRemark(sort: { fields: [frontmatter___date], order: DESC }) {
totalCount
edges {
node {
frontmatter {
tags
}
}
}
}
}
`;
|
src/js/routes.js
|
Chandransh/hackerearth-challenge-page
|
import React from 'react';
import {Route, IndexRoute} from 'react-router';
import Home from './containers/Home/Home';
import ChallengePage from './connect-views/ChallengePage/ChallengePage';
import NotFoundView from './static-views/NotFoundView/NotFoundView';
export default (
<Route path="/" component={Home}>
<IndexRoute component={ChallengePage}/>
<Route path="*" component={NotFoundView}/>
</Route>
);
|
packages/material-ui-icons/src/Landscape.js
|
dsslimshaddy/material-ui
|
import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from 'material-ui/SvgIcon';
let Landscape = props =>
<SvgIcon {...props}>
<path d="M14 6l-3.75 5 2.85 3.8-1.6 1.2C9.81 13.75 7 10 7 10l-6 8h22L14 6z" />
</SvgIcon>;
Landscape = pure(Landscape);
Landscape.muiName = 'SvgIcon';
export default Landscape;
|
tests/components/Header/Header.spec.js
|
nskpaun/group-therapist
|
import React from 'react'
import { Header } from 'components/Header/Header'
import classes from 'components/Header/Header.scss'
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={classes.activeRoute} to='/'>
Home
</IndexLink>
)).to.be.true
})
it('Should render a Link to Counter route', () => {
expect(_wrapper.contains(
<Link activeClassName={classes.activeRoute} to='/counter'>
Counter
</Link>
)).to.be.true
})
})
})
|
app/javascript/mastodon/features/ui/components/column.js
|
increments/mastodon
|
import React from 'react';
import ColumnHeader from './column_header';
import PropTypes from 'prop-types';
import { debounce } from 'lodash';
import { scrollTop } from '../../../scroll';
import { isMobile } from '../../../is_mobile';
export default class Column extends React.PureComponent {
static propTypes = {
heading: PropTypes.string,
icon: PropTypes.string,
children: PropTypes.node,
active: PropTypes.bool,
hideHeadingOnMobile: PropTypes.bool,
};
handleHeaderClick = () => {
const scrollable = this.node.querySelector('.scrollable');
if (!scrollable) {
return;
}
this._interruptScrollAnimation = scrollTop(scrollable);
}
scrollTop () {
const scrollable = this.node.querySelector('.scrollable');
if (!scrollable) {
return;
}
this._interruptScrollAnimation = scrollTop(scrollable);
}
handleScroll = debounce(() => {
if (typeof this._interruptScrollAnimation !== 'undefined') {
this._interruptScrollAnimation();
}
}, 200)
setRef = (c) => {
this.node = c;
}
render () {
const { heading, icon, children, active, hideHeadingOnMobile } = this.props;
const showHeading = heading && (!hideHeadingOnMobile || (hideHeadingOnMobile && !isMobile(window.innerWidth)));
const columnHeaderId = showHeading && heading.replace(/ /g, '-');
const header = showHeading && (
<ColumnHeader icon={icon} active={active} type={heading} onClick={this.handleHeaderClick} columnHeaderId={columnHeaderId} />
);
return (
<div
ref={this.setRef}
role='region'
aria-labelledby={columnHeaderId}
className='column'
onScroll={this.handleScroll}
>
{header}
{children}
</div>
);
}
}
|
src/components/ShareExperience/InterviewStepsForm/BasicInfo/index.js
|
goodjoblife/GoodJobShare
|
import React from 'react';
import PropTypes from 'prop-types';
import subscribeValidation from 'common/subscribeValidation';
import Block from 'common/Block';
import {
companyQuery as companyQueryValidator,
jobTitle as jobTitleValidator,
region as regionValidator,
} from '../formCheck';
import CompanyQuery from '../../common/CompanyQuery';
import Region from '../../common/Region';
import JobTitle from '../../common/JobTitle';
import shareStyles from '../../common/share.module.css';
import { COMPANY, REGION, JOB_TITLE } from '../../../../constants/formElements';
const CompanyQueryWithValidation = subscribeValidation(
CompanyQuery,
props => props.validator(props.companyQuery),
COMPANY,
);
const RegionWithValidation = subscribeValidation(
Region,
props => props.validator(props.region),
REGION,
);
const JobTitleWithValidation = subscribeValidation(
JobTitle,
props => props.validator(props.jobTitle),
JOB_TITLE,
);
class InterviewInfo extends React.PureComponent {
render() {
const {
handleState,
companyQuery,
region,
jobTitle,
submitted,
changeValidationStatus,
} = this.props;
return (
<Block heading="你是去哪間公司面試哪個職務呢?" requiredText>
<div
style={{
marginBottom: '35px',
}}
>
<CompanyQueryWithValidation
companyQuery={companyQuery}
onChange={v => {
handleState('companyQuery')(v);
handleState('title')(`${v} 面試經驗分享`);
}}
onCompanyId={handleState('companyId')}
validator={companyQueryValidator}
submitted={submitted}
changeValidationStatus={changeValidationStatus}
/>
</div>
<div
style={{
marginBottom: '41px',
}}
>
<RegionWithValidation
region={region}
inputTitle={'面試地區'}
onChange={handleState('region')}
validator={regionValidator}
submitted={submitted}
changeValidationStatus={changeValidationStatus}
/>
</div>
<div>
<JobTitleWithValidation
className={shareStyles.single__select__input}
inputTitle="應徵職稱"
jobTitle={jobTitle}
onChange={handleState('jobTitle')}
validator={jobTitleValidator}
submitted={submitted}
changeValidationStatus={changeValidationStatus}
/>
</div>
</Block>
);
}
}
InterviewInfo.propTypes = {
companyQuery: PropTypes.string.isRequired,
region: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
jobTitle: PropTypes.string.isRequired,
handleState: PropTypes.func.isRequired,
submitted: PropTypes.bool.isRequired,
changeValidationStatus: PropTypes.func.isRequired,
};
export default InterviewInfo;
|
src/index.js
|
jmikrut/keen-2017
|
import React from 'react';
import { hydrate, render } from 'react-dom';
import { Provider } from 'react-redux';
import { BrowserRouter as Router } from 'react-router-dom';
import store from './store';
import App from './components/App';
const rootElement = document.getElementById('root');
const Index = () => {
return (
<Provider store={store}>
<Router>
<App />
</Router>
</Provider>
)
}
if (rootElement.hasChildNodes()) {
hydrate(<Index />, rootElement);
} else {
render(<Index />, rootElement);
}
|
addons/ondevice-knobs/src/types/Number.js
|
storybooks/react-storybook
|
import PropTypes from 'prop-types';
import React from 'react';
import { View, Slider } from 'react-native';
import styled from '@emotion/native';
const Input = styled.TextInput(({ theme }) => ({
borderWidth: 1,
borderColor: theme.borderColor,
borderRadius: 2,
fontSize: 13,
padding: 5,
color: theme.labelColor,
}));
class NumberType extends React.Component {
constructor(props) {
super(props);
this.renderNormal = this.renderNormal.bind(this);
this.renderRange = this.renderRange.bind(this);
}
numberTransformer = x => {
if (Number.isNaN(Number(x))) {
return x.substr(0, x.length - 1);
}
return x;
};
onChangeNormal = value => {
const { onChange } = this.props;
if (!Number.isNaN(value)) {
onChange(value);
}
};
renderNormal() {
const { knob } = this.props;
return (
<Input
autoCapitalize="none"
underlineColorAndroid="transparent"
value={(knob.value || '').toString()}
transformer={this.numberTransformer}
keyboardType="numeric"
onChangeText={this.onChangeNormal}
/>
);
}
renderRange() {
const { knob, onChange } = this.props;
return (
<Slider
value={knob.value}
minimumValue={knob.min}
maximumValue={knob.max}
step={knob.step}
onSlidingComplete={val => onChange(parseFloat(val))}
/>
);
}
render() {
const { knob } = this.props;
return (
<View style={{ margin: 10 }}>{knob.range ? this.renderRange() : this.renderNormal()}</View>
);
}
}
NumberType.defaultProps = {
knob: {},
onChange: value => value,
};
NumberType.propTypes = {
knob: PropTypes.shape({
name: PropTypes.string,
value: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
step: PropTypes.number,
min: PropTypes.number,
max: PropTypes.number,
range: PropTypes.bool,
}),
onChange: PropTypes.func,
};
NumberType.serialize = value => String(value);
NumberType.deserialize = value => parseFloat(value);
export default NumberType;
|
src/editors/DateEditor.js
|
diogofcunha/react-data-grid-extensions
|
import React from 'react';
import PropTypes from 'prop-types';
import DayPicker from 'react-day-picker';
import editorWrapper from './editorWrapper';
import "react-day-picker/lib/style.css"
const DATE_TYPES = {
Object: 0,
string: 1
};
const isDate = date => date instanceof Date;
const parseStringToDate = value => new Date(value);
const parseDateToString = value => value.toString();
const parseDate = (value, parseTo) => {
const isValueDate = isDate(value);
if (!isValueDate && typeof value !== 'string') {
throw new Error('The injected value is not a date or a string');
}
if (parseTo === DATE_TYPES.Object) {
return isValueDate ? value : parseStringToDate(value);
}
return isValueDate ? parseDateToString(value) : value;
};
const DateEditor = ({ editorValue, onValueChanged }) => {
const date = parseDate(editorValue, DATE_TYPES.Object);
return (
<div className="editor-main editor-base">
<DayPicker
onDayClick={v => { onValueChanged(parseDate(v, isDate(editorValue) ? DATE_TYPES.Object : DATE_TYPES.string )) }}
selectedDays={date}
initialMonth={date} />
</div>
);
};
DateEditor.propTypes = {
editorValue: PropTypes.object,
onValueChanged: PropTypes.func.isRequired
};
export default editorWrapper(DateEditor);
export { DateEditor, parseDate, DATE_TYPES };
|
src/pages/articlesPage.js
|
MartinP-C/my-site
|
import React from 'react';
import ReactDom from 'react-dom';
import PageHeading from '../components/PageHeading';
import Article from '../components/Article';
import {articles} from '../cms/content.json';
let article;
const articlesBuilt = [];
articles.sort((a, b) => {
return Date.parse(b.date) > Date.parse(a.date); //but have to have the proper date strings in the json. Need to validate..
});
for (article of articles) {
articlesBuilt.push(
<Article
key={article.name}
articleName={article.name}
articleTitle={article.title}
articleSubtitle={article.subtitle}
articleBody={article.body}
articleAuthor={article.author}
articleDate={article.date}
articleType={article.type}
/>
)
};
const articlesPage = () => (
<main className="articles">
<PageHeading>Articles</PageHeading>
<section className="row">
{articlesBuilt}
</section>
</main>
);
export default articlesPage;
|
src/components/Footer/Footer.js
|
Perspicere/PerspicereMagazine
|
/**
* React Static Boilerplate
* https://github.com/kriasoft/react-static-boilerplate
*
* Copyright © 2015-present Kriasoft, LLC. All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE.txt file in the root directory of this source tree.
*/
import React from 'react'
import Link from '../Link'
function Footer() {
return (
<footer className="mdl-mini-footer">
<div className="mdl-mini-footer__left-section">
<div className="mdl-logo">© Company Name</div>
<ul className="mdl-mini-footer__link-list">
<li>
<Link to="/privacy">Privacy & Terms</Link>
</li>
<li>
<Link to="/not-found">Not Found</Link>
</li>
</ul>
</div>
<div className="mdl-mini-footer__right-section">
<ul className="mdl-mini-footer__link-list">
<li className="mdl-mini-footer--social-btn" style={{ backgroundColor: 'transparent' }}>
<a href="https://github.com/kriasoft/react-static-boilerplate" role="button" title="GitHub">
<svg width="36" height="36" viewBox="0 0 24 24">
<path
fill="#fff"
d="M12,2A10,10 0 0,0 2,12C2,16.42 4.87,20.17 8.84,21.5C9.34,21.58
9.5,21.27 9.5,21C9.5,20.77 9.5,20.14 9.5,19.31C6.73,19.91 6.14,17.97 6.14,
17.97C5.68,16.81 5.03,16.5 5.03,16.5C4.12,15.88 5.1,15.9 5.1,15.9C6.1,15.97 6.63,
16.93 6.63,16.93C7.5,18.45 8.97,18 9.54,17.76C9.63,17.11 9.89,16.67 10.17,
16.42C7.95,16.17 5.62,15.31 5.62,11.5C5.62,10.39 6,9.5 6.65,8.79C6.55,8.54 6.2,
7.5 6.75,6.15C6.75,6.15 7.59,5.88 9.5,7.17C10.29,6.95 11.15,6.84 12,6.84C12.85,
6.84 13.71,6.95 14.5,7.17C16.41,5.88 17.25,6.15 17.25,6.15C17.8,7.5 17.45,8.54
17.35,8.79C18,9.5 18.38,10.39 18.38,11.5C18.38,15.32 16.04,16.16 13.81,
16.41C14.17,16.72 14.5,17.33 14.5,18.26C14.5,19.6 14.5,20.68 14.5,21C14.5,21.27
14.66,21.59 15.17,21.5C19.14,20.16 22,16.42 22,12A10,10 0 0,0 12,2Z"
/>
</svg>
</a>
</li>
<li className="mdl-mini-footer--social-btn" style={{ backgroundColor: 'transparent' }}>
<a href="https://twitter.com/ReactStatic" role="button" title="Twitter">
<svg width="36" height="36" viewBox="0 0 24 24">
<path
fill="#fff"
d="M17.71,9.33C18.19,8.93 18.75,8.45 19,7.92C18.59,8.13 18.1,8.26
17.56,8.33C18.06,7.97 18.47,7.5 18.68,6.86C18.16,7.14 17.63,7.38 16.97,
7.5C15.42,5.63 11.71,7.15 12.37,9.95C9.76,9.79 8.17,8.61 6.85,7.16C6.1,8.38
6.75,10.23 7.64,10.74C7.18,10.71 6.83,10.57 6.5,10.41C6.54,11.95 7.39,12.69
8.58,13.09C8.22,13.16 7.82,13.18 7.44,13.12C7.81,14.19 8.58,14.86 9.9,15C9,15.76
7.34,16.29 6,16.08C7.15,16.81 8.46,17.39 10.28,17.31C14.69,17.11 17.64,13.95
17.71,9.33M12,2A10,10 0 0,1 22,12A10,10 0 0,1 12,22A10,10 0 0,1 2,12A10,10 0 0,1
12,2Z"
/>
</svg>
</a>
</li>
</ul>
</div>
</footer>
)
}
export default Footer
|
src/containers/Charts/recharts/charts/simpleBarChart.js
|
EncontrAR/backoffice
|
import React, { Component } from 'react';
import { BarChart, Bar, XAxis, YAxis, CartesianGrid, Tooltip, Legend } from 'recharts';
export default class extends Component {
render() {
const { datas, width, height, colors } = this.props;
return (<div className="isoChartWrapper">
<BarChart width={width} height={height} data={datas} margin={{top: 5, right: 30, left: 20, bottom: 5}}>
<XAxis dataKey="name" stroke={colors[3]} />
<YAxis stroke={colors[3]} />
<CartesianGrid strokeDasharray="3 3"/>
<Tooltip/>
<Legend />
<Bar dataKey="pv" fill={colors[0]} />
<Bar dataKey="uv" fill={colors[1]} />
</BarChart></div>);
}
};
|
src/pages/404.js
|
meherranjan/aerosailor
|
import React from 'react'
import Layout from '../components/layout/default'
import SEO from '../components/includes/seo'
const NotFoundPage = () => (
<Layout>
<SEO title="404: Not found" />
<h1>NOT FOUND</h1>
<p>You just hit a route that doesn't exist... the sadness.</p>
</Layout>
)
export default NotFoundPage
|
app/scripts/Widget/createRoutes.js
|
igr-santos/bonde-client
|
import React from 'react'
import { Route } from 'react-router'
import { SettingsContainer } from './containers'
import {
DonationWidgetSettings,
ExportWidgetData
} from '../pages'
import {
AutoFireFormPage
} from './settings'
import { createRoutes as matchCreateRoutes } from './plugins/Match'
import { createRoutes as pressureCreateRoutes } from './plugins/PressureWidget'
import { createRoutes as formCreateRoutes } from './plugins/Form'
import { createRoutes as donationCreateRoutes } from './plugins/Donation'
import Container from '../Dashboard/Container'
export default () => (
<Route path="/widgets/:widget_id" component={SettingsContainer}>
{pressureCreateRoutes()}
{formCreateRoutes()}
{matchCreateRoutes()}
{donationCreateRoutes()}
<Route path="/autofire" component={AutoFireFormPage} />
<Route path="/export" component={ExportWidgetData} />
<Route path="/donation" component={DonationWidgetSettings} />
</Route>
)
|
packages/icons/src/md/notification/Adb.js
|
suitejs/suitejs
|
import React from 'react';
import IconBase from '@suitejs/icon-base';
function MdAdb(props) {
return (
<IconBase viewBox="0 0 48 48" {...props}>
<path d="M10 31.11c0 7.73 6.27 14 14 14s14-6.27 14-14v-8H10v8zM32.25 7.85C35.72 10.39 38 14.47 38 19.11v2H10v-2c0-4.64 2.28-8.72 5.75-11.26l-4.2-4.2L13.2 2l4.61 4.61c1.88-.93 3.96-1.5 6.19-1.5 2.23 0 4.31.57 6.19 1.5L34.8 2l1.65 1.65-4.2 4.2zM18 17.11a2 2 0 1 0 .001-3.999A2 2 0 0 0 18 17.11zm12 0a2 2 0 1 0 .001-3.999A2 2 0 0 0 30 17.11z" />
</IconBase>
);
}
export default MdAdb;
|
client/Slides/TimeTravel.js
|
Dean177/jumpy-bird-react-demo
|
import React, { Component } from 'react';
export default class TimeTravel extends Component {
render() {
return (
<div className="text-slide">
<a href="https://github.com/gaearon/redux-devtools" target="_blank">Redux dev tools</a> & <a href="https://www.youtube.com/watch?v=xsSnOQynTHs" target="_blank">The talk demonstrating them</a>
<div className="dev-tools-gif" />
</div>
);
}
}
|
src/index.js
|
oh-my-github/registry
|
import React from 'react'
import ReactDOM from 'react-dom'
import { Provider, } from 'react-redux'
import { Router, browserHistory, } from 'react-router'
import routes from './routes'
import configureStore from './store/configureStore'
/** initialize */
import injectTapEventPlugin from 'react-tap-event-plugin'
injectTapEventPlugin()
/** import global css */
import './index.css'
const store = configureStore()
ReactDOM.render(
<Provider store={store}>
<Router history={browserHistory} routes={routes} />
</Provider>, document.getElementById('app')
)
|
examples/nested_reused_components/src/index.js
|
MrEfrem/redux-fly
|
//@flow
import React from 'react'
import ReactDOM from 'react-dom'
import { createStore, compose } from 'redux'
import { Provider } from 'react-redux'
import { enhanceStore } from 'redux-fly'
import Layout from './containers/page/Layout'
const composeEnhancers =
typeof window === 'object' &&
window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ ?
window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({}) : compose
const store = createStore(() => {}, composeEnhancers(enhanceStore))
const target = document.getElementById('root')
const render = (Component) => {
try {
ReactDOM.render(
<Provider store={store}>
<Component/>
</Provider>,
target
)
} catch (err) {
const RedBox = require('redbox-react').default
ReactDOM.render(<RedBox error={err} />, target)
}
}
render(Layout)
if (module.hot) {
(module: any).hot.accept('./containers/page/Layout', () => {
render(require('./containers/page/Layout').default)
})
}
|
docs/app/Examples/behaviors/Visibility/Wireframe.js
|
shengnian/shengnian-ui-react
|
import React from 'react'
import { Divider, Image, Segment } from 'shengnian-ui-react'
export default () => (
<Segment>
<Image src='/assets/images/wireframe/centered-paragraph.png' />
<Divider />
<Image src='/assets/images/wireframe/short-paragraph.png' />
<Divider />
<Image src='/assets/images/wireframe/media-paragraph.png' />
<Divider />
<Image src='/assets/images/wireframe/paragraph.png' />
<Divider />
<Image src='/assets/images/wireframe/centered-paragraph.png' />
<Divider />
<Image src='/assets/images/wireframe/short-paragraph.png' />
<Divider />
<Image src='/assets/images/wireframe/media-paragraph.png' />
<Divider />
<Image src='/assets/images/wireframe/paragraph.png' />
<Divider />
<Image src='/assets/images/wireframe/short-paragraph.png' />
<Divider />
<Image src='/assets/images/wireframe/centered-paragraph.png' />
<Divider />
<Image src='/assets/images/wireframe/short-paragraph.png' />
<Divider />
<Image src='/assets/images/wireframe/media-paragraph.png' />
<Divider />
<Image src='/assets/images/wireframe/paragraph.png' />
<Divider />
<Image src='/assets/images/wireframe/short-paragraph.png' />
</Segment>
)
|
draft-js-emoji-plugin/src/components/Emoji/index.js
|
koaninc/draft-js-plugins
|
import React from 'react';
import unionClassNames from 'union-class-names';
import emojione from 'emojione';
const Emoji = ({ theme = {}, cacheBustParam, imagePath, imageType, className, decoratedText, ...props }) => {
const shortName = emojione.toShort(decoratedText);
// short name to image url code steal from emojione source code
const shortNameForImage = emojione.emojioneList[shortName].unicode[emojione.emojioneList[shortName].unicode.length - 1];
const backgroundImage = `url(${imagePath}${shortNameForImage}.${imageType}${cacheBustParam})`;
const combinedClassName = unionClassNames(theme.emoji, className);
return (
<span
className={combinedClassName}
title={emojione.toShort(decoratedText)}
style={{ backgroundImage }}
>
{props.children}
</span>
);
};
export default Emoji;
|
plugins/Files/js/components/app.js
|
NebulousLabs/New-Sia-UI
|
import PropTypes from 'prop-types'
import React from 'react'
import FileBrowser from '../containers/filebrowser.js'
import AllowanceDialog from '../containers/allowancedialog.js'
const FilesApp = ({ showAllowanceDialog }) => (
<div className='app'>
{showAllowanceDialog ? <AllowanceDialog /> : null}
<FileBrowser />
</div>
)
FilesApp.propTypes = {
showAllowanceDialog: PropTypes.bool.isRequired
}
export default FilesApp
|
test/specs/collections/Breadcrumb/Breadcrumb-test.js
|
jcarbo/stardust
|
import React from 'react'
import Breadcrumb from 'src/collections/Breadcrumb/Breadcrumb'
import * as common from 'test/specs/commonTests'
describe('Breadcrumb', () => {
common.isConformant(Breadcrumb)
common.hasUIClassName(Breadcrumb)
common.rendersChildren(Breadcrumb)
it('renders a <div /> element', () => {
shallow(<Breadcrumb />)
.should.have.tagName('div')
})
const sections = [
{ text: 'Home', link: true },
{ text: 'T-Shirt', href: 'google.com' },
]
it('renders children with `sections` prop', () => {
const wrapper = shallow(<Breadcrumb sections={sections} />)
wrapper.should.have.exactly(1).descendants('BreadcrumbDivider')
wrapper.should.have.exactly(2).descendants('BreadcrumbSection')
})
it('renders defined divider with `divider` prop', () => {
const wrapper = mount(<Breadcrumb sections={sections} divider='>' />)
const divider = wrapper.find('BreadcrumbDivider').first()
divider.should.contain.text('>')
})
})
|
test/fixtures/case6/input.js
|
kadirahq/babel-plugin-react-docgen
|
import React from 'react';
export function hoc (Inner) {
const C1 = (props) => <ActualC1 {...props} />
const C2 = (props) => <ActualC2 {...props} />
return {
C1,
C2
}
}
class ActualC1 extends React.Component {
render() { return <div/> }
}
class ActualC2 extends React.Component {
render() { return <div/> }
}
|
src/shared/components/login/login.js
|
hollomancer/operationcode_frontend
|
import React, { Component } from 'react';
import getVal from 'lodash/get';
import axios from 'axios';
import config from 'config/environment';
import PropTypes from 'prop-types';
import queryString from 'query-string';
import { Link } from 'react-router-dom';
import Form from 'shared/components/form/form';
import FormButton from 'shared/components/form/formButton/formButton';
import FormEmail from 'shared/components/form/formEmail/formEmail';
import FormInput from 'shared/components/form/formInput/formInput';
import Section from 'shared/components/section/section';
import SocialLoginsGrouping from 'shared/components/socialLogin/socialLoginsGrouping';
import * as CookieHelpers from 'shared/utils/cookieHelper';
import styles from './login.css';
import SignUpSection from './signUpSection';
class Login extends Component {
static propTypes = {
history: PropTypes.shape({
action: PropTypes.string,
block: PropTypes.func,
createHref: PropTypes.func,
go: PropTypes.func,
goBack: PropTypes.func,
goForward: PropTypes.func,
length: PropTypes.number,
listen: PropTypes.func,
location: PropTypes.shape({
key: PropTypes.string,
pathname: PropTypes.string,
search: PropTypes.string,
state: PropTypes.shape({
referrer: PropTypes.string
})
}),
push: PropTypes.func,
replace: PropTypes.func
}).isRequired,
isAuth: PropTypes.bool,
sendNotification: PropTypes.func.isRequired,
updateRootAuthState: PropTypes.func
};
static defaultProps = {
updateRootAuthState: () => {},
isAuth: false
};
state = {
email: '',
emailValid: false,
password: '',
passwordValid: false,
authenticated: false,
errorStatus: -1,
errorMessage: '',
error: '',
sso: null,
sig: null,
ssoParamsPresent: false,
location: null
};
componentDidMount = () => {
this.checkForSsoParams();
};
onEmailChange = (value, valid) => {
this.setState({ email: value, emailValid: valid });
};
onPasswordChange = (value, valid) => {
this.setState({ password: value, passwordValid: valid });
};
setErrorMessage = (error) => {
const errorStatus = getVal(error, ['response', 'status'], -1);
const errorMessage = getVal(error, 'message');
this.setState({ errorStatus, errorMessage });
};
setSsoParams = () => {
const parsed = queryString.parse(location.search); //eslint-disable-line
if (this.state.ssoParamsPresent) {
this.setState(
{
sso: parsed.sso,
sig: parsed.sig
},
this.checkSsoLoggedIn
);
}
};
// SSO Flow:
// * Discourse sends us an SSO token and a signature for that token (shared key)
// If those params exist we assume we're doing an SSO login.
//
// Scenario: user not logged in
// * If the user is not logged in they enter their creds and we pass along the
// token and sig to the backend where it's verified
// * If we have a succesful login we redirect back to discourse with our payload and sig
// * These values are provided by the backend
//
// Scenario: user logged in
// * When the login page mounts we check to see if the user is logged in via props
// * If the user is logged in AND this is an SSO request we perform a GET request with
// the token and sig
// * If the users auth token is valid and the token and sig are valid we redirect back
// to discourse with our payload and sig
// * These values are provided by the backend
checkForSsoParams = () => {
const parsed = queryString.parse(location.search); //eslint-disable-line
if (parsed.sso && parsed.sig) {
this.setState({ ssoParamsPresent: true }, this.setSsoParams);
}
};
checkSsoLoggedIn = () => {
if (this.state.ssoParamsPresent && this.props.isAuth) {
this.ssoLoggedInRedirect();
}
};
ssoLoggedInRedirect = () => {
axios
.get(
`${config.backendUrl}/sessions/sso?sso=${encodeURI(this.state.sso)}&sig=${this.state.sig}`,
{
headers: {
Authorization: `Bearer ${CookieHelpers.authToken()}`
}
}
)
.then(({ data }) => {
window.location = data.redirect_to;
})
.catch((error) => {
this.setErrorMessage(error);
});
};
isFormValid = () => this.state.emailValid && this.state.passwordValid;
handleOnClick = (e) => {
e.preventDefault();
if (this.isFormValid()) {
axios
.post(`${config.backendUrl}/sessions`, {
user: {
email: this.state.email,
password: this.state.password
},
sso: this.state.sso,
sig: this.state.sig
})
.then(({ data }) => {
CookieHelpers.setUserAuthCookie(data);
this.setState({ authenticated: true });
this.props.updateRootAuthState();
this.props.sendNotification('success', 'Success', 'You have logged in!');
const redirect = this.props.history.location.state
? this.props.history.location.state.referrer
: data.redirect_to;
if (this.state.ssoParamsPresent) {
window.location = redirect;
} else {
this.props.history.push(redirect);
}
})
.catch((error) => {
if (getVal(error, ['response', 'status'], -1) !== 401) {
this.props.sendNotification('error', 'Error', 'We will investigate this issue!');
}
this.setErrorMessage(error);
});
}
};
render() {
const { errorStatus, errorMessage } = this.state;
let errorFeedback;
if (errorStatus === 401) {
errorFeedback = 'Sorry, you entered an invalid email or password.';
} else if (errorMessage) {
errorFeedback = `Login error: ${errorMessage}.`;
}
return (
<div className={styles.gridRow}>
<Section title="Login" theme="white">
<Form autoComplete>
<FormEmail id="email" displayName="Email" label="Email" onChange={this.onEmailChange} />
<FormInput
id="password"
displayName="Password"
label="Password"
inputType="password"
onChange={this.onPasswordChange}
/>
{errorFeedback && <h2 className={styles.loginError}>{errorFeedback}</h2>}
<FormButton className={styles.loginBtn} text="Login" onClick={e => this.handleOnClick(e)} />
<span className={styles.resetBtn}>
Forgot your password? <Link to="/reset_password">Reset it.</Link>
</span>
</Form>
<SocialLoginsGrouping
history={this.props.history}
sendNotification={this.props.sendNotification}
updateRootAuthState={this.props.updateRootAuthState}
/>
</Section>
<SignUpSection />
</div>
);
}
}
export default Login;
|
example/Header/index.js
|
antonKalinin/react-json-graph
|
import React from 'react';
import styles from './header.css';
export default () => (
<div>
<div className={styles.title}>React Json Graph</div>
<div className={styles.description}>
React component for visualizing graphs and networks
</div>
<ul className={styles.instructions}>
<li>Mouse down on node and drag to move it</li>
<li>Use mouse wheel to zoom in and out</li>
<li>Mouse down and move on empty space to navigate over the graph</li>
</ul>
</div>
);
|
src/app/routes/ui/containers/icons/Glyphicons.js
|
backpackcoder/world-in-flames
|
import React from 'react'
import {Stats, BigBreadcrumbs, WidgetGrid, JarvisWidget} from '../../../../components'
export default class Glyphicons extends React.Component {
state = {
search: ''
};
shouldComponentUpdate(nextProps, nextState) {
if (this.state.search != nextState.search) {
let $container = $(this.refs.demoContainer);
if (nextState.search) {
$("li", $container).hide();
$("li .glyphicon", $container)
.filter(function () {
var r = new RegExp(nextState.search, 'i');
return r.test($(this).attr('class') + $(this).attr('alt'))
})
.closest("li").show();
$(".alert, h2", $container).hide()
} else {
$("li", $container).show();
$(".alert, h2", $container).show()
}
}
return true
}
onSearchChange = (value)=> {
this.setState({
search: value
})
};
render() {
return (
<div id="content">
<div className="row">
<BigBreadcrumbs items={['UI Elements', 'Icons', 'Glyph Icons']} icon="fa fa-fw fa-desktop"
className="col-xs-12 col-sm-7 col-md-7 col-lg-4"/>
<Stats />
</div>
{/* widget grid */}
<WidgetGrid>
<div className="well well-sm">
<div className="input-group">
<input className="form-control input-lg"
value={this.state.search}
onChange={event => this.onSearchChange(event.target.value)}
placeholder="Search for an icon..."/>
<span className="input-group-addon"><i className="fa fa-fw fa-lg fa-search"/></span>
</div>
</div>
{/* row */}
{/* row */}
<div className="row">
{/* NEW WIDGET START */}
<article className="col-sm-12">
{/* Widget ID (each widget will need unique ID)*/}
<JarvisWidget colorbutton={false} editbutton={false} togglebutton={false} deletebutton={false}
color="purple">
<header>
<h2>Glyph Icons </h2>
</header>
{/* widget div*/}
<div>
{/* widget content */}
<div className="widget-body" ref='demoContainer'>
<ul className="bs-glyphicons">
<li>
<span className="glyphicon glyphicon-adjust"/>
<span className="glyphicon-class">.glyphicon .glyphicon-adjust</span>
</li>
<li>
<span className="glyphicon glyphicon-align-center"/>
<span className="glyphicon-class">.glyphicon .glyphicon-align-center</span>
</li>
<li>
<span className="glyphicon glyphicon-align-justify"/>
<span className="glyphicon-class">.glyphicon .glyphicon-align-justify</span>
</li>
<li>
<span className="glyphicon glyphicon-align-left"/>
<span className="glyphicon-class">.glyphicon .glyphicon-align-left</span>
</li>
<li>
<span className="glyphicon glyphicon-align-right"/>
<span className="glyphicon-class">.glyphicon .glyphicon-align-right</span>
</li>
<li>
<span className="glyphicon glyphicon-arrow-down"/>
<span className="glyphicon-class">.glyphicon .glyphicon-arrow-down</span>
</li>
<li>
<span className="glyphicon glyphicon-arrow-left"/>
<span className="glyphicon-class">.glyphicon .glyphicon-arrow-left</span>
</li>
<li>
<span className="glyphicon glyphicon-arrow-right"/>
<span className="glyphicon-class">.glyphicon .glyphicon-arrow-right</span>
</li>
<li>
<span className="glyphicon glyphicon-arrow-up"/>
<span className="glyphicon-class">.glyphicon .glyphicon-arrow-up</span>
</li>
<li>
<span className="glyphicon glyphicon-asterisk"/>
<span className="glyphicon-class">.glyphicon .glyphicon-asterisk</span>
</li>
<li>
<span className="glyphicon glyphicon-backward"/>
<span className="glyphicon-class">.glyphicon .glyphicon-backward</span>
</li>
<li>
<span className="glyphicon glyphicon-ban-circle"/>
<span className="glyphicon-class">.glyphicon .glyphicon-ban-circle</span>
</li>
<li>
<span className="glyphicon glyphicon-barcode"/>
<span className="glyphicon-class">.glyphicon .glyphicon-barcode</span>
</li>
<li>
<span className="glyphicon glyphicon-bell"/>
<span className="glyphicon-class">.glyphicon .glyphicon-bell</span>
</li>
<li>
<span className="glyphicon glyphicon-bold"/>
<span className="glyphicon-class">.glyphicon .glyphicon-bold</span>
</li>
<li>
<span className="glyphicon glyphicon-book"/>
<span className="glyphicon-class">.glyphicon .glyphicon-book</span>
</li>
<li>
<span className="glyphicon glyphicon-bookmark"/>
<span className="glyphicon-class">.glyphicon .glyphicon-bookmark</span>
</li>
<li>
<span className="glyphicon glyphicon-briefcase"/>
<span className="glyphicon-class">.glyphicon .glyphicon-briefcase</span>
</li>
<li>
<span className="glyphicon glyphicon-bullhorn"/>
<span className="glyphicon-class">.glyphicon .glyphicon-bullhorn</span>
</li>
<li>
<span className="glyphicon glyphicon-calendar"/>
<span className="glyphicon-class">.glyphicon .glyphicon-calendar</span>
</li>
<li>
<span className="glyphicon glyphicon-camera"/>
<span className="glyphicon-class">.glyphicon .glyphicon-camera</span>
</li>
<li>
<span className="glyphicon glyphicon-certificate"/>
<span className="glyphicon-class">.glyphicon .glyphicon-certificate</span>
</li>
<li>
<span className="glyphicon glyphicon-check"/>
<span className="glyphicon-class">.glyphicon .glyphicon-check</span>
</li>
<li>
<span className="glyphicon glyphicon-chevron-down"/>
<span className="glyphicon-class">.glyphicon .glyphicon-chevron-down</span>
</li>
<li>
<span className="glyphicon glyphicon-chevron-left"/>
<span className="glyphicon-class">.glyphicon .glyphicon-chevron-left</span>
</li>
<li>
<span className="glyphicon glyphicon-chevron-right"/>
<span className="glyphicon-class">.glyphicon .glyphicon-chevron-right</span>
</li>
<li>
<span className="glyphicon glyphicon-chevron-up"/>
<span className="glyphicon-class">.glyphicon .glyphicon-chevron-up</span>
</li>
<li>
<span className="glyphicon glyphicon-circle-arrow-down"/>
<span className="glyphicon-class">.glyphicon .glyphicon-circle-arrow-down</span>
</li>
<li>
<span className="glyphicon glyphicon-circle-arrow-left"/>
<span className="glyphicon-class">.glyphicon .glyphicon-circle-arrow-left</span>
</li>
<li>
<span className="glyphicon glyphicon-circle-arrow-right"/>
<span className="glyphicon-class">.glyphicon .glyphicon-circle-arrow-right</span>
</li>
<li>
<span className="glyphicon glyphicon-circle-arrow-up"/>
<span className="glyphicon-class">.glyphicon .glyphicon-circle-arrow-up</span>
</li>
<li>
<span className="glyphicon glyphicon-cloud"/>
<span className="glyphicon-class">.glyphicon .glyphicon-cloud</span>
</li>
<li>
<span className="glyphicon glyphicon-cloud-download"/>
<span className="glyphicon-class">.glyphicon .glyphicon-cloud-download</span>
</li>
<li>
<span className="glyphicon glyphicon-cloud-upload"/>
<span className="glyphicon-class">.glyphicon .glyphicon-cloud-upload</span>
</li>
<li>
<span className="glyphicon glyphicon-cog"/>
<span className="glyphicon-class">.glyphicon .glyphicon-cog</span>
</li>
<li>
<span className="glyphicon glyphicon-collapse-down"/>
<span className="glyphicon-class">.glyphicon .glyphicon-collapse-down</span>
</li>
<li>
<span className="glyphicon glyphicon-collapse-up"/>
<span className="glyphicon-class">.glyphicon .glyphicon-collapse-up</span>
</li>
<li>
<span className="glyphicon glyphicon-comment"/>
<span className="glyphicon-class">.glyphicon .glyphicon-comment</span>
</li>
<li>
<span className="glyphicon glyphicon-compressed"/>
<span className="glyphicon-class">.glyphicon .glyphicon-compressed</span>
</li>
<li>
<span className="glyphicon glyphicon-copyright-mark"/>
<span className="glyphicon-class">.glyphicon .glyphicon-copyright-mark</span>
</li>
<li>
<span className="glyphicon glyphicon-credit-card"/>
<span className="glyphicon-class">.glyphicon .glyphicon-credit-card</span>
</li>
<li>
<span className="glyphicon glyphicon-cutlery"/>
<span className="glyphicon-class">.glyphicon .glyphicon-cutlery</span>
</li>
<li>
<span className="glyphicon glyphicon-dashboard"/>
<span className="glyphicon-class">.glyphicon .glyphicon-dashboard</span>
</li>
<li>
<span className="glyphicon glyphicon-download"/>
<span className="glyphicon-class">.glyphicon .glyphicon-download</span>
</li>
<li>
<span className="glyphicon glyphicon-download-alt"/>
<span className="glyphicon-class">.glyphicon .glyphicon-download-alt</span>
</li>
<li>
<span className="glyphicon glyphicon-earphone"/>
<span className="glyphicon-class">.glyphicon .glyphicon-earphone</span>
</li>
<li>
<span className="glyphicon glyphicon-edit"/>
<span className="glyphicon-class">.glyphicon .glyphicon-edit</span>
</li>
<li>
<span className="glyphicon glyphicon-eject"/>
<span className="glyphicon-class">.glyphicon .glyphicon-eject</span>
</li>
<li>
<span className="glyphicon glyphicon-envelope"/>
<span className="glyphicon-class">.glyphicon .glyphicon-envelope</span>
</li>
<li>
<span className="glyphicon glyphicon-euro"/>
<span className="glyphicon-class">.glyphicon .glyphicon-euro</span>
</li>
<li>
<span className="glyphicon glyphicon-exclamation-sign"/>
<span className="glyphicon-class">.glyphicon .glyphicon-exclamation-sign</span>
</li>
<li>
<span className="glyphicon glyphicon-expand"/>
<span className="glyphicon-class">.glyphicon .glyphicon-expand</span>
</li>
<li>
<span className="glyphicon glyphicon-export"/>
<span className="glyphicon-class">.glyphicon .glyphicon-export</span>
</li>
<li>
<span className="glyphicon glyphicon-eye-close"/>
<span className="glyphicon-class">.glyphicon .glyphicon-eye-close</span>
</li>
<li>
<span className="glyphicon glyphicon-eye-open"/>
<span className="glyphicon-class">.glyphicon .glyphicon-eye-open</span>
</li>
<li>
<span className="glyphicon glyphicon-facetime-video"/>
<span className="glyphicon-class">.glyphicon .glyphicon-facetime-video</span>
</li>
<li>
<span className="glyphicon glyphicon-fast-backward"/>
<span className="glyphicon-class">.glyphicon .glyphicon-fast-backward</span>
</li>
<li>
<span className="glyphicon glyphicon-fast-forward"/>
<span className="glyphicon-class">.glyphicon .glyphicon-fast-forward</span>
</li>
<li>
<span className="glyphicon glyphicon-file"/>
<span className="glyphicon-class">.glyphicon .glyphicon-file</span>
</li>
<li>
<span className="glyphicon glyphicon-film"/>
<span className="glyphicon-class">.glyphicon .glyphicon-film</span>
</li>
<li>
<span className="glyphicon glyphicon-filter"/>
<span className="glyphicon-class">.glyphicon .glyphicon-filter</span>
</li>
<li>
<span className="glyphicon glyphicon-fire"/>
<span className="glyphicon-class">.glyphicon .glyphicon-fire</span>
</li>
<li>
<span className="glyphicon glyphicon-flag"/>
<span className="glyphicon-class">.glyphicon .glyphicon-flag</span>
</li>
<li>
<span className="glyphicon glyphicon-flash"/>
<span className="glyphicon-class">.glyphicon .glyphicon-flash</span>
</li>
<li>
<span className="glyphicon glyphicon-floppy-disk"/>
<span className="glyphicon-class">.glyphicon .glyphicon-floppy-disk</span>
</li>
<li>
<span className="glyphicon glyphicon-floppy-open"/>
<span className="glyphicon-class">.glyphicon .glyphicon-floppy-open</span>
</li>
<li>
<span className="glyphicon glyphicon-floppy-remove"/>
<span className="glyphicon-class">.glyphicon .glyphicon-floppy-remove</span>
</li>
<li>
<span className="glyphicon glyphicon-floppy-save"/>
<span className="glyphicon-class">.glyphicon .glyphicon-floppy-save</span>
</li>
<li>
<span className="glyphicon glyphicon-floppy-saved"/>
<span className="glyphicon-class">.glyphicon .glyphicon-floppy-saved</span>
</li>
<li>
<span className="glyphicon glyphicon-folder-close"/>
<span className="glyphicon-class">.glyphicon .glyphicon-folder-close</span>
</li>
<li>
<span className="glyphicon glyphicon-folder-open"/>
<span className="glyphicon-class">.glyphicon .glyphicon-folder-open</span>
</li>
<li>
<span className="glyphicon glyphicon-font"/>
<span className="glyphicon-class">.glyphicon .glyphicon-font</span>
</li>
<li>
<span className="glyphicon glyphicon-forward"/>
<span className="glyphicon-class">.glyphicon .glyphicon-forward</span>
</li>
<li>
<span className="glyphicon glyphicon-fullscreen"/>
<span className="glyphicon-class">.glyphicon .glyphicon-fullscreen</span>
</li>
<li>
<span className="glyphicon glyphicon-gbp"/>
<span className="glyphicon-class">.glyphicon .glyphicon-gbp</span>
</li>
<li>
<span className="glyphicon glyphicon-gift"/>
<span className="glyphicon-class">.glyphicon .glyphicon-gift</span>
</li>
<li>
<span className="glyphicon glyphicon-glass"/>
<span className="glyphicon-class">.glyphicon .glyphicon-glass</span>
</li>
<li>
<span className="glyphicon glyphicon-globe"/>
<span className="glyphicon-class">.glyphicon .glyphicon-globe</span>
</li>
<li>
<span className="glyphicon glyphicon-hand-down"/>
<span className="glyphicon-class">.glyphicon .glyphicon-hand-down</span>
</li>
<li>
<span className="glyphicon glyphicon-hand-left"/>
<span className="glyphicon-class">.glyphicon .glyphicon-hand-left</span>
</li>
<li>
<span className="glyphicon glyphicon-hand-right"/>
<span className="glyphicon-class">.glyphicon .glyphicon-hand-right</span>
</li>
<li>
<span className="glyphicon glyphicon-hand-up"/>
<span className="glyphicon-class">.glyphicon .glyphicon-hand-up</span>
</li>
<li>
<span className="glyphicon glyphicon-hd-video"/>
<span className="glyphicon-class">.glyphicon .glyphicon-hd-video</span>
</li>
<li>
<span className="glyphicon glyphicon-hdd"/>
<span className="glyphicon-class">.glyphicon .glyphicon-hdd</span>
</li>
<li>
<span className="glyphicon glyphicon-header"/>
<span className="glyphicon-class">.glyphicon .glyphicon-header</span>
</li>
<li>
<span className="glyphicon glyphicon-headphones"/>
<span className="glyphicon-class">.glyphicon .glyphicon-headphones</span>
</li>
<li>
<span className="glyphicon glyphicon-heart"/>
<span className="glyphicon-class">.glyphicon .glyphicon-heart</span>
</li>
<li>
<span className="glyphicon glyphicon-heart-empty"/>
<span className="glyphicon-class">.glyphicon .glyphicon-heart-empty</span>
</li>
<li>
<span className="glyphicon glyphicon-home"/>
<span className="glyphicon-class">.glyphicon .glyphicon-home</span>
</li>
<li>
<span className="glyphicon glyphicon-import"/>
<span className="glyphicon-class">.glyphicon .glyphicon-import</span>
</li>
<li>
<span className="glyphicon glyphicon-inbox"/>
<span className="glyphicon-class">.glyphicon .glyphicon-inbox</span>
</li>
<li>
<span className="glyphicon glyphicon-indent-left"/>
<span className="glyphicon-class">.glyphicon .glyphicon-indent-left</span>
</li>
<li>
<span className="glyphicon glyphicon-indent-right"/>
<span className="glyphicon-class">.glyphicon .glyphicon-indent-right</span>
</li>
<li>
<span className="glyphicon glyphicon-info-sign"/>
<span className="glyphicon-class">.glyphicon .glyphicon-info-sign</span>
</li>
<li>
<span className="glyphicon glyphicon-italic"/>
<span className="glyphicon-class">.glyphicon .glyphicon-italic</span>
</li>
<li>
<span className="glyphicon glyphicon-leaf"/>
<span className="glyphicon-class">.glyphicon .glyphicon-leaf</span>
</li>
<li>
<span className="glyphicon glyphicon-link"/>
<span className="glyphicon-class">.glyphicon .glyphicon-link</span>
</li>
<li>
<span className="glyphicon glyphicon-list"/>
<span className="glyphicon-class">.glyphicon .glyphicon-list</span>
</li>
<li>
<span className="glyphicon glyphicon-list-alt"/>
<span className="glyphicon-class">.glyphicon .glyphicon-list-alt</span>
</li>
<li>
<span className="glyphicon glyphicon-lock"/>
<span className="glyphicon-class">.glyphicon .glyphicon-lock</span>
</li>
<li>
<span className="glyphicon glyphicon-log-in"/>
<span className="glyphicon-class">.glyphicon .glyphicon-log-in</span>
</li>
<li>
<span className="glyphicon glyphicon-log-out"/>
<span className="glyphicon-class">.glyphicon .glyphicon-log-out</span>
</li>
<li>
<span className="glyphicon glyphicon-magnet"/>
<span className="glyphicon-class">.glyphicon .glyphicon-magnet</span>
</li>
<li>
<span className="glyphicon glyphicon-map-marker"/>
<span className="glyphicon-class">.glyphicon .glyphicon-map-marker</span>
</li>
<li>
<span className="glyphicon glyphicon-minus"/>
<span className="glyphicon-class">.glyphicon .glyphicon-minus</span>
</li>
<li>
<span className="glyphicon glyphicon-minus-sign"/>
<span className="glyphicon-class">.glyphicon .glyphicon-minus-sign</span>
</li>
<li>
<span className="glyphicon glyphicon-move"/>
<span className="glyphicon-class">.glyphicon .glyphicon-move</span>
</li>
<li>
<span className="glyphicon glyphicon-music"/>
<span className="glyphicon-class">.glyphicon .glyphicon-music</span>
</li>
<li>
<span className="glyphicon glyphicon-new-window"/>
<span className="glyphicon-class">.glyphicon .glyphicon-new-window</span>
</li>
<li>
<span className="glyphicon glyphicon-off"/>
<span className="glyphicon-class">.glyphicon .glyphicon-off</span>
</li>
<li>
<span className="glyphicon glyphicon-ok"/>
<span className="glyphicon-class">.glyphicon .glyphicon-ok</span>
</li>
<li>
<span className="glyphicon glyphicon-ok-circle"/>
<span className="glyphicon-class">.glyphicon .glyphicon-ok-circle</span>
</li>
<li>
<span className="glyphicon glyphicon-ok-sign"/>
<span className="glyphicon-class">.glyphicon .glyphicon-ok-sign</span>
</li>
<li>
<span className="glyphicon glyphicon-open"/>
<span className="glyphicon-class">.glyphicon .glyphicon-open</span>
</li>
<li>
<span className="glyphicon glyphicon-paperclip"/>
<span className="glyphicon-class">.glyphicon .glyphicon-paperclip</span>
</li>
<li>
<span className="glyphicon glyphicon-pause"/>
<span className="glyphicon-class">.glyphicon .glyphicon-pause</span>
</li>
<li>
<span className="glyphicon glyphicon-pencil"/>
<span className="glyphicon-class">.glyphicon .glyphicon-pencil</span>
</li>
<li>
<span className="glyphicon glyphicon-phone"/>
<span className="glyphicon-class">.glyphicon .glyphicon-phone</span>
</li>
<li>
<span className="glyphicon glyphicon-phone-alt"/>
<span className="glyphicon-class">.glyphicon .glyphicon-phone-alt</span>
</li>
<li>
<span className="glyphicon glyphicon-picture"/>
<span className="glyphicon-class">.glyphicon .glyphicon-picture</span>
</li>
<li>
<span className="glyphicon glyphicon-plane"/>
<span className="glyphicon-class">.glyphicon .glyphicon-plane</span>
</li>
<li>
<span className="glyphicon glyphicon-play"/>
<span className="glyphicon-class">.glyphicon .glyphicon-play</span>
</li>
<li>
<span className="glyphicon glyphicon-play-circle"/>
<span className="glyphicon-class">.glyphicon .glyphicon-play-circle</span>
</li>
<li>
<span className="glyphicon glyphicon-plus"/>
<span className="glyphicon-class">.glyphicon .glyphicon-plus</span>
</li>
<li>
<span className="glyphicon glyphicon-plus-sign"/>
<span className="glyphicon-class">.glyphicon .glyphicon-plus-sign</span>
</li>
<li>
<span className="glyphicon glyphicon-print"/>
<span className="glyphicon-class">.glyphicon .glyphicon-print</span>
</li>
<li>
<span className="glyphicon glyphicon-pushpin"/>
<span className="glyphicon-class">.glyphicon .glyphicon-pushpin</span>
</li>
<li>
<span className="glyphicon glyphicon-qrcode"/>
<span className="glyphicon-class">.glyphicon .glyphicon-qrcode</span>
</li>
<li>
<span className="glyphicon glyphicon-question-sign"/>
<span className="glyphicon-class">.glyphicon .glyphicon-question-sign</span>
</li>
<li>
<span className="glyphicon glyphicon-random"/>
<span className="glyphicon-class">.glyphicon .glyphicon-random</span>
</li>
<li>
<span className="glyphicon glyphicon-record"/>
<span className="glyphicon-class">.glyphicon .glyphicon-record</span>
</li>
<li>
<span className="glyphicon glyphicon-refresh"/>
<span className="glyphicon-class">.glyphicon .glyphicon-refresh</span>
</li>
<li>
<span className="glyphicon glyphicon-registration-mark"/>
<span className="glyphicon-class">.glyphicon .glyphicon-registration-mark</span>
</li>
<li>
<span className="glyphicon glyphicon-remove"/>
<span className="glyphicon-class">.glyphicon .glyphicon-remove</span>
</li>
<li>
<span className="glyphicon glyphicon-remove-circle"/>
<span className="glyphicon-class">.glyphicon .glyphicon-remove-circle</span>
</li>
<li>
<span className="glyphicon glyphicon-remove-sign"/>
<span className="glyphicon-class">.glyphicon .glyphicon-remove-sign</span>
</li>
<li>
<span className="glyphicon glyphicon-repeat"/>
<span className="glyphicon-class">.glyphicon .glyphicon-repeat</span>
</li>
<li>
<span className="glyphicon glyphicon-resize-full"/>
<span className="glyphicon-class">.glyphicon .glyphicon-resize-full</span>
</li>
<li>
<span className="glyphicon glyphicon-resize-horizontal"/>
<span className="glyphicon-class">.glyphicon .glyphicon-resize-horizontal</span>
</li>
<li>
<span className="glyphicon glyphicon-resize-small"/>
<span className="glyphicon-class">.glyphicon .glyphicon-resize-small</span>
</li>
<li>
<span className="glyphicon glyphicon-resize-vertical"/>
<span className="glyphicon-class">.glyphicon .glyphicon-resize-vertical</span>
</li>
<li>
<span className="glyphicon glyphicon-retweet"/>
<span className="glyphicon-class">.glyphicon .glyphicon-retweet</span>
</li>
<li>
<span className="glyphicon glyphicon-road"/>
<span className="glyphicon-class">.glyphicon .glyphicon-road</span>
</li>
<li>
<span className="glyphicon glyphicon-save"/>
<span className="glyphicon-class">.glyphicon .glyphicon-save</span>
</li>
<li>
<span className="glyphicon glyphicon-saved"/>
<span className="glyphicon-class">.glyphicon .glyphicon-saved</span>
</li>
<li>
<span className="glyphicon glyphicon-screenshot"/>
<span className="glyphicon-class">.glyphicon .glyphicon-screenshot</span>
</li>
<li>
<span className="glyphicon glyphicon-sd-video"/>
<span className="glyphicon-class">.glyphicon .glyphicon-sd-video</span>
</li>
<li>
<span className="glyphicon glyphicon-search"/>
<span className="glyphicon-class">.glyphicon .glyphicon-search</span>
</li>
<li>
<span className="glyphicon glyphicon-send"/>
<span className="glyphicon-class">.glyphicon .glyphicon-send</span>
</li>
<li>
<span className="glyphicon glyphicon-share"/>
<span className="glyphicon-class">.glyphicon .glyphicon-share</span>
</li>
<li>
<span className="glyphicon glyphicon-share-alt"/>
<span className="glyphicon-class">.glyphicon .glyphicon-share-alt</span>
</li>
<li>
<span className="glyphicon glyphicon-shopping-cart"/>
<span className="glyphicon-class">.glyphicon .glyphicon-shopping-cart</span>
</li>
<li>
<span className="glyphicon glyphicon-signal"/>
<span className="glyphicon-class">.glyphicon .glyphicon-signal</span>
</li>
<li>
<span className="glyphicon glyphicon-sort"/>
<span className="glyphicon-class">.glyphicon .glyphicon-sort</span>
</li>
<li>
<span className="glyphicon glyphicon-sort-by-alphabet"/>
<span className="glyphicon-class">.glyphicon .glyphicon-sort-by-alphabet</span>
</li>
<li>
<span className="glyphicon glyphicon-sort-by-alphabet-alt"/>
<span className="glyphicon-class">.glyphicon .glyphicon-sort-by-alphabet-alt</span>
</li>
<li>
<span className="glyphicon glyphicon-sort-by-attributes"/>
<span className="glyphicon-class">.glyphicon .glyphicon-sort-by-attributes</span>
</li>
<li>
<span className="glyphicon glyphicon-sort-by-attributes-alt"/>
<span className="glyphicon-class">.glyphicon .glyphicon-sort-by-attributes-alt</span>
</li>
<li>
<span className="glyphicon glyphicon-sort-by-order"/>
<span className="glyphicon-class">.glyphicon .glyphicon-sort-by-order</span>
</li>
<li>
<span className="glyphicon glyphicon-sort-by-order-alt"/>
<span className="glyphicon-class">.glyphicon .glyphicon-sort-by-order-alt</span>
</li>
<li>
<span className="glyphicon glyphicon-sound-5-1"/>
<span className="glyphicon-class">.glyphicon .glyphicon-sound-5-1</span>
</li>
<li>
<span className="glyphicon glyphicon-sound-6-1"/>
<span className="glyphicon-class">.glyphicon .glyphicon-sound-6-1</span>
</li>
<li>
<span className="glyphicon glyphicon-sound-7-1"/>
<span className="glyphicon-class">.glyphicon .glyphicon-sound-7-1</span>
</li>
<li>
<span className="glyphicon glyphicon-sound-dolby"/>
<span className="glyphicon-class">.glyphicon .glyphicon-sound-dolby</span>
</li>
<li>
<span className="glyphicon glyphicon-sound-stereo"/>
<span className="glyphicon-class">.glyphicon .glyphicon-sound-stereo</span>
</li>
<li>
<span className="glyphicon glyphicon-star"/>
<span className="glyphicon-class">.glyphicon .glyphicon-star</span>
</li>
<li>
<span className="glyphicon glyphicon-star-empty"/>
<span className="glyphicon-class">.glyphicon .glyphicon-star-empty</span>
</li>
<li>
<span className="glyphicon glyphicon-stats"/>
<span className="glyphicon-class">.glyphicon .glyphicon-stats</span>
</li>
<li>
<span className="glyphicon glyphicon-step-backward"/>
<span className="glyphicon-class">.glyphicon .glyphicon-step-backward</span>
</li>
<li>
<span className="glyphicon glyphicon-step-forward"/>
<span className="glyphicon-class">.glyphicon .glyphicon-step-forward</span>
</li>
<li>
<span className="glyphicon glyphicon-stop"/>
<span className="glyphicon-class">.glyphicon .glyphicon-stop</span>
</li>
<li>
<span className="glyphicon glyphicon-subtitles"/>
<span className="glyphicon-class">.glyphicon .glyphicon-subtitles</span>
</li>
<li>
<span className="glyphicon glyphicon-tag"/>
<span className="glyphicon-class">.glyphicon .glyphicon-tag</span>
</li>
<li>
<span className="glyphicon glyphicon-tags"/>
<span className="glyphicon-class">.glyphicon .glyphicon-tags</span>
</li>
<li>
<span className="glyphicon glyphicon-tasks"/>
<span className="glyphicon-class">.glyphicon .glyphicon-tasks</span>
</li>
<li>
<span className="glyphicon glyphicon-text-height"/>
<span className="glyphicon-class">.glyphicon .glyphicon-text-height</span>
</li>
<li>
<span className="glyphicon glyphicon-text-width"/>
<span className="glyphicon-class">.glyphicon .glyphicon-text-width</span>
</li>
<li>
<span className="glyphicon glyphicon-th"/>
<span className="glyphicon-class">.glyphicon .glyphicon-th</span>
</li>
<li>
<span className="glyphicon glyphicon-th-large"/>
<span className="glyphicon-class">.glyphicon .glyphicon-th-large</span>
</li>
<li>
<span className="glyphicon glyphicon-th-list"/>
<span className="glyphicon-class">.glyphicon .glyphicon-th-list</span>
</li>
<li>
<span className="glyphicon glyphicon-thumbs-down"/>
<span className="glyphicon-class">.glyphicon .glyphicon-thumbs-down</span>
</li>
<li>
<span className="glyphicon glyphicon-thumbs-up"/>
<span className="glyphicon-class">.glyphicon .glyphicon-thumbs-up</span>
</li>
<li>
<span className="glyphicon glyphicon-time"/>
<span className="glyphicon-class">.glyphicon .glyphicon-time</span>
</li>
<li>
<span className="glyphicon glyphicon-tint"/>
<span className="glyphicon-class">.glyphicon .glyphicon-tint</span>
</li>
<li>
<span className="glyphicon glyphicon-tower"/>
<span className="glyphicon-class">.glyphicon .glyphicon-tower</span>
</li>
<li>
<span className="glyphicon glyphicon-transfer"/>
<span className="glyphicon-class">.glyphicon .glyphicon-transfer</span>
</li>
<li>
<span className="glyphicon glyphicon-trash"/>
<span className="glyphicon-class">.glyphicon .glyphicon-trash</span>
</li>
<li>
<span className="glyphicon glyphicon-tree-conifer"/>
<span className="glyphicon-class">.glyphicon .glyphicon-tree-conifer</span>
</li>
<li>
<span className="glyphicon glyphicon-tree-deciduous"/>
<span className="glyphicon-class">.glyphicon .glyphicon-tree-deciduous</span>
</li>
<li>
<span className="glyphicon glyphicon-unchecked"/>
<span className="glyphicon-class">.glyphicon .glyphicon-unchecked</span>
</li>
<li>
<span className="glyphicon glyphicon-upload"/>
<span className="glyphicon-class">.glyphicon .glyphicon-upload</span>
</li>
<li>
<span className="glyphicon glyphicon-usd"/>
<span className="glyphicon-class">.glyphicon .glyphicon-usd</span>
</li>
<li>
<span className="glyphicon glyphicon-user"/>
<span className="glyphicon-class">.glyphicon .glyphicon-user</span>
</li>
<li>
<span className="glyphicon glyphicon-volume-down"/>
<span className="glyphicon-class">.glyphicon .glyphicon-volume-down</span>
</li>
<li>
<span className="glyphicon glyphicon-volume-off"/>
<span className="glyphicon-class">.glyphicon .glyphicon-volume-off</span>
</li>
<li>
<span className="glyphicon glyphicon-volume-up"/>
<span className="glyphicon-class">.glyphicon .glyphicon-volume-up</span>
</li>
<li>
<span className="glyphicon glyphicon-warning-sign"/>
<span className="glyphicon-class">.glyphicon .glyphicon-warning-sign</span>
</li>
<li>
<span className="glyphicon glyphicon-wrench"/>
<span className="glyphicon-class">.glyphicon .glyphicon-wrench</span>
</li>
<li>
<span className="glyphicon glyphicon-zoom-in"/>
<span className="glyphicon-class">.glyphicon .glyphicon-zoom-in</span>
</li>
<li>
<span className="glyphicon glyphicon-zoom-out"/>
<span className="glyphicon-class">.glyphicon .glyphicon-zoom-out</span>
</li>
</ul>
</div>
{/* end widget content */}
</div>
{/* end widget div */}
</JarvisWidget>
{/* end widget */}
</article>
{/* WIDGET END */}
</div>
</WidgetGrid>
</div>
)
}
}
|
src/components/CoverInfo.js
|
amaralflavio/cmovies
|
import React from 'react';
import styled from 'styled-components';
import Text from './Text';
import Title from './Title';
import DetailList from './DetailList';
import Button from './Button';
const CoverInfo = (props) => {
const {poster_path, title, overview, vote_average, adult, release_date, id} = props.data;
return (
<div className={props.className}>
<div className="col-lg-5 col-md-7 col-sm-8 col-xs-11 cover-info-cont">
<div className="cover-poster">
<img src={`http://image.tmdb.org/t/p/w92${poster_path}`} alt=""/>
<Title>{title}</Title>
</div>
<div className="about-cont">
<Text>{overview}</Text>
</div>
<DetailList
Vote={vote_average}
Category={adult ? "Adult" : "Non-Adult"}
Type={release_date}
/>
<Button onClick={ () => window.open(`http://www.themoviedb.org/movie/${id}`)}>More</Button>
</div>
</div>
)
};
const CoverInfoWithStyles = styled(CoverInfo)`
.cover-poster {
height: 100px;
img {
float: left;
box-shadow: 0 3px 6px rgba(0,0,0,0.16), 0 3px 6px rgba(0,0,0,0.23);
}
h2 {
float: left;
margin-bottom: 0px;
margin-top: 79px;
color: #f1f1f1;
text-transform: uppercase;
}
}
img {
height: 100px;
}
.about-cont {
float: left;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
max-height: 125px;
-webkit-line-clamp: 5;
-webkit-box-orient: vertical;
margin-bottom: 22px;
margin-top: 22px;
p {
font-size: 16px;
color: #b2b2b2;
margin-top: 0;
margin-bottom: 0;
line-height: 1.6;
}
}
.cover-info-cont {
z-index: 2;
float: right;
margin-top: 60px;
margin-right: 20px;
padding: 30px;
}
button {
margin-top: 17px;
float: right;
}
@media screen and (max-width: 480px) {
.cover-info-cont {
margin-top: 35px;
}
.cover-poster {
text-align: center;
height: 135px;
img {
float: none;
}
h2 {
float: none;
margin-bottom: 10px;
margin-top: 10px;
}
}
}
`;
export default CoverInfoWithStyles;
|
consoles/my-joy-templates/src/mocks/theme.js
|
yldio/joyent-portal
|
import React from 'react';
import { ThemeProvider } from 'styled-components';
import {
theme,
RootContainer,
PageContainer,
ViewContainer
} from 'joyent-ui-toolkit';
export default ({ children, ss }) => (
<ThemeProvider theme={theme}>
{ss ? (
<RootContainer>
<PageContainer>
<ViewContainer>{children}</ViewContainer>
</PageContainer>
</RootContainer>
) : (
children
)}
</ThemeProvider>
);
|
src/shared/components/navbar/NavTab.js
|
sbekti/path-web-client
|
import React from 'react'
import { Link, IndexLink } from 'react-router'
class NavTab extends React.Component {
constructor(props) {
super(props)
}
render() {
const isActive = this.context.router.isActive(this.props.to, this.props.onlyActiveOnIndex)
const LinkComponent = this.props.onlyActiveOnIndex ? IndexLink : Link
const className = isActive ? 'active' : ''
return (
<li className={className} >
<LinkComponent to={this.props.to} >{this.props.children}</LinkComponent>
</li>
)
}
}
NavTab.contextTypes = {
router: React.PropTypes.object
}
export default NavTab
|
boilerplates/app/src/routes/dashboard/components/cpu.js
|
hexagonframework/antd-admin-cli
|
import React from 'react'
import PropTypes from 'prop-types'
import CountUp from 'react-countup'
import { LineChart, Line, XAxis, YAxis, CartesianGrid, ResponsiveContainer } from 'recharts'
import styles from './cpu.less'
import { color } from '../../../utils'
const countUpProps = {
start: 0,
duration: 2.75,
useEasing: true,
useGrouping: true,
separator: ',',
}
function Cpu ({ usage, space, cpu, data }) {
return (<div className={styles.cpu}>
<div className={styles.number}>
<div className={styles.item}>
<p>usage</p>
<p><CountUp
end={usage}
suffix="GB"
{...countUpProps}
/></p>
</div>
<div className={styles.item}>
<p>space</p>
<p><CountUp
end={space}
suffix="GB"
{...countUpProps}
/></p>
</div>
<div className={styles.item}>
<p>cpu</p>
<p><CountUp
end={cpu}
suffix="%"
{...countUpProps}
/></p>
</div>
</div>
<ResponsiveContainer minHeight={300}>
<LineChart data={data} margin={{ left: -40 }}>
<XAxis dataKey="name" axisLine={{ stroke: color.borderBase, strokeWidth: 1 }} tickLine={false} />
<YAxis axisLine={false} tickLine={false} />
<CartesianGrid vertical={false} stroke={color.borderBase} strokeDasharray="3 3" />
<Line type="monotone" connectNulls dataKey="cpu" stroke={color.blue} fill={color.blue} />
</LineChart>
</ResponsiveContainer>
</div>)
}
Cpu.propTypes = {
data: PropTypes.array,
usage: PropTypes.number,
space: PropTypes.number,
cpu: PropTypes.number,
}
export default Cpu
|
app/javascript/mastodon/components/status.js
|
rutan/mastodon
|
import React from 'react';
import ImmutablePropTypes from 'react-immutable-proptypes';
import PropTypes from 'prop-types';
import Avatar from './avatar';
import AvatarOverlay from './avatar_overlay';
import RelativeTimestamp from './relative_timestamp';
import DisplayName from './display_name';
import StatusContent from './status_content';
import StatusActionBar from './status_action_bar';
import AttachmentList from './attachment_list';
import { injectIntl, FormattedMessage } from 'react-intl';
import ImmutablePureComponent from 'react-immutable-pure-component';
import { MediaGallery, Video } from '../features/ui/util/async-components';
import { HotKeys } from 'react-hotkeys';
import classNames from 'classnames';
// We use the component (and not the container) since we do not want
// to use the progress bar to show download progress
import Bundle from '../features/ui/components/bundle';
export const textForScreenReader = (intl, status, rebloggedByText = false) => {
const displayName = status.getIn(['account', 'display_name']);
const values = [
displayName.length === 0 ? status.getIn(['account', 'acct']).split('@')[0] : displayName,
status.get('spoiler_text') && status.get('hidden') ? status.get('spoiler_text') : status.get('search_index').slice(status.get('spoiler_text').length),
intl.formatDate(status.get('created_at'), { hour: '2-digit', minute: '2-digit', month: 'short', day: 'numeric' }),
status.getIn(['account', 'acct']),
];
if (rebloggedByText) {
values.push(rebloggedByText);
}
return values.join(', ');
};
@injectIntl
export default class Status extends ImmutablePureComponent {
static contextTypes = {
router: PropTypes.object,
};
static propTypes = {
status: ImmutablePropTypes.map,
account: ImmutablePropTypes.map,
onReply: PropTypes.func,
onFavourite: PropTypes.func,
onReblog: PropTypes.func,
onDelete: PropTypes.func,
onDirect: PropTypes.func,
onMention: PropTypes.func,
onPin: PropTypes.func,
onOpenMedia: PropTypes.func,
onOpenVideo: PropTypes.func,
onBlock: PropTypes.func,
onEmbed: PropTypes.func,
onHeightChange: PropTypes.func,
onToggleHidden: PropTypes.func,
muted: PropTypes.bool,
hidden: PropTypes.bool,
onMoveUp: PropTypes.func,
onMoveDown: PropTypes.func,
};
// Avoid checking props that are functions (and whose equality will always
// evaluate to false. See react-immutable-pure-component for usage.
updateOnProps = [
'status',
'account',
'muted',
'hidden',
]
handleClick = () => {
if (!this.context.router) {
return;
}
const { status } = this.props;
this.context.router.history.push(`/statuses/${status.getIn(['reblog', 'id'], status.get('id'))}`);
}
handleAccountClick = (e) => {
if (this.context.router && e.button === 0 && !(e.ctrlKey || e.metaKey)) {
const id = e.currentTarget.getAttribute('data-id');
e.preventDefault();
this.context.router.history.push(`/accounts/${id}`);
}
}
handleExpandedToggle = () => {
this.props.onToggleHidden(this._properStatus());
};
renderLoadingMediaGallery () {
return <div className='media_gallery' style={{ height: '110px' }} />;
}
renderLoadingVideoPlayer () {
return <div className='media-spoiler-video' style={{ height: '110px' }} />;
}
handleOpenVideo = (media, startTime) => {
this.props.onOpenVideo(media, startTime);
}
handleHotkeyReply = e => {
e.preventDefault();
this.props.onReply(this._properStatus(), this.context.router.history);
}
handleHotkeyFavourite = () => {
this.props.onFavourite(this._properStatus());
}
handleHotkeyBoost = e => {
this.props.onReblog(this._properStatus(), e);
}
handleHotkeyMention = e => {
e.preventDefault();
this.props.onMention(this._properStatus().get('account'), this.context.router.history);
}
handleHotkeyOpen = () => {
this.context.router.history.push(`/statuses/${this._properStatus().get('id')}`);
}
handleHotkeyOpenProfile = () => {
this.context.router.history.push(`/accounts/${this._properStatus().getIn(['account', 'id'])}`);
}
handleHotkeyMoveUp = e => {
this.props.onMoveUp(this.props.status.get('id'), e.target.getAttribute('data-featured'));
}
handleHotkeyMoveDown = e => {
this.props.onMoveDown(this.props.status.get('id'), e.target.getAttribute('data-featured'));
}
handleHotkeyToggleHidden = () => {
this.props.onToggleHidden(this._properStatus());
}
_properStatus () {
const { status } = this.props;
if (status.get('reblog', null) !== null && typeof status.get('reblog') === 'object') {
return status.get('reblog');
} else {
return status;
}
}
render () {
let media = null;
let statusAvatar, prepend, rebloggedByText;
const { intl, hidden, featured } = this.props;
let { status, account, ...other } = this.props;
if (status === null) {
return null;
}
if (hidden) {
return (
<div>
{status.getIn(['account', 'display_name']) || status.getIn(['account', 'username'])}
{status.get('content')}
</div>
);
}
if (status.get('filtered') || status.getIn(['reblog', 'filtered'])) {
const minHandlers = this.props.muted ? {} : {
moveUp: this.handleHotkeyMoveUp,
moveDown: this.handleHotkeyMoveDown,
};
return (
<HotKeys handlers={minHandlers}>
<div className='status__wrapper status__wrapper--filtered focusable' tabIndex='0'>
<FormattedMessage id='status.filtered' defaultMessage='Filtered' />
</div>
</HotKeys>
);
}
if (featured) {
prepend = (
<div className='status__prepend'>
<div className='status__prepend-icon-wrapper'><i className='fa fa-fw fa-thumb-tack status__prepend-icon' /></div>
<FormattedMessage id='status.pinned' defaultMessage='Pinned toot' />
</div>
);
} else if (status.get('reblog', null) !== null && typeof status.get('reblog') === 'object') {
const display_name_html = { __html: status.getIn(['account', 'display_name_html']) };
prepend = (
<div className='status__prepend'>
<div className='status__prepend-icon-wrapper'><i className='fa fa-fw fa-retweet status__prepend-icon' /></div>
<FormattedMessage id='status.reblogged_by' defaultMessage='{name} boosted' values={{ name: <a onClick={this.handleAccountClick} data-id={status.getIn(['account', 'id'])} href={status.getIn(['account', 'url'])} className='status__display-name muted'><bdi><strong dangerouslySetInnerHTML={display_name_html} /></bdi></a> }} />
</div>
);
rebloggedByText = intl.formatMessage({ id: 'status.reblogged_by', defaultMessage: '{name} boosted' }, { name: status.getIn(['account', 'acct']) });
account = status.get('account');
status = status.get('reblog');
}
if (status.get('media_attachments').size > 0) {
if (this.props.muted || status.get('media_attachments').some(item => item.get('type') === 'unknown')) {
media = (
<AttachmentList
compact
media={status.get('media_attachments')}
/>
);
} else if (status.getIn(['media_attachments', 0, 'type']) === 'video') {
const video = status.getIn(['media_attachments', 0]);
media = (
<Bundle fetchComponent={Video} loading={this.renderLoadingVideoPlayer} >
{Component => (
<Component
preview={video.get('preview_url')}
src={video.get('url')}
alt={video.get('description')}
width={239}
height={110}
inline
sensitive={status.get('sensitive')}
onOpenVideo={this.handleOpenVideo}
/>
)}
</Bundle>
);
} else {
media = (
<Bundle fetchComponent={MediaGallery} loading={this.renderLoadingMediaGallery}>
{Component => <Component media={status.get('media_attachments')} sensitive={status.get('sensitive')} height={110} onOpenMedia={this.props.onOpenMedia} />}
</Bundle>
);
}
}
if (account === undefined || account === null) {
statusAvatar = <Avatar account={status.get('account')} size={48} />;
}else{
statusAvatar = <AvatarOverlay account={status.get('account')} friend={account} />;
}
const handlers = this.props.muted ? {} : {
reply: this.handleHotkeyReply,
favourite: this.handleHotkeyFavourite,
boost: this.handleHotkeyBoost,
mention: this.handleHotkeyMention,
open: this.handleHotkeyOpen,
openProfile: this.handleHotkeyOpenProfile,
moveUp: this.handleHotkeyMoveUp,
moveDown: this.handleHotkeyMoveDown,
toggleHidden: this.handleHotkeyToggleHidden,
};
return (
<HotKeys handlers={handlers}>
<div className={classNames('status__wrapper', `status__wrapper-${status.get('visibility')}`, { 'status__wrapper-reply': !!status.get('in_reply_to_id'), focusable: !this.props.muted })} tabIndex={this.props.muted ? null : 0} data-featured={featured ? 'true' : null} aria-label={textForScreenReader(intl, status, rebloggedByText, !status.get('hidden'))}>
{prepend}
<div className={classNames('status', `status-${status.get('visibility')}`, { 'status-reply': !!status.get('in_reply_to_id'), muted: this.props.muted })} data-id={status.get('id')}>
<div className='status__info'>
<a href={status.get('url')} className='status__relative-time' target='_blank' rel='noopener'><RelativeTimestamp timestamp={status.get('created_at')} /></a>
<a onClick={this.handleAccountClick} target='_blank' data-id={status.getIn(['account', 'id'])} href={status.getIn(['account', 'url'])} title={status.getIn(['account', 'acct'])} className='status__display-name'>
<div className='status__avatar'>
{statusAvatar}
</div>
<DisplayName account={status.get('account')} />
</a>
</div>
<StatusContent status={status} onClick={this.handleClick} expanded={!status.get('hidden')} onExpandedToggle={this.handleExpandedToggle} />
{media}
<StatusActionBar status={status} account={account} {...other} />
</div>
</div>
</HotKeys>
);
}
}
|
src/client/react/admin/views/FeedView/StoryCreate.js
|
bwyap/ptc-amazing-g-race
|
import React from 'react';
import PropTypes from 'prop-types';
import autobind from 'core-decorators/es/autobind';
import { graphql } from 'react-apollo';
import { Button, Intent, Dialog, Icon } from '@blueprintjs/core';
import MarkdownEditor from '../../../../../../lib/react/components/MarkdownEditor';
import { createStory } from '../../../../graphql/story';
import NotificationToaster from '../../../components/NotificationToaster';
import IconSelect from './IconSelect';
import IntentSelect from './IntentSelect';
@graphql(createStory('ok'), { name: 'MutationCreateStory' })
@autobind
class StoryCreate extends React.Component {
static propTypes = {
refetch: PropTypes.func.isRequired
}
state = {
showCreateStory: false,
createStoryLoading: false,
createStoryError: null,
// Fields
type: 'custom',
intent: 'none',
iconName: '',
content: '',
who: 'me'
}
toggleCreateStory() {
this.setState((prevState) => {
return {
showCreateStory: !prevState.showCreateStory,
type: 'custom',
intent: 'none',
iconName: '',
content: ''
}
});
}
editValue(valueName) {
return (e) => {
this.setState({ [valueName]: e.target.value });
}
}
async submitCreateStory() {
this.setState({ createStoryLoading: true, createStoryError: null });
try {
await this.props.MutationCreateStory({
variables: {
type: this.state.type,
intent: this.state.intent,
who: this.state.who,
iconName: this.state.iconName,
content: this.state.content
}
});
await this.props.refetch();
this.setState({ showCreateStory: false, createStoryLoading: false });
}
catch (err) {
if (this.state.showCreateStory) this.setState({ createStoryLoading: false, createStoryError: err.toString() });
else {
this.setState({ createStoryLoading: false });
NotificationToaster.show({
intent: Intent.DANGER,
message: err.toString()
});
}
}
}
render() {
return (
<div style={{marginBottom:'0.5rem'}}>
<Button text='Create story' iconName='feed' className='pt-fill pt-minimal' intent={Intent.PRIMARY} onClick={this.toggleCreateStory}/>
<Dialog isOpen={this.state.showCreateStory} title='Create story' iconName='feed' onClose={this.toggleCreateStory}>
<div className='pt-dialog-body'>
{this.state.createStoryError ?
<div className='pt-callout pt-intent-danger pt-icon-error' style={{marginBottom:'0.5rem'}}>
{this.state.createStoryError}
</div>
:null}
<label className='pt-label'>
Story type:
<div className='pt-select'>
<select onChange={this.editValue('type')} value={this.state.type} disabled={this.state.createStoryLoading}>
<option value='custom'>Custom</option>
<option value='user'>User story</option>
<option value='challengeUnlock'>Challenge unlock (system)</option>
<option value='challengeRespond'>Challenge response (system)</option>
<option value='challengeCheck'>Challenge checked (system)</option>
</select>
</div>
</label>
<IntentSelect onChange={this.editValue('intent')} value={this.state.intent} disabled={this.state.createStoryLoading}/>
<label className='pt-label'>
Post as:
<div className='pt-select'>
<select onChange={this.editValue('who')} value={this.state.who} disabled={this.state.createStoryLoading}>
<option value='me'>Me</option>
<option value='admins'>Planning Team</option>
<option value='generated'>Auto-generated</option>
</select>
</div>
</label>
<div style={{display:'flex',justifyContent:'space-between',alignItems:'center'}}>
<div style={{width:'40px',height:'40px',padding:'10px',textAlign:'center',border:'solid 1px slategray',borderRadius:'0.3rem'}}>
<Icon iconName={this.state.iconName} iconSize={20}/>
</div>
<div style={{flexGrow:'1',marginLeft:'1rem'}}>
<IconSelect value={this.state.iconName} onChange={this.editValue('iconName')} disabled={this.state.createStoryLoading}/>
</div>
</div>
<div className='instruction-panel markdown-preview create-story'>
<MarkdownEditor title='Post content' content={this.state.content} onChange={this.editValue('content')} disabled={this.state.createStoryLoading}/>
</div>
</div>
<div className='pt-dialog-footer'>
<div className='pt-dialog-footer-actions'>
<Button onClick={this.toggleCreateStory} text='Cancel' className='pt-minimal' disabled={this.state.createStoryLoading}/>
<Button onClick={this.submitCreateStory} text='Create' intent={Intent.PRIMARY} loading={this.state.createStoryLoading}/>
</div>
</div>
</Dialog>
</div>
);
}
}
export default StoryCreate;
|
admin/src/components/PopoutBody.js
|
wustxing/keystone
|
import blacklist from 'blacklist';
import classnames from 'classnames';
import React from 'react';
var PopoutBody = React.createClass({
displayName: 'PopoutBody',
propTypes: {
children: React.PropTypes.node.isRequired,
scrollable: React.PropTypes.bool,
},
render () {
let className = classnames('Popout__body', {
'Popout__scrollable-area': this.props.scrollable
}, this.props.className);
let props = blacklist(this.props, 'className', 'scrollable');
return <div className={className} {...props} />;
}
});
module.exports = PopoutBody;
|
client/src/App.js
|
jlcanela/facebook-friends
|
/* eslint-disable no-unused-vars */
import React from 'react'
import Layout from './Layout'
import { Col, Table, Button } from 'react-bootstrap'
import { connect } from 'react-redux'
import { fetchData, setAdmin } from './actions'
import './App.css'
/* eslint-enable no-unused-vars */
const Header = ({
columns
}) => (
<thead>
<tr>
{ columns.map((name) => <th key={name}>{name}</th>)}
</tr>
</thead>
)
const SetAdmin = ({isAdmin, setAdmin}) => {
if (isAdmin) {
return <span>Admin</span>
}
return <a onClick={setAdmin } >Set Admin</a>
}
const Body = ({ objects, setAdmin }) =>
<tbody>
{
objects.map((object) =>
<tr key={object.name}>
<td>{object.name}</td>
<td><SetAdmin isAdmin={object.isAdmin} setAdmin={() => setAdmin(object.name)}/></td>
</tr>
)}
</tbody>
const App = ({ objects, loadData, setAdmin }) =>
<Layout>
<Col md={6}>
<Button onClick={ () => loadData }>Refresh</Button>
<Table responsive>
<Header columns={['Name', 'Admin']} />
<Body objects={ objects } setAdmin={ setAdmin } />
</Table>
</Col>
</Layout>
const mapStateToProps = (state) => {
const adminName = state.example.adminName.name
const users = state.example.data.map(user => Object.assign({}, user, {isAdmin: user.name === adminName}))
console.log(users)
return {
objects: users
}
}
const mapDispatchToProps = (dispatch) => {
return {
loadData: () => {
dispatch(fetchData('http://localhost:3001/api/users'))
},
setAdmin: (name) => {
dispatch(setAdmin(name))
}
}
}
const AppContainer = connect(
mapStateToProps,
mapDispatchToProps
)(App)
export default AppContainer
|
src/main/resources/app/scripts/app.js
|
pgrimard/spark-react-es6
|
import React from 'react';
import HelloWorld from './components/helloworld';
React.render(<HelloWorld/>, document.body);
|
Js/Core/Lib/Auth/index.js
|
Webiny/Webiny
|
import React from 'react';
import _ from 'lodash';
import Webiny from 'webiny';
class Auth {
constructor() {
this.loginRoute = 'Login';
this.forbiddenRoute = 'Forbidden';
this.routerEvent = null;
}
init() {
Webiny.Router.addRoute(new Webiny.Route(this.loginRoute, '/login', this.renderLogin(), 'Login').setLayout('empty'));
Webiny.Router.addRoute(new Webiny.Route(this.forbiddenRoute, '/forbidden', this.renderForbidden(), 'Forbidden'));
Webiny.Router.onBeforeStart(routerEvent => {
Webiny.Http.addRequestInterceptor(http => {
http.addHeader('X-Webiny-Authorization', Webiny.Cookies.get(this.getCookieName()));
});
// Watch if we got a forbidden request - then log out
Webiny.Http.addResponseInterceptor(this.getResponseInterceptor());
return this.checkUser(routerEvent);
});
Webiny.Router.onRouteWillChange(this.checkUser.bind(this));
}
getResponseInterceptor() {
return response => {
if (response.getStatus() === 403) {
this.onForbidden(response);
}
};
}
/**
* Check if user is authenticated and authorized to visit requested route.
* This method is the main "entry point" into the verification process.
*
* @param routerEvent
* @returns {*}
*/
checkUser(routerEvent) {
this.routerEvent = routerEvent;
if (Webiny.Model.get('User')) {
return this.checkRouteRole(routerEvent);
}
const token = Webiny.Cookies.get(this.getCookieName());
// Check if token exists on client side
if (!token) {
return this.onNoToken(routerEvent);
}
// Try fetching user data
return this.getUser().then(() => this.checkRouteRole(routerEvent));
}
checkRouteRole(routerEvent) {
if (Webiny.Config.Js.CheckUserRoles && _.has(routerEvent.route, 'role')) {
return new Promise((resolve) => {
const user = Webiny.Model.get('User');
if (user && _.isArray(routerEvent.route.role) && this.hasRole(routerEvent.route.role)) {
return resolve(routerEvent);
}
if (user && _.isFunction(routerEvent.route.role)) {
return Promise.resolve(routerEvent.route.role(routerEvent.route)).then(allowed => {
if (!allowed) {
routerEvent.stop();
routerEvent.goToRoute(this.forbiddenRoute);
}
resolve(routerEvent);
});
}
routerEvent.stop();
routerEvent.goToRoute(this.forbiddenRoute);
resolve(routerEvent);
});
}
return Promise.resolve(routerEvent);
}
/**
* This method checks if current target route is already a login route and redirects (or not) properly.
*
* @param routerEvent
* @returns {*}
*/
goToLogin(routerEvent) {
const isLoginRoute = _.get(routerEvent.route, 'name') === this.loginRoute;
if (!isLoginRoute) {
Webiny.LocalStorage.set('loginRedirect', window.location.href);
routerEvent.stop();
routerEvent.goToRoute(this.loginRoute);
}
return routerEvent;
}
onNoToken(routerEvent) {
return this.goToLogin(routerEvent);
}
/**
* Use the given user data to check if the user is authorized to be in this app.
* This logic is completely specific to your application. Implement this as you see fit.
*
* This method is used by `verifyUser` and Login forms to check authorization of logged in user.
*
* @param user
* @returns {boolean}
*/
isAuthorized(user) {
if (!!_.find(user.roles, {slug: 'administrator'})) {
return true;
}
return !!_.find(user.roleGroups, rg => !!_.find(rg.roles, {slug: 'administrator'}));
}
getUserFields() {
return '*,roles.slug,roleGroups[id,name,roles.slug],gravatar';
}
/**
* Fetch user profile and verify the returned data.
*
* @returns Promise
*/
getUser() {
return this.getApiEndpoint().get('/me', {_fields: this.getUserFields()}).then(apiResponse => {
return Promise.resolve(this.verifyUser(apiResponse)).then(() => apiResponse);
});
}
/**
* Get cookie name
* @returns {string}
*/
getCookieName() {
return 'webiny-token';
}
getApiEndpoint() {
if (!this.authApi) {
this.authApi = new Webiny.Api.Endpoint('/entities/webiny/users')
}
return this.authApi;
}
refresh() {
return this.getUser();
}
logout(redirect = true) {
let logout = Promise.resolve().then(() => {
Webiny.Model.set('User', null);
Webiny.Cookies.remove(this.getCookieName());
});
if (redirect) {
logout = logout.then(() => Webiny.Router.goToRoute(this.loginRoute));
}
return logout;
}
/**
* This method determines if the given response from the API is valid user data.
* It also executes `isAuthorized` to see if given user is allowed to be in this app.
*
* This method can be overridden to suit your app's needs.
* It is up to the developer to handle both `verified` and `unverified` cases as he sees fit.
*
* @param apiResponse
* @returns {*}
*/
verifyUser(apiResponse) {
const data = apiResponse.getData();
if (apiResponse.isError() || !this.isAuthorized(data)) {
// We need to stop router event to prevent him from rendering the route he initially intended
this.routerEvent && this.routerEvent.stop();
return this.logout();
}
Webiny.Model.set('User', data);
}
/**
* Check if current user has any of the requested roles (checks both roles and roleGroups)
* @param role
*/
hasRole(role) {
if (_.isString(role)) {
role = [role];
}
const user = Webiny.Model.get('User');
// First check user roles
let hasRole = _.find(user.roles, r => role.indexOf(r.slug) > -1);
if (!hasRole) {
// Check user role groups
_.each(user.roleGroups, group => {
hasRole = _.find(group.roles, r => role.indexOf(r.slug) > -1);
if (hasRole) {
return false;
}
});
}
return hasRole;
}
/**
* Triggered when user is not authorized to perform the HTTP request.
*/
onForbidden(httpResponse) {
// Implement whatever logic you see fit
}
renderLogin() {
return null;
}
renderForbidden() {
return null;
}
}
export default Auth;
|
app/containers/App/index.js
|
dcarneiro/my-react-boilerplate
|
/**
*
* App.react.js
*
* This component is the skeleton around the actual pages, and should only
* contain code that should be seen on all pages. (e.g. navigation bar)
*
* 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 necessity for you then you can refactor it and remove
* the linting exception.
*/
import React, { Component } from 'react';
import { connect } from 'react-redux';
import { browserHistory } from 'react-router';
import AppBar from 'material-ui/AppBar';
import { createStructuredSelector } from 'reselect';
import { selectIsAuthenticated, selectUser } from './selectors';
import Main from './Main';
import Container from './Container';
import NavigationBar from '../NavigationBar';
import NotificationList from '../NotificationList';
import RequestHandler from '../RequestHandler';
class App extends Component { // eslint-disable-line react/prefer-stateless-function
static propTypes = {
children: React.PropTypes.node,
};
handleTouchTap(e) {
e.preventDefault();
browserHistory.push('/');
}
render() {
const { isAuthenticated, user } = this.props;
return (
<div>
<NavigationBar
isAuthenticated={isAuthenticated}
user={user}
/>
<Main>
<AppBar
title="My Awesome App Name"
onTitleTouchTap={this.handleTouchTap}
/>
<Container>
{React.Children.toArray(this.props.children)}
</Container>
<NotificationList />
<RequestHandler />
</Main>
</div>
);
}
}
const mapStateToProps = createStructuredSelector({
isAuthenticated: selectIsAuthenticated(),
user: selectUser(),
});
App.propTypes = {
isAuthenticated: React.PropTypes.bool,
user: React.PropTypes.object,
};
export default connect(mapStateToProps)(App);
|
node_modules/case-sensitive-paths-webpack-plugin/demo/src/init.js
|
marsinearth/decisionmaker
|
import AppRoot from './AppRoot.component.js';
import React from 'react';
import ReactDOM from 'react-dom';
const app = {
initialize() {
ReactDOM.render(<AppRoot/>, document.getElementById('react-app-hook'));
}
};
app.initialize();
|
src/components/Home.spec.js
|
brnewby602/kinects-it
|
import React from 'react';
import { shallow } from 'enzyme';
import { expect } from 'chai';
import { Home } from './Home';
describe('<Home />', () => {
it('contains spec with an expectation', () => {
expect(shallow(<Home />).find('h2').length).to.equal(1);
});
});
|
react/src/components/dashboard/settings/settings.appSettingsPanel.js
|
pbca26/EasyDEX-GUI
|
import React from 'react';
import { connect } from 'react-redux';
import ReactTooltip from 'react-tooltip';
import translate from '../../../translate/translate';
import Config from '../../../config';
import {
getAppConfig,
getAppInfo,
resetAppConfig,
resetSPVCache,
saveAppConfig,
skipFullDashboardUpdate,
triggerToaster,
apiElectrumKvServersList,
} from '../../../actions/actionCreators';
import Store from '../../../store';
import mainWindow, { staticVar } from '../../../util/mainWindow';
import { pubkeyToAddress } from 'agama-wallet-lib/src/keys';
import bitcoinjsNetworks from 'agama-wallet-lib/src/bitcoinjs-networks';
class AppSettingsPanel extends React.Component {
constructor() {
super();
this.state = {
appSettings: {},
appConfigSchema: {},
};
this._saveAppConfig = this._saveAppConfig.bind(this);
this._resetAppConfig = this._resetAppConfig.bind(this);
this._skipFullDashboardUpdate = this._skipFullDashboardUpdate.bind(this);
this._resetSPVCache = this._resetSPVCache.bind(this);
this._apiElectrumKvServersList = this._apiElectrumKvServersList.bind(this);
this.updateInput = this.updateInput.bind(this);
}
validatePubkey(pubkey) {
const address = pubkeyToAddress(pubkey, bitcoinjsNetworks.kmd);
if (address) {
Store.dispatch(
triggerToaster(
`${translate('TOASTR.YOUR_PUBKEY')}${pubkey}${translate('TOASTR.CORRESPONDS_TO_T_ADDR')}${address}`,
translate('INDEX.SETTINGS'),
'success toastr-wide',
false
)
);
} else {
Store.dispatch(
triggerToaster(
translate('TOASTR.INVALID_PUBKEY'),
translate('INDEX.SETTINGS'),
'error'
)
);
}
}
_apiElectrumKvServersList() {
apiElectrumKvServersList()
.then((res) => {
Store.dispatch(
triggerToaster(
translate('SETTINGS.' + (res.msg === 'success' ? 'DOWNLOAD_KV_ELECTRUMS_DONE' : 'DOWNLOAD_KV_ELECTRUMS_ERR')),
translate('INDEX.SETTINGS'),
res.msg === 'success' ? 'success' : 'error',
)
);
});
}
_resetSPVCache() {
Store.dispatch(resetSPVCache());
}
componentWillMount() {
const _appConfigSchema = staticVar.appConfigSchema;
const _appSettings = this.props.Settings.appSettings ? this.props.Settings.appSettings : Object.assign({}, mainWindow.appConfig);
this.setState(Object.assign({}, this.state, {
appConfigSchema: _appConfigSchema,
appSettings: _appSettings,
}));
}
componentDidMount(props) {
Store.dispatch(getAppConfig());
Store.dispatch(getAppInfo());
}
_skipFullDashboardUpdate() {
Store.dispatch(skipFullDashboardUpdate(!this.props.Dashboard.skipFullDashboardUpdate));
}
_resetAppConfig() {
Store.dispatch(resetAppConfig());
}
_saveAppConfig() {
const _appSettings = this.state.appSettings;
const _configSchema = this.state.appConfigSchema;
let _appSettingsPristine = Object.assign({}, this.state.appSettings || this.props.Settings.appSettings);
let isError = false;
let saveAfterPathCheck = false;
for (let key in _appSettings) {
if (typeof _appSettings[key] !== 'object') {
_appSettingsPristine[key] = _configSchema[key] && _configSchema[key].type === 'number' ? Number(_appSettings[key]) : _appSettings[key];
if (_configSchema[key] &&
_configSchema[key].type === 'folder' &&
_appSettings[key] &&
_appSettings[key].length) {
const _testLocation = mainWindow.testLocation;
saveAfterPathCheck = true;
_testLocation(_appSettings[key])
.then((res) => {
if (res === -1) {
isError = true;
Store.dispatch(
triggerToaster(
this.renderLB('TOASTR.KOMODO_DATADIR_INVALID'),
translate('INDEX.SETTINGS'),
'error',
false
)
);
} else if (res === false) {
isError = true;
Store.dispatch(
triggerToaster(
this.renderLB('TOASTR.KOMODO_DATADIR_NOT_DIR'),
translate('INDEX.SETTINGS'),
'error',
false
)
);
} else {
Store.dispatch(saveAppConfig(_appSettingsPristine));
}
});
}
} else {
for (let keyChild in _appSettings[key]) {
if (_configSchema[key][keyChild] &&
_configSchema[key][keyChild].type === 'folder' &&
_appSettings[key][keyChild] &&
_appSettings[key][keyChild].length) {
const _testLocation = mainWindow.testLocation;
saveAfterPathCheck = true;
_testLocation(_appSettings[key][keyChild])
.then((res) => {
if (res === -1) {
isError = true;
Store.dispatch(
triggerToaster(
this.renderLB('TOASTR.KOMODO_DATADIR_INVALID'),
translate('INDEX.SETTINGS'),
'error',
false
)
);
} else if (res === false) {
isError = true;
Store.dispatch(
triggerToaster(
this.renderLB('TOASTR.KOMODO_DATADIR_NOT_DIR'),
translate('INDEX.SETTINGS'),
'error',
false
)
);
} else {
Store.dispatch(saveAppConfig(_appSettingsPristine));
}
});
} else {
_appSettingsPristine[key][keyChild] = _configSchema[key][keyChild].type === 'number' ? Number(_appSettings[key][keyChild]) : _appSettings[key][keyChild];
}
}
}
}
delete _appSettingsPristine.token;
if (!saveAfterPathCheck) {
Store.dispatch(saveAppConfig(_appSettingsPristine));
mainWindow.appConfig = _appSettingsPristine;
}
}
renderLB(_translationID) {
const _translationComponents = translate(_translationID).split('<br>');
let _items = [];
for (let i = 0; i < _translationComponents.length; i++) {
_items.push(
<span key={ `jumblr-label-${Math.random(0, 9) * 10}` }>
{ _translationComponents[i] }
<br />
</span>
);
}
return _items;
}
renderSelectOptions(data, translateSelector, name) {
let _items = [];
for (let i = 0; i < data.length; i++) {
_items.push(
<option
key={ `settings-${name}-opt-${i}` }
value={ data[i] }>
{ translate(`${translateSelector}.${data[i].toUpperCase()}`) }
</option>
);
}
return _items;
}
renderConfigEditForm() {
const _appConfig = this.state.appSettings;
const _configSchema = this.state.appConfigSchema
let items = [];
for (let key in _appConfig) {
if (_configSchema[key] &&
typeof _appConfig[key] === 'object') {
if ((_configSchema[key].display && _configSchema[key].type !== 'select') ||
(_configSchema[key].display && _configSchema[key].type === 'select' && Config.userAgreement)) {
items.push(
<tr key={ `app-settings-${key}` }>
<td className="padding-15">
{ _configSchema[key].displayName ? _configSchema[key].displayName : key }
{ _configSchema[key].info &&
<i
className="icon fa-question-circle settings-help"
data-tip={ _configSchema[key].info }
data-for="appSettings1"
data-html={ true }></i>
}
<ReactTooltip
id="appSettings1"
effect="solid"
className="text-left" />
</td>
<td className="padding-15"></td>
</tr>
);
for (let _key in _appConfig[key]) {
items.push(
<tr key={ `app-settings-${key}-${_key}` }>
<td className="padding-15 padding-left-30">
{ _configSchema[key][_key].displayName ? _configSchema[key][_key].displayName : _key }
{ _configSchema[key][_key].info &&
<i
className="icon fa-question-circle settings-help"
data-tip={ _configSchema[key][_key].info }
data-html={ true }
data-for="appSettings2"></i>
}
<ReactTooltip
id="appSettings2"
effect="solid"
className="text-left" />
</td>
<td className="padding-15">
{ _configSchema[key][_key].type === 'number' &&
<input
type="number"
pattern="[0-9]*"
name={ `${key}__${_key}` }
value={ _appConfig[key][_key] }
onChange={ (event) => this.updateInputSettings(event, key, _key) } />
}
{ (_configSchema[key][_key].type === 'string' ||
_configSchema[key][_key].type === 'folder') &&
<input
type="text"
name={ `${key}__${_key}` }
value={ _appConfig[key][_key] }
className="full-width"
onChange={ (event) => this.updateInputSettings(event, key, _key) } />
}
{ _configSchema[key][_key].type === 'boolean' &&
<span className="pointer toggle">
<label className="switch">
<input
type="checkbox"
name={ `${key}__${_key}` }
value={ _appConfig[key] }
checked={ _appConfig[key][_key] }
readOnly />
<div
className="slider"
onClick={ (event) => this.updateInputSettings(event, key, _key) }></div>
</label>
</span>
}
</td>
</tr>
);
const _appInfo = this.props.Settings.appInfo;
if (key === 'spv' &&
_key === 'cache' &&
_appInfo &&
_appInfo.cacheSize &&
_appInfo.cacheSize !== '2 Bytes') {
items.push(
<tr key={ `app-settings-${key}-${_key}-size` }>
<td
className="padding-15 padding-left-30">
{ translate('SETTINGS.CURRENT_CACHE_SIZE') }: <strong>{ _appInfo.cacheSize }</strong>
</td>
<td className="padding-15">
<button
type="button"
className="btn btn-info waves-effect waves-light"
onClick={ this._resetSPVCache }>
{ translate('SETTINGS.CLEAR_CACHE') }
</button>
</td>
</tr>
);
}
if (key === 'spv' &&
_key === 'syncServerListFromKv') {
items.push(
<tr key={ `app-settings-${key}-${_key}-size` }>
<td
colSpan="2"
className="padding-15">
<button
type="button"
className="btn btn-info waves-effect waves-light margin-left-15"
onClick={ this._apiElectrumKvServersList }>
{ translate('SETTINGS.DOWNLOAD_KV_ELECTRUMS') }
</button>
</td>
</tr>
);
}
}
}
} else {
if ((_configSchema[key] && _configSchema[key].display && _configSchema[key].type !== 'select') ||
(_configSchema[key] && _configSchema[key].display && _configSchema[key].type === 'select' && Config.userAgreement)) {
items.push(
<tr key={ `app-settings-${key}` }>
<td className="padding-15">
{ _configSchema[key].displayName ? _configSchema[key].displayName : key }
{ _configSchema[key].info &&
<i
className="icon fa-question-circle settings-help"
data-tip={ _configSchema[key].info }
data-html={ true }
data-for="appSettings3"></i>
}
<ReactTooltip
id="appSettings3"
effect="solid"
className="text-left" />
</td>
<td className="padding-15">
{ _configSchema[key].type === 'number' &&
<input
type="number"
pattern="[0-9]*"
name={ `${key}` }
value={ _appConfig[key] }
onChange={ (event) => this.updateInputSettings(event, key) } />
}
{ (_configSchema[key].type === 'string' ||
_configSchema[key].type === 'folder') &&
<input
type="text"
name={ `${key}` }
value={ _appConfig[key] }
className="full-width"
onChange={ (event) => this.updateInputSettings(event, key) } />
}
{ (_configSchema[key].type === 'string' ||
_configSchema[key].type === 'folder') &&
key === 'pubkey' &&
_appConfig[key].length > 0 &&
<button
type="button"
className="btn btn-info waves-effect waves-light margin-top-15"
onClick={ () => this.validatePubkey(_appConfig[key]) } >
{ translate('SETTINGS.VALIDATE_PUBKEY') }
</button>
}
{ _configSchema[key].type === 'boolean' &&
<span className="pointer toggle">
<label className="switch">
<input
type="checkbox"
name={ `${key}` }
value={ _appConfig[key] }
checked={ _appConfig[key] }
readOnly />
<div
className="slider"
onClick={ (event) => this.updateInputSettings(event, key) }></div>
</label>
</span>
}
{ _configSchema[key].type === 'select' &&
Config.userAgreement &&
<select
className="form-control select-settings"
name={ `${key}` }
value={ _appConfig[key] }
onChange={ (event) => this.updateInputSettings(event, key) }>
{ this.renderSelectOptions(_configSchema[key].data, _configSchema[key].translateSelector, key) }
</select>
}
</td>
</tr>
);
}
}
}
items.push(
<tr key="kmd-main-sync-only">
<td className="padding-15">
{ translate('SETTINGS.KMD_MAIN_SYNC_ONLY') }
<i
className="icon fa-question-circle settings-help"
data-tip={ translate('SETTINGS.RPC_FETCH_ONLY_DESC') }
data-html={ true }
data-for="appSettings4"></i>
<ReactTooltip
id="appSettings4"
effect="solid"
className="text-left" />
</td>
<td className="padding-15">
<span className="pointer toggle">
<label className="switch">
<input
type="checkbox"
name="kmd-main-sync-only"
value={ this.props.Dashboard.skipFullDashboardUpdate }
checked={ this.props.Dashboard.skipFullDashboardUpdate }
readOnly />
<div
className="slider"
onClick={ this._skipFullDashboardUpdate }></div>
</label>
</span>
</td>
</tr>
);
return items;
}
updateInput(e) {
this.setState({
[e.target.name]: e.target.value,
});
}
updateInputSettings(e, parentKey, childKey) {
const _configSchema = this.state.appConfigSchema;
const _val = e.target.value;
const _name = e.target.name;
let _appSettings = this.state.appSettings;
let _appSettingsPrev = Object.assign({}, _appSettings);
if (!childKey &&
_configSchema[parentKey].type === 'boolean') {
_appSettings[parentKey] = typeof _appSettings[parentKey] !== undefined ? !_appSettings[parentKey] : !this.state.appSettings[parentKey];
} else if (
childKey &&
_configSchema[parentKey][childKey].type === 'boolean'
) {
_appSettings[parentKey][childKey] = typeof _appSettings[parentKey][childKey] !== undefined ? !_appSettings[parentKey][childKey] : !this.state.appSettings[parentKey][childKey];
} else if (
(!childKey && _configSchema[parentKey].type === 'number') ||
(childKey && _configSchema[parentKey][childKey].type === 'number')
) {
if (!childKey) {
_appSettings[_name] = _val === '' ? _appSettingsPrev[_name] : _val.replace(/[^0-9]+/g, '');
} else {
_appSettings[parentKey][childKey] = _val === '' ? _appSettingsPrev[parentKey][childKey] : _val.replace(/[^0-9]+/g, '');
}
} else if (
childKey &&
parentKey &&
(_configSchema[parentKey][childKey].type === 'string' || _configSchema[parentKey][childKey].type === 'folder')
) {
_appSettings[parentKey][childKey] = _val;
} else {
_appSettings[_name] = _val;
}
this.setState({
appSettings: _appSettings,
});
}
render() {
return (
<div>
<div className="row">
<div className="col-sm-12 padding-top-15">
<p>
<strong>{ translate('SETTINGS.CONFIG_RESTART_REQUIRED') }</strong>
</p>
<table>
<tbody>
{ this.renderConfigEditForm() }
</tbody>
</table>
</div>
</div>
<div className="row">
<div className="col-sm-12 col-xs-12 text-align-center padding-top-35 padding-bottom-30">
<button
type="button"
className="btn btn-primary waves-effect waves-light"
onClick={ this._saveAppConfig }>
{ translate('SETTINGS.SAVE_APP_CONFIG') }
</button>
<button
type="button"
className="btn btn-primary waves-effect waves-light margin-left-30"
onClick={ this._resetAppConfig }>
{ translate('SETTINGS.RESET_TO_DEFAULT') }
</button>
</div>
</div>
</div>
);
};
}
const mapStateToProps = (state) => {
return {
Settings: state.Settings,
Dashboard: {
skipFullDashboardUpdate: state.Dashboard.skipFullDashboardUpdate,
},
};
};
export default connect(mapStateToProps)(AppSettingsPanel);
|
react-swipeable/src/index.js
|
kimown/gist
|
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
import SimpleSlider from './SimpleSlider'
import './index.css';
ReactDOM.render(
<SimpleSlider />,
document.getElementById('root')
);
|
src/svg-icons/places/kitchen.js
|
hwo411/material-ui
|
import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let PlacesKitchen = (props) => (
<SvgIcon {...props}>
<path d="M18 2.01L6 2c-1.1 0-2 .89-2 2v16c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V4c0-1.11-.9-1.99-2-1.99zM18 20H6v-9.02h12V20zm0-11H6V4h12v5zM8 5h2v3H8zm0 7h2v5H8z"/>
</SvgIcon>
);
PlacesKitchen = pure(PlacesKitchen);
PlacesKitchen.displayName = 'PlacesKitchen';
PlacesKitchen.muiName = 'SvgIcon';
export default PlacesKitchen;
|
src/components/common/hocs/PeriodicContent.js
|
mitmedialab/MediaCloud-Web-Tools
|
import PropTypes from 'prop-types';
import React from 'react';
import { FormattedMessage, injectIntl } from 'react-intl';
import MenuItem from '@material-ui/core/MenuItem';
import ActionMenu from '../ActionMenu';
import { calculateTimePeriods, PAST_WEEK, PAST_MONTH, PAST_YEAR, PAST_ALL } from '../../../lib/dateUtil';
const localMessages = {
timePeriodMenuTitle: { id: 'periodic.menuTitle', defaultMessage: 'Change Time Period...' },
pastWeek: { id: 'periodic.pastWeek', defaultMessage: 'past week' },
pastMonth: { id: 'periodic.pastMonth', defaultMessage: 'past month' },
pastYear: { id: 'periodic.pastYear', defaultMessage: 'past year' },
all: { id: 'periodic.all', defaultMessage: 'all time' },
};
/**
* Give this:
* 1. `selectedTimePeriod` string
* 2. `handleTimePeriodClick` callback handler
* It gives the child:
* 1. `timePeriodControls` UI elements
*/
const withTimePeriods = (ChildComponent, hideAllTimeOption = false) => {
class PeriodicContent extends React.Component {
saveStateAndTriggerFetch = (timePeriod) => {
const { handleTimePeriodClick } = this.props;
handleTimePeriodClick(calculateTimePeriods(timePeriod), timePeriod);
}
render() {
const { selectedTimePeriod } = this.props;
const timePeriodControls = (
<div className="periodic-controls">
<a
href="#"
role="button"
tabIndex="0"
className={selectedTimePeriod === PAST_WEEK ? 'selected' : ''}
onClick={e => this.saveStateAndTriggerFetch(PAST_WEEK, e)}
>
<FormattedMessage {...localMessages.pastWeek} />
</a>
<a
href="#"
role="button"
tabIndex="0"
className={selectedTimePeriod === PAST_MONTH ? 'selected' : ''}
onClick={e => this.saveStateAndTriggerFetch(PAST_MONTH, e)}
>
<FormattedMessage {...localMessages.pastMonth} />
</a>
<a
href="#"
role="button"
tabIndex="0"
className={selectedTimePeriod === PAST_YEAR ? 'selected' : ''}
onClick={e => this.saveStateAndTriggerFetch(PAST_YEAR, e)}
>
<FormattedMessage {...localMessages.pastYear} />
</a>
{!hideAllTimeOption && (
<a
href="#"
role="button"
tabIndex="0"
className={selectedTimePeriod === PAST_ALL ? 'selected' : ''}
onClick={e => this.saveStateAndTriggerFetch(PAST_ALL, e)}
>
<FormattedMessage {...localMessages.all} />
</a>
)}
</div>
);
const timePeriodMenu = (
<ActionMenu actionTextMsg={localMessages.timePeriodMenuTitle}>
<MenuItem
className="action-icon-menu-item"
disabled={selectedTimePeriod === PAST_WEEK}
onClick={e => this.saveStateAndTriggerFetch(PAST_WEEK, e)}
>
<FormattedMessage {...localMessages.pastWeek} />
</MenuItem>
<MenuItem
className="action-icon-menu-item"
disabled={selectedTimePeriod === PAST_MONTH}
onClick={e => this.saveStateAndTriggerFetch(PAST_MONTH, e)}
>
<FormattedMessage {...localMessages.pastMonth} />
</MenuItem>
<MenuItem
className="action-icon-menu-item"
disabled={selectedTimePeriod === PAST_YEAR} // can only edit in ordered mode
onClick={e => this.saveStateAndTriggerFetch(PAST_YEAR, e)}
>
<FormattedMessage {...localMessages.pastYear} />
</MenuItem>
{!hideAllTimeOption && (
<MenuItem
className="action-icon-menu-item"
disabled={selectedTimePeriod === PAST_ALL} // can only edit in ordered mode
onClick={e => this.saveStateAndTriggerFetch(PAST_ALL, e)}
>
<FormattedMessage {...localMessages.all} />
</MenuItem>
)}
</ActionMenu>
);
return (
<span className="periodic-container">
<ChildComponent
{...this.props}
timePeriodControls={timePeriodControls}
timePeriodMenu={timePeriodMenu}
/>
</span>
);
}
}
PeriodicContent.propTypes = {
intl: PropTypes.object.isRequired,
selectedTimePeriod: PropTypes.string.isRequired,
handleTimePeriodClick: PropTypes.func.isRequired,
};
return injectIntl(
PeriodicContent
);
};
export default withTimePeriods;
|
examples/huge-apps/routes/Course/routes/Assignments/routes/Assignment/components/Assignment.js
|
RobertKielty/react-router
|
import React from 'react';
class Assignment extends React.Component {
render () {
var { courseId, assignmentId } = this.props.params;
var { title, body } = COURSES[courseId].assignments[assignmentId]
return (
<div>
<h4>{title}</h4>
<p>{body}</p>
</div>
);
}
}
export default Assignment;
|
src/js/components/Grid/stories/NColumn.js
|
HewlettPackard/grommet
|
import React from 'react';
import { Grommet, Box, Grid } from 'grommet';
import { grommet } from 'grommet/themes';
export const NColumnGrid = () => (
<Grommet theme={grommet} full>
<Grid
columns={{
count: 6,
size: 'auto',
}}
gap="small"
>
<Box background="brand">Item 1</Box>
<Box background="brand">Item 2</Box>
<Box background="brand">Item 3</Box>
<Box background="brand">Item 4</Box>
<Box background="brand">Item 5</Box>
<Box background="brand">Item 6</Box>
</Grid>
</Grommet>
);
NColumnGrid.storyName = 'N-column layout';
export default {
title: 'Layout/Grid/N-column layout',
};
|
src/routes/dashboard/components/numberCard.js
|
miaoji/guojibackend
|
import React from 'react'
import PropTypes from 'prop-types'
import { Icon, Card } from 'antd'
import CountUp from 'react-countup'
import styles from './numberCard.less'
function NumberCard ({ icon, color, title, number, countUp }) {
return (
<Card className={styles.numberCard} bordered={false} bodyStyle={{ padding: 0 }}>
<Icon className={styles.iconWarp} style={{ color }} type={icon} />
<div className={styles.content}>
<p className={styles.title}>{title || 'No Title'}</p>
<p className={styles.number}>
<CountUp
start={0}
end={number}
duration={2.75}
useEasing
useGrouping
separator=","
{...countUp || {}}
/>
</p>
</div>
</Card>
)
}
NumberCard.propTypes = {
icon: PropTypes.string,
color: PropTypes.string,
title: PropTypes.string,
number: PropTypes.number,
countUp: PropTypes.object,
}
export default NumberCard
|
test/ButtonGroupSpec.js
|
jesenko/react-bootstrap
|
import React from 'react';
import ReactTestUtils from 'react/lib/ReactTestUtils';
import ReactDOM from 'react-dom';
import ButtonGroup from '../src/ButtonGroup';
import Button from '../src/Button';
import {shouldWarn} from './helpers';
describe('ButtonGroup', () => {
it('Should output a button group', () => {
let instance = ReactTestUtils.renderIntoDocument(
<ButtonGroup>
<Button>
Title
</Button>
</ButtonGroup>
);
assert.equal(ReactDOM.findDOMNode(instance).nodeName, 'DIV');
assert.ok(ReactDOM.findDOMNode(instance).className.match(/\bbtn-group\b/));
});
it('Should add size', () => {
let instance = ReactTestUtils.renderIntoDocument(
<ButtonGroup bsSize="large">
<Button>
Title
</Button>
</ButtonGroup>
);
assert.ok(ReactDOM.findDOMNode(instance).className.match(/\bbtn-group-lg\b/));
});
it('Should add vertical variation', () => {
let instance = ReactTestUtils.renderIntoDocument(
<ButtonGroup vertical>
<Button>
Title
</Button>
</ButtonGroup>
);
assert.equal(ReactDOM.findDOMNode(instance).className.trim(), 'btn-group-vertical');
});
it('Should add block variation', () => {
let instance = ReactTestUtils.renderIntoDocument(
<ButtonGroup vertical block>
<Button>
Title
</Button>
</ButtonGroup>
);
assert.ok(ReactDOM.findDOMNode(instance).className.match(/\bbtn-block\b/));
});
it('Should warn about block without vertical', () => {
ReactTestUtils.renderIntoDocument(
<ButtonGroup block>
<Button>
Title
</Button>
</ButtonGroup>
);
shouldWarn('The block property requires the vertical property to be set to have any effect');
});
it('Should add justified variation', () => {
let instance = ReactTestUtils.renderIntoDocument(
<ButtonGroup justified>
<Button>
Title
</Button>
</ButtonGroup>
);
assert.ok(ReactDOM.findDOMNode(instance).className.match(/\bbtn-group-justified\b/));
});
});
|
app/javascript/mastodon/components/relative_timestamp.js
|
koba-lab/mastodon
|
import React from 'react';
import { injectIntl, defineMessages } from 'react-intl';
import PropTypes from 'prop-types';
const messages = defineMessages({
today: { id: 'relative_time.today', defaultMessage: 'today' },
just_now: { id: 'relative_time.just_now', defaultMessage: 'now' },
just_now_full: { id: 'relative_time.full.just_now', defaultMessage: 'just now' },
seconds: { id: 'relative_time.seconds', defaultMessage: '{number}s' },
seconds_full: { id: 'relative_time.full.seconds', defaultMessage: '{number, plural, one {# second} other {# seconds}} ago' },
minutes: { id: 'relative_time.minutes', defaultMessage: '{number}m' },
minutes_full: { id: 'relative_time.full.minutes', defaultMessage: '{number, plural, one {# minute} other {# minutes}} ago' },
hours: { id: 'relative_time.hours', defaultMessage: '{number}h' },
hours_full: { id: 'relative_time.full.hours', defaultMessage: '{number, plural, one {# hour} other {# hours}} ago' },
days: { id: 'relative_time.days', defaultMessage: '{number}d' },
days_full: { id: 'relative_time.full.days', defaultMessage: '{number, plural, one {# day} other {# days}} ago' },
moments_remaining: { id: 'time_remaining.moments', defaultMessage: 'Moments remaining' },
seconds_remaining: { id: 'time_remaining.seconds', defaultMessage: '{number, plural, one {# second} other {# seconds}} left' },
minutes_remaining: { id: 'time_remaining.minutes', defaultMessage: '{number, plural, one {# minute} other {# minutes}} left' },
hours_remaining: { id: 'time_remaining.hours', defaultMessage: '{number, plural, one {# hour} other {# hours}} left' },
days_remaining: { id: 'time_remaining.days', defaultMessage: '{number, plural, one {# day} other {# days}} left' },
});
const dateFormatOptions = {
hour12: false,
year: 'numeric',
month: 'short',
day: '2-digit',
hour: '2-digit',
minute: '2-digit',
};
const shortDateFormatOptions = {
month: 'short',
day: 'numeric',
};
const SECOND = 1000;
const MINUTE = 1000 * 60;
const HOUR = 1000 * 60 * 60;
const DAY = 1000 * 60 * 60 * 24;
const MAX_DELAY = 2147483647;
const selectUnits = delta => {
const absDelta = Math.abs(delta);
if (absDelta < MINUTE) {
return 'second';
} else if (absDelta < HOUR) {
return 'minute';
} else if (absDelta < DAY) {
return 'hour';
}
return 'day';
};
const getUnitDelay = units => {
switch (units) {
case 'second':
return SECOND;
case 'minute':
return MINUTE;
case 'hour':
return HOUR;
case 'day':
return DAY;
default:
return MAX_DELAY;
}
};
export const timeAgoString = (intl, date, now, year, timeGiven, short) => {
const delta = now - date.getTime();
let relativeTime;
if (delta < DAY && !timeGiven) {
relativeTime = intl.formatMessage(messages.today);
} else if (delta < 10 * SECOND) {
relativeTime = intl.formatMessage(short ? messages.just_now : messages.just_now_full);
} else if (delta < 7 * DAY) {
if (delta < MINUTE) {
relativeTime = intl.formatMessage(short ? messages.seconds : messages.seconds_full, { number: Math.floor(delta / SECOND) });
} else if (delta < HOUR) {
relativeTime = intl.formatMessage(short ? messages.minutes : messages.minutes_full, { number: Math.floor(delta / MINUTE) });
} else if (delta < DAY) {
relativeTime = intl.formatMessage(short ? messages.hours : messages.hours_full, { number: Math.floor(delta / HOUR) });
} else {
relativeTime = intl.formatMessage(short ? messages.days : messages.days_full, { number: Math.floor(delta / DAY) });
}
} else if (date.getFullYear() === year) {
relativeTime = intl.formatDate(date, shortDateFormatOptions);
} else {
relativeTime = intl.formatDate(date, { ...shortDateFormatOptions, year: 'numeric' });
}
return relativeTime;
};
const timeRemainingString = (intl, date, now, timeGiven = true) => {
const delta = date.getTime() - now;
let relativeTime;
if (delta < DAY && !timeGiven) {
relativeTime = intl.formatMessage(messages.today);
} else if (delta < 10 * SECOND) {
relativeTime = intl.formatMessage(messages.moments_remaining);
} else if (delta < MINUTE) {
relativeTime = intl.formatMessage(messages.seconds_remaining, { number: Math.floor(delta / SECOND) });
} else if (delta < HOUR) {
relativeTime = intl.formatMessage(messages.minutes_remaining, { number: Math.floor(delta / MINUTE) });
} else if (delta < DAY) {
relativeTime = intl.formatMessage(messages.hours_remaining, { number: Math.floor(delta / HOUR) });
} else {
relativeTime = intl.formatMessage(messages.days_remaining, { number: Math.floor(delta / DAY) });
}
return relativeTime;
};
export default @injectIntl
class RelativeTimestamp extends React.Component {
static propTypes = {
intl: PropTypes.object.isRequired,
timestamp: PropTypes.string.isRequired,
year: PropTypes.number.isRequired,
futureDate: PropTypes.bool,
short: PropTypes.bool,
};
state = {
now: this.props.intl.now(),
};
static defaultProps = {
year: (new Date()).getFullYear(),
short: true,
};
shouldComponentUpdate (nextProps, nextState) {
// As of right now the locale doesn't change without a new page load,
// but we might as well check in case that ever changes.
return this.props.timestamp !== nextProps.timestamp ||
this.props.intl.locale !== nextProps.intl.locale ||
this.state.now !== nextState.now;
}
componentWillReceiveProps (nextProps) {
if (this.props.timestamp !== nextProps.timestamp) {
this.setState({ now: this.props.intl.now() });
}
}
componentDidMount () {
this._scheduleNextUpdate(this.props, this.state);
}
componentWillUpdate (nextProps, nextState) {
this._scheduleNextUpdate(nextProps, nextState);
}
componentWillUnmount () {
clearTimeout(this._timer);
}
_scheduleNextUpdate (props, state) {
clearTimeout(this._timer);
const { timestamp } = props;
const delta = (new Date(timestamp)).getTime() - state.now;
const unitDelay = getUnitDelay(selectUnits(delta));
const unitRemainder = Math.abs(delta % unitDelay);
const updateInterval = 1000 * 10;
const delay = delta < 0 ? Math.max(updateInterval, unitDelay - unitRemainder) : Math.max(updateInterval, unitRemainder);
this._timer = setTimeout(() => {
this.setState({ now: this.props.intl.now() });
}, delay);
}
render () {
const { timestamp, intl, year, futureDate, short } = this.props;
const timeGiven = timestamp.includes('T');
const date = new Date(timestamp);
const relativeTime = futureDate ? timeRemainingString(intl, date, this.state.now, timeGiven) : timeAgoString(intl, date, this.state.now, year, timeGiven, short);
return (
<time dateTime={timestamp} title={intl.formatDate(date, dateFormatOptions)}>
{relativeTime}
</time>
);
}
}
|
src/interface/icons/Megaphone.js
|
yajinni/WoWAnalyzer
|
import React from 'react';
// https://thenounproject.com/term/megaphone/1399378/
// Created by Jony from the Noun Project
const Icon = ({ ...other }) => (
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" className="icon" {...other}>
<path d="M77.2,7c-3.5,0-6.4,2.4-7.1,5.8L28.7,27.7H14.8c-4.4,0-8,3.6-8,8v22.8c0,0.2,0,0.4,0.1,0.6l0,0 l8.4,30.4c0.2,0.8,0.9,1.4,1.8,1.5h16.4c1.1,0,2-0.9,2-2c0-0.2,0-0.3-0.1-0.5l-4.6-17.7L43,65l27.2,8.5c0.6,3.9,4.3,6.6,8.3,6 c3.6-0.6,6.2-3.8,6-7.5V61.2l4.3-0.8c3.8-0.7,6.5-4,6.5-7.9V34.6c0-3.9-2.7-7.2-6.5-7.9L84.4,26V14.3c0.1-4-3.1-7.2-7.1-7.3 C77.3,7,77.2,7,77.2,7z M31.1,31L70,17.1v52.1L31.1,57.1L31.1,31z M10.8,35.7c0-2.2,1.8-4,4-4h12.3v24.8H10.8V35.7z M27.6,67.9 c-0.9,0.4-1.3,1.4-1.1,2.3L30.9,87H18.7l-7.3-26.5h17.3l8.6,2.7L27.6,67.9z M80.4,71.9c0,1.8-1.4,3.2-3.2,3.2 c-1.8,0-3.2-1.4-3.2-3.2V14.3c0-1.8,1.4-3.2,3.2-3.2c1.8,0,3.2,1.4,3.2,3.2V71.9z M87.9,30.7c1.9,0.3,3.3,2,3.3,3.9v18 c0,1.9-1.4,3.6-3.3,3.9l-3.5,0.7V30L87.9,30.7z" />
</svg>
);
export default Icon;
|
src/svg-icons/notification/adb.js
|
IsenrichO/mui-with-arrows
|
import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let NotificationAdb = (props) => (
<SvgIcon {...props}>
<path d="M5 16c0 3.87 3.13 7 7 7s7-3.13 7-7v-4H5v4zM16.12 4.37l2.1-2.1-.82-.83-2.3 2.31C14.16 3.28 13.12 3 12 3s-2.16.28-3.09.75L6.6 1.44l-.82.83 2.1 2.1C6.14 5.64 5 7.68 5 10v1h14v-1c0-2.32-1.14-4.36-2.88-5.63zM9 9c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1zm6 0c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1z"/>
</SvgIcon>
);
NotificationAdb = pure(NotificationAdb);
NotificationAdb.displayName = 'NotificationAdb';
NotificationAdb.muiName = 'SvgIcon';
export default NotificationAdb;
|
src/components/forging/delegateStats.js
|
slaweet/lisk-nano
|
import React from 'react';
import { Card, CardText } from 'react-toolbox/lib/card';
import CircularProgressbar from 'react-circular-progressbar';
import grid from 'flexboxgrid/dist/flexboxgrid.css';
import { translate } from 'react-i18next';
import style from './forging.css';
const identity = x => (x);
const addPercentSign = x => (`${x}%`);
const progressCircleCardList = [
{
key: 'rate',
label: 'Rank',
percentageTransform: percentage => (Math.max(0, 101 - percentage)),
textForPercentage: identity,
}, {
key: 'productivity',
label: 'Productivity',
percentageTransform: identity,
textForPercentage: addPercentSign,
}, {
key: 'approval',
label: 'Approval',
percentageTransform: identity,
textForPercentage: addPercentSign,
},
];
const DelegateStats = props => (
<div className={`${grid.row} ${grid['between-xs']}`}>
{progressCircleCardList.map(cardItem => (
<div className={`${grid['col-xs-12']} ${grid['col-sm-4']}`} key={cardItem.key}>
<Card className={style.grayCard}>
<CardText>
<div className={grid['col-xs-12']}>
<div className={`${grid.row} ${grid['between-xs']}`}>
<div className={style.circularProgressTitle}> {props.t(cardItem.label)} </div>
<CircularProgressbar
percentage={cardItem.percentageTransform(props.delegate[cardItem.key])}
textForPercentage={
cardItem.textForPercentage.bind(null, props.delegate[cardItem.key])}/>
</div>
</div>
</CardText>
</Card>
</div>
))}
</div>
);
export default translate()(DelegateStats);
|
BoBoClient/app/pages/Record.js
|
lan-xue-xing/BoBo
|
/**
* Created by Administrator on 2016/11/6.
*/
import React, { Component } from 'react';
import {
StyleSheet,
Text,
View
} from 'react-native';
import p from '../utils/TransForm';
export default class Record extends Component {
render() {
return (
<View style={styles.container}>
{/** 顶部的TitleBar **/}
<View style={styles.titleBarStyle}>
<Text style={styles.titleBarTextStyle}>录制</Text>
</View>
</View>
);
}
}
const styles = StyleSheet.create({
container: { //容器View
flex: 1,
backgroundColor: '#F2F2F2'
},
titleBarStyle: { //顶部TitleBar的View
justifyContent: 'center',
alignItems: 'center',
height: p(100),
backgroundColor: '#E35852'
},
titleBarTextStyle: { //顶部TitleBar的文字
fontSize: p(32),
color: 'white'
}
});
|
src/main.js
|
viltsu/FDB
|
/**
* App entry point
*/
// Polyfill
import 'babel-polyfill';
// Libraries
import React from 'react';
import ReactDOM from 'react-dom';
import { Router, browserHistory } from 'react-router';
import { Provider } from 'react-redux'
import configureStore from './store'
// Routes
import Routes from './common/components/Routes';
// Base styling
import './common/base.css';
const store = configureStore();
// Render the router
ReactDOM.render((
<Provider store={store}>
<Router history={browserHistory}>
{Routes}
</Router>
</Provider>
), document.getElementById('app'));
|
test/specs/collections/Form/Form-test.js
|
shengnian/shengnian-ui-react
|
import faker from 'faker'
import _ from 'lodash'
import React from 'react'
import Form from 'src/collections/Form/Form'
import FormButton from 'src/collections/Form/FormButton'
import FormCheckbox from 'src/collections/Form/FormCheckbox'
import FormDropdown from 'src/collections/Form/FormDropdown'
import FormField from 'src/collections/Form/FormField'
import FormGroup from 'src/collections/Form/FormGroup'
import FormInput from 'src/collections/Form/FormInput'
import FormRadio from 'src/collections/Form/FormRadio'
import FormSelect from 'src/collections/Form/FormSelect'
import FormTextArea from 'src/collections/Form/FormTextArea'
import { SUI } from 'src/lib'
import * as common from 'test/specs/commonTests'
import { sandbox } from 'test/utils'
describe('Form', () => {
common.isConformant(Form)
common.hasSubComponents(Form, [
FormButton,
FormCheckbox,
FormDropdown,
FormField,
FormTextArea,
FormGroup,
FormInput,
FormRadio,
FormSelect,
])
common.hasUIClassName(Form)
common.rendersChildren(Form, {
rendersContent: false,
})
common.implementsWidthProp(Form, [], {
propKey: 'widths',
})
common.propKeyOnlyToClassName(Form, 'error')
common.propKeyOnlyToClassName(Form, 'inverted')
common.propKeyOnlyToClassName(Form, 'loading')
common.propKeyOnlyToClassName(Form, 'reply')
common.propKeyOnlyToClassName(Form, 'success')
common.propKeyOnlyToClassName(Form, 'unstackable')
common.propKeyOnlyToClassName(Form, 'warning')
common.propValueOnlyToClassName(Form, 'size', _.without(SUI.SIZES, 'medium'))
describe('action', () => {
it('is not set by default', () => {
shallow(<Form />)
.should.not.have.prop('action')
})
it('applied when defined', () => {
const action = faker.internet.url()
shallow(<Form action={action} />)
.should.have.prop('action', action)
})
})
describe('onSubmit', () => {
it('prevents default on the event when there is no action', () => {
const event = { preventDefault: sandbox.spy() }
shallow(<Form />)
.simulate('submit', event)
shallow(<Form action={false} />)
.simulate('submit', event)
shallow(<Form action={null} />)
.simulate('submit', event)
event.preventDefault.should.have.been.calledThrice()
})
it('does not prevent default on the event when there is an action', () => {
const event = { preventDefault: sandbox.spy() }
shallow(<Form action='do not prevent default!' />)
.simulate('submit', event)
shallow(<Form action='' />)
.simulate('submit', event)
event.preventDefault.should.not.have.been.called()
})
it('is called with (e, props) on submit', () => {
const onSubmit = sandbox.spy()
const event = { name: 'foo' }
const props = { 'data-bar': 'baz' }
shallow(<Form {...props} onSubmit={onSubmit} />)
.simulate('submit', event)
onSubmit.should.have.been.calledOnce()
onSubmit.should.have.been.calledWithMatch(event, props)
})
it('passes all args to onSubmit', () => {
const onSubmit = sandbox.spy()
const props = { 'data-baz': 'baz' }
const event = { fake: 'event' }
const args = ['some', 'extra', 'args']
shallow(<Form {...props} onSubmit={onSubmit} />)
.simulate('submit', event, ...args)
onSubmit.should.have.been.calledOnce()
onSubmit.should.have.been.calledWithMatch(event, props, ...args)
})
})
})
|
packages/material-ui-icons/legacy/CellWifiSharp.js
|
lgollut/material-ui
|
import React from 'react';
import createSvgIcon from './utils/createSvgIcon';
export default createSvgIcon(
<React.Fragment><path fillOpacity=".3" d="M6 22h16V5.97L6 22z" /><path d="M18 9.98L6 22h12V9.98zM3.93 5.93l1.29 1.29c3.19-3.19 8.38-3.19 11.57 0l1.29-1.29c-3.91-3.91-10.25-3.91-14.15 0zm5.14 5.14L11 13l1.93-1.93c-1.07-1.06-2.79-1.06-3.86 0zM6.5 8.5l1.29 1.29c1.77-1.77 4.65-1.77 6.43 0L15.5 8.5c-2.48-2.48-6.52-2.48-9 0z" /></React.Fragment>
, 'CellWifiSharp');
|
tests/react_children/text.js
|
AgentME/flow
|
// @flow
import React from 'react';
class Text extends React.Component<{children: string}, void> {}
class TextOptional extends React.Component<{children?: string}, void> {}
class TextLiteral extends React.Component<{children: 'foo' | 'bar'}, void> {}
<Text />; // Error: `children` is required.
<TextOptional />; // OK: `children` is optional.
<TextLiteral />; // Error: `children` is required.
<Text>Hello, world!</Text>; // OK: `children` is a single string.
<Text></Text>; // Error: `children` does not exist.
<Text> </Text>; // OK: `children` is some space.
<Text>{}</Text>; // Error: `children` is required.
<Text>{/* Hello, world! */}</Text>; // Error: `children` is required.
<Text>{undefined}</Text>; // Error: `undefined` is not allowed.
<Text>{null}</Text>; // Error: `null` is not allowed.
<Text>{true}</Text>; // Error: `boolean`s are not allowed.
<Text>{false}</Text>; // Error: `boolean`s are not allowed.
<Text>{0}</Text>; // Error: `number`s are not allowed.
<Text>{42}</Text>; // Error: `number`s are not allowed.
<Text><intrinsic/></Text>; // Error: elements are not allowed.
// OK: Text across multiple lines is fine.
<Text>
Hello, world!
Multiline.
</Text>;
<Text>{'Hello, world!'}</Text>; // OK: Single string in an expression container.
<Text>{'Hello, '}{'world!'}</Text>; // Error: We did not allow an array.
<Text>Hello, {'world!'}</Text>; // Error: We did not allow an array.
<Text>{'Hello, world!'} </Text>; // Error: Spaces cause there to be an array.
<Text> {'Hello, world!'}</Text>; // Error: Spaces cause there to be an array.
// OK: Newlines are trimmed.
<Text>
{'Hello, world!'}
</Text>;
<TextLiteral>foo</TextLiteral>; // OK: Text literal is fine.
<TextLiteral>bar</TextLiteral>; // OK: Text literal is fine.
<TextLiteral>{'foo'}</TextLiteral>; // OK: Text literal is fine.
<TextLiteral>buz</TextLiteral>; // Error: `buz` is not allowed.
<TextLiteral>{'buz'}</TextLiteral>; // Error: `buz` is not allowed.
<TextLiteral>foo </TextLiteral>; // Error: Spaces are not trimmed.
<TextLiteral> foo</TextLiteral>; // Error: Spaces are not trimmed.
<TextLiteral>{'foo'} </TextLiteral>; // Error: Spaces are not trimmed.
<TextLiteral> {'foo'}</TextLiteral>; // Error: Spaces are not trimmed.
// OK: Newlines are trimmed.
<TextLiteral>
foo
</TextLiteral>;
|
server/react/components/AddEdit.js
|
ryordanov/hobby-collection
|
import React from 'react';
import PropTypes from 'prop-types';
import { Button, FormGroup, FormControl, ControlLabel, Alert } from 'react-bootstrap';
import { Link /*, withRouter */ } from 'react-router-dom';
import { getRequestToAPI, postRequestToAPI, buildUrl, concatQueryParams, setNestedValue } from '../utils';
import { Redirect } from 'react-router-dom';
import classnames from 'classnames';
// import { Typeahead } from 'react-bootstrap-typeahead';
export default class Add extends React.Component {
constructor(props) {
super(props);
this.state = {
record: {
// oid: (props.match && props.match.params && props.match.params.itemOid) || '',
oid: (props && props.location && props.location.itemEditOid) || '',
id: '',
path: /*(props.match && props.match.params && props.match.params.path) ||*/[''],
margins: '',
items: ''
},
validRegex: false,
responseStatus: '',
errorCode: 0
};
this.handleSubmit = this.handleSubmit.bind(this);
this.handleChange = this.handleChange.bind(this);
this.handleAdd = this.handleAdd.bind(this);
this.handleRemove = this.handleRemove.bind(this);
this.checkValidity = this.checkValidity.bind(this);
}
checkValidity(items) {
let regex1 = RegExp(/[\wа\-я♦♥♠♣\s]+(?:\([\wа-я\s\-\/\*\:\.\?]+(?:\;[\wа-я\s\*]+){0,1}\){0,1}){0,1}(?:\-\w+){0,1}/);
return regex1.test(items);
}
componentDidMount() {
if (this.state.record.oid) {
let queryParams = concatQueryParams(this.props.location.search);
return getRequestToAPI(buildUrl('/api/getItem', [this.state.record.oid], queryParams), this.props.history)
.then((resData) => {
if (resData && resData.oid) {
this.setState({
record: {
oid: resData.oid,
id: resData.id,
path: resData.path,
margins: resData.margins,
items: resData.items
},
validRegex: this.checkValidity(resData.items)
});
}
});
}
}
// componentDidMount() {
// GET LIST OF CATEGORIES FOR DROPDOWN
// // return getRequestToAPI(`/api/collections/${this.props.match.params.collectionName}/${this.props.match.params.subCollectionName}?option=${this.props.match.params.option}`, this.props.history)
// let queryParams = concatQueryParams(this.props.location.search);
// return getRequestToAPI(buildUrl('/api/collections', this.props.match.params, queryParams), this.props.history)
// .then((resData) => {
// this.setState({
// record: {
// oid: resData[0].oid,
// id: resData[0].id,
// collection: resData[0].make,
// subCollection: resData[0].serie,
// margins: resData[0].margins,
// items: resData[0].items
// }
// });
// });
// }
handleChange(event) {
let path = event.target.id; // dot separated route
let value = event.target.value;
let validInput = false;
if (path === 'record.items') {
validInput = this.checkValidity(value);
}
this.setState((prevState) => {
let tmpState = Object.assign({}, prevState); // do not mutate previous State object
setNestedValue(tmpState, path, value);
tmpState.responseStatus = '';
tmpState.errorCode = 0;
tmpState.validRegex = validInput;
return tmpState;
});
// this.setState({ [event.target.id]: event.target.value });
}
handleSubmit(event) {
event.preventDefault();
// const data = new FormData(event.target);
// const form = event.target;
// const data = {}
// for (let element of form.elements) {
// if (element.name) {
// data[element.name] = element.value;
// }
// }
let { oid, id, path, margins, items } = this.state.record;
let queryParams = concatQueryParams(this.props.location.search);
let url = '';
if (this.state.record && this.state.record.oid) {
url = buildUrl('/api/save', [oid], queryParams);
} else {
url = buildUrl('/api/create', [], queryParams);
}
return postRequestToAPI(url, { oid, id, path, margins, items }, this.props.history)
.then(data => {
if (data) {
if (data.error) {
this.setState({ responseStatus: data.error, errorCode: data.errorCode });
} else {
this.setState({
record: {
oid: data.oid,
id: data.data,
path: data.path,
margins: data.margins,
items: data.items
},
responseStatus: 'Success',
errorCode: 0
});
}
} else {
this.setState({ responseStatus: 'No data returned from server! Create failed!' });
}
});
}
handleAdd() {
this.setState((prevState) => {
return prevState.record.path.push('');
});
}
handleRemove() {
this.setState((prevState) => {
if (prevState.record.path.length > 1) {
prevState.record.path.pop();
}
return prevState;
});
}
render() {
if (this.props.location.pathname.startsWith('/edit') && !this.state.record.oid) {
return <Redirect to='/collections' />;
}
return (
<div>
<form id='updateForm' onSubmit={this.handleSubmit} noValidate>
{this.state.record.path.map((el, i) => {
return <FormGroup key={i} controlId={'record.path[' + i + ']'} bsSize="large">
<ControlLabel>{i === 0 ? 'Category' : 'Subcategory'}:</ControlLabel>
{i === 0 &&
<span>
<Button className = 'actionBtn' bsStyle='info' onClick={this.handleAdd}>+</Button>
<Button className = 'actionBtn' bsStyle='info' onClick={this.handleRemove}>-</Button>
</span>
}
<FormControl
autoFocus
type="text"
value={decodeURIComponent(el || '')}
onChange={this.handleChange}
placeholder={'Example: Category ' + ++i}
/>
</FormGroup>;
})}
<FormGroup controlId="record.margins" bsSize="large">
<ControlLabel>Margins:</ControlLabel>
<FormControl
autoFocus
type="text"
value={this.state.record.margins}
onChange={this.handleChange}
placeholder="Example: 1-50"
/>
</FormGroup>
<FormGroup controlId="record.items" bsSize="large">
<ControlLabel>Items:</ControlLabel>
<FormControl
autoFocus
// type="text"
componentClass="textarea"
rows={8}
maxLength={4000}
value={this.state.record.items}
onChange={this.handleChange}
placeholder="Example: 1,2,5-10,11(2;broken),21"
/>
</FormGroup>
<Button
block
bsSize="large"
type="submit"
disabled={!!this.state.responseStatus}
>
Save
</Button>
<Button
block
bsSize="large"
type="button"
onClick={this.props.history.goBack}
>
Cancel
</Button>
</form>
{this.state.responseStatus &&
<Alert bsStyle="info">
<strong>Create status: </strong>
{this.state.responseStatus && this.state.errorCode === 2 &&
<span>
{this.state.responseStatus}
<span> Please use </span><Link to={buildUrl('/edit', [this.state.record.oid])} className="alert-link">Edit</Link><span> link. </span>
</span>
}
{this.state.responseStatus && this.state.errorCode !== 2 &&
this.state.responseStatus
}
</Alert>}
{/* {'Valid: ' + this.state.validRegex} */}
</div>
);
}
}
Add.propTypes = {
match: PropTypes.object,
history: PropTypes.object,
location: PropTypes.object
};
Add.defaultProps = {
match: {
params: {
path: [],
option: ''
}
}
};
|
src/PaginationButton.js
|
lo1tuma/react-bootstrap
|
import React from 'react';
import classNames from 'classnames';
import BootstrapMixin from './BootstrapMixin';
import createSelectedEvent from './utils/createSelectedEvent';
const PaginationButton = React.createClass({
mixins: [BootstrapMixin],
propTypes: {
className: React.PropTypes.string,
eventKey: React.PropTypes.oneOfType([
React.PropTypes.string,
React.PropTypes.number
]),
onSelect: React.PropTypes.func,
disabled: React.PropTypes.bool,
active: React.PropTypes.bool
},
getDefaultProps() {
return {
active: false,
disabled: false
};
},
handleClick(event) {
// This would go away once SafeAnchor is available
event.preventDefault();
if (this.props.onSelect) {
let selectedEvent = createSelectedEvent(this.props.eventKey);
this.props.onSelect(event, selectedEvent);
}
},
render() {
let classes = this.getBsClassSet();
classes.active = this.props.active;
classes.disabled = this.props.disabled;
return (
<li className={classNames(this.props.className, classes)}>
<a href='#' onClick={this.handleClick}>{this.props.children}</a>
</li>
);
}
});
export default PaginationButton;
|
node_modules/react-router/es/RouterContext.js
|
saltypaul/SnipTodo
|
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
import invariant from 'invariant';
import React from 'react';
import getRouteParams from './getRouteParams';
import { ContextProvider } from './ContextUtils';
import { isReactChildren } from './RouteUtils';
var _React$PropTypes = React.PropTypes,
array = _React$PropTypes.array,
func = _React$PropTypes.func,
object = _React$PropTypes.object;
/**
* A <RouterContext> renders the component tree for a given router state
* and sets the history object and the current location in context.
*/
var RouterContext = React.createClass({
displayName: 'RouterContext',
mixins: [ContextProvider('router')],
propTypes: {
router: object.isRequired,
location: object.isRequired,
routes: array.isRequired,
params: object.isRequired,
components: array.isRequired,
createElement: func.isRequired
},
getDefaultProps: function getDefaultProps() {
return {
createElement: React.createElement
};
},
childContextTypes: {
router: object.isRequired
},
getChildContext: function getChildContext() {
return {
router: this.props.router
};
},
createElement: function createElement(component, props) {
return component == null ? null : this.props.createElement(component, props);
},
render: function render() {
var _this = this;
var _props = this.props,
location = _props.location,
routes = _props.routes,
params = _props.params,
components = _props.components,
router = _props.router;
var element = null;
if (components) {
element = components.reduceRight(function (element, components, index) {
if (components == null) return element; // Don't create new children; use the grandchildren.
var route = routes[index];
var routeParams = getRouteParams(route, params);
var props = {
location: location,
params: params,
route: route,
router: router,
routeParams: routeParams,
routes: routes
};
if (isReactChildren(element)) {
props.children = element;
} else if (element) {
for (var prop in element) {
if (Object.prototype.hasOwnProperty.call(element, prop)) props[prop] = element[prop];
}
}
if ((typeof components === 'undefined' ? 'undefined' : _typeof(components)) === 'object') {
var elements = {};
for (var key in components) {
if (Object.prototype.hasOwnProperty.call(components, key)) {
// Pass through the key as a prop to createElement to allow
// custom createElement functions to know which named component
// they're rendering, for e.g. matching up to fetched data.
elements[key] = _this.createElement(components[key], _extends({
key: key }, props));
}
}
return elements;
}
return _this.createElement(components, props);
}, element);
}
!(element === null || element === false || React.isValidElement(element)) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'The root route must render a single element') : invariant(false) : void 0;
return element;
}
});
export default RouterContext;
|
client/tests/components/auth/FormField.spec.js
|
johadi10/PostIt
|
import 'babel-polyfill';
import React from 'react';
import expect from 'expect';
import { mount } from 'enzyme';
import FormField from '../../../src/components/auth/FormField';
const wrapper = mount(<FormField/>);
describe('<FormField/>', () => {
it('should check the div with form-group class exists', () => {
expect(wrapper.find('.form-group').length).toBe(1);
});
it('should check that input text field exists', () => {
expect(wrapper.find('input').length).toBe(1);
});
});
|
examples/page-transitions/pages/_document.js
|
giacomorebonato/next.js
|
import React from 'react'
import Document, { Head, Main, NextScript } from 'next/document'
// ---------------------------------------------
export default class CustomDocument extends Document {
render () {
return (<html lang='en-US'>
<Head>
<meta name='viewport' content='width=device-width, initial-scale=1' />
<meta name='robots' content='noindex' />
<link rel='stylesheet' href='/static/style.css' />
</Head>
<body>
<Main />
<NextScript />
</body>
</html>)
}
}
|
src/examples/cats/app.js
|
c00kiemon5ter/react-image-lightbox
|
import React from 'react';
import ReactDOM from 'react-dom';
import Lightbox from '../../react-image-lightbox';
import styles from './stylesheets/app.scss';
import image1 from './images/1.jpg';
import image2 from './images/2.jpg';
import image3 from './images/3.jpg';
import image4 from './images/4.jpg';
import image1Thumb from './images/1_thumb.jpg';
import image2Thumb from './images/2_thumb.jpg';
import image3Thumb from './images/3_thumb.jpg';
import image4Thumb from './images/4_thumb.jpg';
const images = [ image1, image2, image3, image4 ];
const thumbs = [ image1Thumb, image2Thumb, image3Thumb, image4Thumb ];
const titles = [
'',
(<span>
by
<a className={styles.creditLink} href="http://flickr.com/photos/titrans/">
quatre mains
</a>
(<a
className={styles.creditLink}
href="http://creativecommons.org/licenses/by/2.0/"
title="Attribution License"
>
Some rights reserved
</a>)
</span>),
(<span>
by
<a className={styles.creditLink} href="http://flickr.com/photos/lachlanrogers/">
latch.r
</a>
(<a
className={styles.creditLink}
href="http://creativecommons.org/licenses/by-sa/2.0/"
title="Attribution-ShareAlike License"
>
Some rights reserved
</a>)
</span>),
(<span>
by
<a className={styles.creditLink} href="http://flickr.com/photos/fazen/">
fazen
</a>
(<a
className={styles.creditLink}
href="http://creativecommons.org/licenses/by/2.0/"
title="Attribution License"
>
Some rights reserved
</a>)
</span>),
];
const captions = [
'',
'Sad kitten wants a hug',
(<p>
.. not in the
<em>
mood
</em>
for games right now
</p>),
(<p>
Meow!? What do you mean by «Earth is
<strong>
round
</strong>
»? Are you
<em>
absolutely
</em>
<strong>
sure
</strong>
you know what you're talking about?
</p>),
];
const App = React.createClass({
getInitialState() {
return {
index: 0,
isOpen: false
};
},
openLightbox() {
this.setState({ isOpen: true });
},
closeLightbox() {
this.setState({ isOpen: false });
},
moveNext() {
this.setState({ index: (this.state.index + 1) % images.length });
},
movePrev() {
this.setState({ index: (this.state.index + images.length - 1) % images.length });
},
render() {
let lightbox;
if (this.state.isOpen) {
lightbox = (
<Lightbox
mainSrc={images[this.state.index]}
nextSrc={images[(this.state.index + 1) % images.length]}
prevSrc={images[(this.state.index + images.length - 1) % images.length]}
mainSrcThumbnail={thumbs[this.state.index]}
nextSrcThumbnail={thumbs[(this.state.index + 1) % images.length]}
prevSrcThumbnail={thumbs[(this.state.index + images.length - 1) % images.length]}
onCloseRequest={this.closeLightbox}
onMovePrevRequest={this.movePrev}
onMoveNextRequest={this.moveNext}
imageTitle={titles[this.state.index]}
imageCaption={captions[this.state.index]}
/>
);
}
return (
<div>
<section className={styles['page-header']}>
<h1 className={styles['project-name']}>
React Image Lightbox
</h1>
<h2 className={styles['project-tagline']}>
Flexible lightbox component for displaying images with React
</h2>
</section>
<section className={styles['main-content']}>
<h2>Demo</h2>
<div>
<button
type="button"
id="open-lightbox"
className={styles.demoButton}
onClick={this.openLightbox}
>
Open Lightbox
</button>
{lightbox}
</div>
<h2>Features</h2>
<ul>
<li>Keyboard shortcuts (with rate limiting)</li>
<li>Image Zoom</li>
<li>Flexible rendering using src values assigned on the fly</li>
<li>Image preloading for smoother viewing</li>
<li>Few dependencies</li>
<li>No external CSS</li>
</ul>
<a href="https://github.com/fritz-c/react-image-lightbox">Examples and Documentation on Github</a>
<footer className={styles['site-footer']}>
<span className={styles['site-footer-owner']}>
<a href="https://github.com/fritz-c/react-image-lightbox">React Image Lightbox</a> is maintained by <a href="https://github.com/fritz-c">fritz-c</a>.
</span>
<span className={styles['site-footer-credits']}>
This page was generated by <a href="https://pages.github.com">GitHub Pages</a> using the <a href="https://github.com/jasonlong/cayman-theme">Cayman theme</a> by <a href="https://twitter.com/jasonlong">Jason Long</a>.
</span>
</footer>
</section>
<a href="https://github.com/fritz-c/react-image-lightbox">
<img
style={{ position: 'absolute', top: 0, right: 0, border: 0 }}
src="https://camo.githubusercontent.com/38ef81f8aca64bb9a64448d0d70f1308ef5341ab/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f6461726b626c75655f3132313632312e706e67"
alt="Fork me on GitHub"
data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png"
/>
</a>
</div>
);
}
});
ReactDOM.render(<App />, document.getElementById('app'));
|
frontend/src/components/Main/Main.js
|
VitaC123/youTubeMixTape
|
import React, { Component } from 'react';
import { Route, Switch } from 'react-router-dom';
import FadeIn from '../helper/FadeIn';
import Navigation from './Navigation';
import Home from '../Home/Home';
import NoResults from '../Home/NoResults';
import Artists from '../Artists/Artists';
import Player from '../Player/Player';
import './Main.css';
class Main extends Component {
componentWillMount() {
// Ensures app knows when stylesheet has loaded
document.getElementById('styleSheetBootstrap').addEventListener('load', this.props.refreshStyleSheetStatus);
}
render() {
return (
<div className='mainBody'>
<header className='mainHeader'>
{this.props.styleSheetLoaded && (
<FadeIn>
<Navigation {...this.props} />
</FadeIn>)}
</header>
<main className='mainContent'>
<Switch>
<Route path='/' exact={true} render={() => <Home {...this.props} />} />
<Route path='/search:*' render={() => (
<div>
<NoResults {...this.props} />
<Artists {...this.props} />
</div>)} />
<Route path='/settings' render={() => <p className='text-center'>A 'Settings' page placeholder</p>} />
</Switch>
</main>
<Player {...this.props} />
<footer className='mainFooter' style={{ paddingTop: '2em', background: '#494949' }}>
<p className='text-center'><a href='https://github.com/VitaC123/youtube-mixtape'>View source</a></p>
</footer>
</div>
);
}
}
export default Main;
|
src/lib/withProps.js
|
yeojz/react-form-addons
|
// @flow
import React from 'react';
import createSyntheticFormEvent from '../utils/createSyntheticFormEvent';
import getDataFromKey from '../utils/getDataFromKey';
import updateObjectData from '../utils/updateObjectData';
type Props = {
formData: Object,
formMeta: Object,
onChange: Function
};
const handleToggle = (props: Props) => (evt: PseudoEvent): void => {
let event: SyntheticFormEvent = createSyntheticFormEvent(evt, props.formData, props.formMeta);
event.formData = updateObjectData(props.formData, evt, true);
props.onChange(event);
};
const handleChange = (props: Props) => (evt: PseudoEvent): void => {
let event: SyntheticFormEvent = createSyntheticFormEvent(evt, props.formData, props.formMeta);
event.formData = updateObjectData(props.formData, evt);
props.onChange(event);
};
const withProps = () => (Component: ReactClass<any>): ReactClass<any> => {
class FormWithProps extends React.Component {
props: Props
static defaultProps = {
formData: {},
formMeta: {}
}
render() {
return (
<Component
{...this.props}
formData={this.props.formData}
formMeta={this.props.formMeta}
getFormData={getDataFromKey(this.props.formData)}
getFormMeta={getDataFromKey(this.props.formMeta)}
onChange={handleChange(this.props)}
onToggle={handleToggle(this.props)}
/>
);
}
}
return FormWithProps;
};
export default withProps;
|
src/components/ExampleComponent.js
|
ambershen/ambershen.github.io
|
import React from 'react';
import Interactive from 'react-interactive';
import { Switch, Route, Link } from 'react-router-dom';
import ExampleTwoDeepComponent from './ExampleTwoDeepComponent';
import PageNotFound from './PageNotFound';
import s from '../styles/exampleComponent.style';
const ExamplePageText = () => (
<p style={s.p}>
This is an example page. Refresh the page or copy/paste the url to
test out the redirect functionality (this same page should load
after the redirect).
</p>
);
export default function ExampleComponent() {
return (
<Switch>
<Route
exact path="/example/two-deep"
render={({ location }) => (
<div>
<ExamplePageText />
<ExampleTwoDeepComponent location={location} />
</div>
)}
/>
<Route
exact path="/example"
render={() => (
<div>
<ExamplePageText />
<div style={s.pageLinkContainer}>
<Interactive
as={Link}
{...s.link}
to="/example/two-deep?field1=foo&field2=bar#boom!"
>Example two deep with query and hash</Interactive>
</div>
</div>
)}
/>
<Route component={PageNotFound} />
</Switch>
);
}
|
client/scripts/components/user/entities/new-entity-button/index.js
|
kuali/research-coi
|
/*
The Conflict of Interest (COI) module of Kuali Research
Copyright © 2005-2016 Kuali, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
*/
import styles from './style';
import React from 'react';
import {PlusIcon} from '../../../dynamic-icons/plus-icon';
export function NewEntityButton(props) {
return (
<span id='newEntityButton' onClick={props.onClick} className={`${styles.container} ${props.className}`}>
<div className={styles.text}>
<div className={styles.newText}>New</div>
<div className={styles.financialText}>Financial</div>
<div className={styles.entityText}>Entity</div>
</div>
<span className={styles.plus}>
<PlusIcon
className={`${styles.override} ${styles.img}`}
color={window.colorBlindModeOn ? 'black' : '#00bcd4'}
/>
</span>
</span>
);
}
|
test/mocks/FooComponent.js
|
fustic/hubrick-frontend-challenge
|
import React from 'react';
class FooComponent extends React.Component {
render() {
return <div />;
}
}
export default FooComponent;
|
src/components/FilterBySearch.js
|
bjacobel/cabinet
|
import React, { Component } from 'react';
import { filterBox, filter, filterHint, filterLabel } from '../stylesheets/filterBySearch.css';
export default class FilterbySearch extends Component {
render() {
return (
<div className={ filterBox }>
<label htmlFor="filter-input" className={ filterLabel }>Filter by:</label>
<br />
<input
id="filter-input"
className={ filter }
placeholder="Senator or state"
aria-describedby="filter-input-hint"
onChange={ event => this.props.updateFilter(event.target.value) }
/>
<span className={ filterHint } id="filter-input-hint">Enter a senator's name or state to search by.</span>
</div>
);
}
}
|
docs/app/Examples/collections/Breadcrumb/Content/index.js
|
clemensw/stardust
|
import React from 'react'
import ComponentExample from 'docs/app/Components/ComponentDoc/ComponentExample'
import ExampleSection from 'docs/app/Components/ComponentDoc/ExampleSection'
const BreadcrumbContentExamples = () => (
<div>
<ExampleSection title='Content'>
<ComponentExample
title='Divider'
description={[
'A breadcrumb can contain a divider to show the relationship between sections,',
'this can be formatted as an icon or text.',
].join(' ')}
examplePath='collections/Breadcrumb/Content/BreadcrumbExampleDivider'
/>
<ComponentExample examplePath='collections/Breadcrumb/Content/BreadcrumbExampleDividerProps' />
<ComponentExample examplePath='collections/Breadcrumb/Content/BreadcrumbExampleIconDivider' />
<ComponentExample examplePath='collections/Breadcrumb/Content/BreadcrumbExampleIconDividerProps' />
<ComponentExample
title='Section'
description='A breadcrumb can contain sections that can either be formatted as a link or text.'
examplePath='collections/Breadcrumb/Content/BreadcrumbExampleSection'
/>
<ComponentExample examplePath='collections/Breadcrumb/Content/BreadcrumbExampleSectionProps' />
<ComponentExample
title='Link'
description='A section may be linkable or contain a link.'
examplePath='collections/Breadcrumb/Content/BreadcrumbExampleLink'
/>
</ExampleSection>
</div>
)
export default BreadcrumbContentExamples
|
src/components/GridVideoTile.js
|
lishiyo/listentothis
|
/**
Presentational component to render a single embed, given id, URL, title, and author (author).
props: {
id: '3ybh3d',
title: 'Hello',
author: 'AdeleFan',
iframeData: <iframe src='http://..' width='350' height='250' ../>
iframeReadyCb: function
}
**/
import React from 'react'
import GridTile from 'material-ui/lib/grid-list/grid-tile'
export class GridVideoTile extends React.Component {
static propTypes = {
title: React.PropTypes.string.isRequired,
author: React.PropTypes.string.isRequired,
iframeReadyCb: React.PropTypes.func.isRequired,
iframeData: React.PropTypes.object.isRequired,
id: React.PropTypes.string.isRequired
}
componentDidMount () {
// after iframe node has been rendered
this.props.iframeReadyCb(this.refs.iframeRef)
}
render () {
const {
title,
author,
id,
iframeData
} = this.props
const {
src,
width,
height
} = iframeData
return (
<GridTile
title={title}
subtitle={<span>by <b>{author}</b></span>}>
{ iframeData &&
<iframe
id={id}
ref='iframeRef'
src={src}
width={width}
height={height}
className='embedly-embed'
scrolling='no'
frameBorder='0'
allowFullScreen
></iframe>
}
</GridTile>
)
}
}
export default GridVideoTile
|
src/containers/App.js
|
FRCTools/Attendance-Client
|
import React, { Component } from 'react';
import { Provider } from 'react-redux';
import firebase from 'firebase';
import injectTapEventPlugin from 'react-tap-event-plugin';
import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider';
import getMuiTheme from 'material-ui/styles/getMuiTheme';
import { purple400 } from 'material-ui/styles/colors';
import MainPage from './MainPage';
import store from '../store';
const muiTheme = getMuiTheme({
palette: {
primary1Color: purple400,
},
});
injectTapEventPlugin();
firebase.initializeApp({
databaseURL: 'https://attendance-2fd4c.firebaseio.com/'
});
class App extends Component {
render() {
return (
<MuiThemeProvider muiTheme={muiTheme}>
<Provider store={store}>
<MainPage />
</Provider>
</MuiThemeProvider>
);
}
}
export default App;
|
packages/cf-component-tabs/src/TabsPanel.js
|
mdno/mdno.github.io
|
import React from 'react';
import PropTypes from 'prop-types';
import { createComponent } from 'cf-style-container';
const styles = ({ theme }) => ({
backgroundColor: theme.backgroundColor
});
class TabsPanel extends React.Component {
render() {
const selected = this.context.active === this.props.id;
return (
<div
className={this.props.className}
role="tabpanel"
aria-labelledby={this.props.id}
aria-hidden={!selected}
>
{this.props.children}
</div>
);
}
}
TabsPanel.propTypes = {
id: PropTypes.string.isRequired,
children: PropTypes.node
};
TabsPanel.contextTypes = {
active: PropTypes.string.isRequired
};
export default createComponent(styles, TabsPanel);
|
test/integration/image-component/base-path/pages/missing-src.js
|
JeromeFitz/next.js
|
import React from 'react'
import Image from 'next/image'
const Page = () => {
return (
<div>
<Image width={200}></Image>
</div>
)
}
export default Page
|
examples/basic/simple_usage/modal.js
|
rackt/react-modal
|
import React from 'react';
import Modal from 'react-modal';
export default props => {
const {
title, isOpen, askToClose,
onAfterOpen, onRequestClose, onChangeInput
} = props;
return (
<Modal
id="test"
contentLabel="modalA"
closeTimeoutMS={150}
isOpen={isOpen}
onAfterOpen={onAfterOpen}
onRequestClose={onRequestClose}>
<h1>{title}</h1>
<button onClick={askToClose}>close</button>
<div>I am a modal. Use the first input to change the modal's title.</div>
<form>
<input onChange={onChangeInput} />
<input />
<br />
<button>Button A</button>
<button>Button B</button>
<button>Button C</button>
<button>Button D</button>
</form>
</Modal>
);
}
|
examples/react-redux-example/app/async/index.js
|
demones/react-guide
|
import React from 'react';
import { render } from 'react-dom';
import { Provider } from 'react-redux';
import App from './containers/App';
import configureStore from './store/configureStore';
const store = configureStore();
render(
<Provider store={store}>
<App />
</Provider>,
document.getElementById('layout')
);
|
app/components/Feed/FeedEntryPlaceholder.js
|
yenbekbay/filmstrip-web
|
/* @flow */
import {css, keyframes} from 'glamor';
import React from 'react';
import {breakpoints, t} from '../../styles';
const loaderAnimation = keyframes({
'0%': {backgroundPosition: '-700px 0'},
'100%': {backgroundPosition: '800px 0'},
});
const styles = {
container: css({
...t.br2,
...t.mt2,
...t.w_100,
...t.relative,
height: '17rem',
content: '',
background: '#353A44',
backgroundImage: 'linear-gradient(to right, #353A44 0%, #2F343F 20%, #353A44 40%, #353A44 100%)',
animation: `${loaderAnimation} 1s infinite linear`,
backgroundRepeat: 'no-repeat',
backgroundSize: '1400px 600px',
overflow: 'none',
}),
block: css({
...t.absolute,
backgroundColor: '#272B35',
}),
};
const blocks = [
{
top: 0,
left: 0,
right: 0,
height: '2rem',
[breakpoints.l]: {
left: '13rem',
},
},
{
bottom: 0,
left: 0,
right: 0,
height: '2rem',
[breakpoints.l]: {
left: '13rem',
},
},
{
top: 0,
left: 0,
width: '2rem',
height: '100%',
[breakpoints.l]: {
left: '11rem',
},
},
{top: 0, right: '0rem', width: '2rem', height: '100%'},
{top: '2rem', right: '5rem', width: '3rem', height: '1.5rem'},
{
top: '3.5rem',
left: '2rem',
right: '5rem',
height: '1rem',
[breakpoints.l]: {
left: '13rem',
},
},
{
top: '4.5rem',
left: '13rem',
right: '5rem',
height: '1rem',
[breakpoints.l]: {
left: '24rem',
},
},
{
top: '5.5rem',
left: '0rem',
right: '5rem',
height: '1.5rem',
[breakpoints.l]: {
left: '13rem',
},
},
{top: '7rem', right: '5rem', width: '3rem', height: '3.5rem'},
{
top: '10.5rem',
left: 0,
right: 0,
height: '1.5rem',
[breakpoints.l]: {
left: '13rem',
},
},
{
top: '12rem',
left: '19rem',
right: 0,
height: '1.5rem',
[breakpoints.l]: {
left: '30rem',
},
},
{
top: '13.25rem',
left: 0,
right: 0,
height: '0.5rem',
[breakpoints.l]: {
left: '13rem',
},
},
{top: '13.5rem', left: '40rem', right: 0, height: '1.5rem'},
];
const renderBlock = (block: Object, idx: number) => {
const blockStyle = css(block);
return <div key={idx} className={`${styles.block} ${blockStyle}`} />;
};
const FeedEntryPlaceholder = () => (
<div className={styles.container}>
{blocks.map(renderBlock)}
</div>
);
export default FeedEntryPlaceholder;
|
src/components/CartInfoPane.js
|
longyarnz/WelFurnish-E-Commerce
|
import React, { Component } from 'react';
export default class CartInfoPane extends Component {
constructor(props) {
super(props);
}
render() {
return (
<div className="cart-info">
<i className="" />
<span>{this.props.content}</span>
</div>
);
}
}
|
src/test/componentsSpec/Header.spec.js
|
badT/Chatson
|
import React from 'react';
import { Provider } from 'react-redux';
import { mount } from 'enzyme';
import chai, { expect } from 'chai';
import chaiEnzyme from 'chai-enzyme';
chai.use(chaiEnzyme());
import configureStore from '../../store/configureStore';
import { Header } from '../../components/Header/index';
describe('<Header />', () => {
const store = configureStore();
const wrapper = mount(
<Provider store={store}>
<Header />
</Provider>
);
it('should render <ChannelDropdown /> container', () => {
expect(wrapper.find('span')).to.have.length(3);
});
});
|
server/sonar-web/src/main/js/apps/overview/gate/gate.js
|
joansmith/sonarqube
|
/*
* SonarQube
* Copyright (C) 2009-2016 SonarSource SA
* mailto:contact AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import React from 'react';
import GateConditions from './gate-conditions';
import GateEmpty from './gate-empty';
import { translate, translateWithParameters } from '../../../helpers/l10n';
export default React.createClass({
renderGateConditions () {
return <GateConditions gate={this.props.gate} component={this.props.component}/>;
},
renderGateText () {
let text = '';
if (this.props.gate.level === 'ERROR') {
text = translateWithParameters('overview.gate.view.errors', this.props.gate.text);
} else if (this.props.gate.level === 'WARN') {
text = translateWithParameters('overview.gate.view.warnings', this.props.gate.text);
} else {
text = translate('overview.gate.view.no_alert');
}
return <div className="overview-card">{text}</div>;
},
render() {
if (!this.props.gate || !this.props.gate.level) {
return this.props.component.qualifier === 'TRK' ? <GateEmpty/> : null;
}
let level = this.props.gate.level.toLowerCase();
let badgeClassName = 'badge badge-' + level;
let badgeText = translate('overview.gate', this.props.gate.level);
return (
<div className="overview-gate">
<h2 className="overview-title">
{translate('overview.quality_gate')}
<span className={badgeClassName}>{badgeText}</span>
</h2>
{this.props.gate.conditions ? this.renderGateConditions() : this.renderGateText()}
</div>
);
}
});
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.