path
stringlengths 5
195
| repo_name
stringlengths 5
79
| content
stringlengths 25
1.01M
|
---|---|---|
techCurriculum/ui/solutions/2.3/src/components/Title.js | tadas412/EngineeringEssentials | /**
* Copyright 2017 Goldman Sachs.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
**/
import React from 'react';
function Title() {
return (
<div>
<h1>Cards</h1>
<h2>Share your ideas</h2>
</div>
);
}
export default Title;
|
components/Cards/EditorialCard/EditorialCard.js | rdjpalmer/bloom | import PropTypes from 'prop-types';
import React, { Component } from 'react';
import cx from 'classnames';
import { applyContainerQuery } from 'react-container-query';
import FittedImage from '../../FittedImage/FittedImage';
import Card from '../Card/Card';
import css from './EditorialCard.css';
const query = {
[css.large]: {
minWidth: 400,
},
};
class EditorialCard extends Component {
static propTypes = {
title: PropTypes.string.isRequired,
children: PropTypes.node,
className: PropTypes.string,
src: PropTypes.string,
allowHorizontal: PropTypes.bool,
forceHorizontal: PropTypes.bool,
containerQuery: PropTypes.shape({
[css.horizontal]: PropTypes.bool,
[css.large]: PropTypes.bool,
}),
};
static defaultProps = {
allowHorizontal: true,
};
render() {
const {
title,
className,
src,
children,
containerQuery,
allowHorizontal,
forceHorizontal,
...rest,
} = this.props;
const renderHorizontal = (allowHorizontal && containerQuery[css.horizontal]) ||
forceHorizontal;
const classes = cx(
css.root, {
...containerQuery,
[css.horizontal]: renderHorizontal,
},
className,
);
return (
<Card { ...rest } className={ classes }>
<div className={ css.imageContainer }>
<FittedImage
src={ src }
alt={ title }
className={ css.image }
/>
</div>
<div className={ css.content }>
<span className={ css.title }>{ title }</span>
<div className={ css.body }>{ children }</div>
</div>
</Card>
);
}
}
export default applyContainerQuery(EditorialCard, query);
|
src/components/TopicTypes.js | cyqkeygen/ruby-china-react-redux-demo | import React from 'react';
import PropTypes from 'prop-types';
import { NavLink } from 'react-router-dom';
import styles from '../styles/modules/TopicTypes.scss';
class TopicTypes extends React.Component {
render(){
return (
<div className={styles.links}>
<NavLink className={styles.link}
activeClassName={styles.active}
exact
to='/topics'>
默认
</NavLink>
<NavLink className={styles.link}
activeClassName={styles.active}
to='/topics/popular'>
优质帖子
</NavLink>
<NavLink className={styles.link}
activeClassName={styles.active}
to='/topics/no_reply'>
无人问津
</NavLink>
<NavLink className={styles.link}
activeClassName={styles.active}
to='/topics/last'>
最新发布
</NavLink>
</div>
)
}
}
export default TopicTypes;
|
docs/src/App.js | InsidersByte/react-markdown-editor | import React, { Component } from 'react';
import MarkdownEditor from '@insidersbyte/react-markdown-editor';
import './App.css';
class App extends Component {
state = {
markdown: '# This is a H1 \n## This is a H2 \n###### This is a H6',
};
handleChange = event => {
this.setState({ markdown: event.target.value });
};
render() {
return (
<MarkdownEditor
value={this.state.markdown}
onChange={this.updateMarkdown}
onImageDrop={this.onImageDrop}
/>
);
}
}
export default App;
|
src/mui/field/UrlField.js | RestUI/rest-ui | import React from 'react';
import PropTypes from 'prop-types';
import get from 'lodash.get';
import pure from 'recompose/pure';
const UrlField = ({ source, record = {}, elStyle }) => (
<a href={get(record, source)} style={elStyle}>
{get(record, source)}
</a>
);
UrlField.propTypes = {
addLabel: PropTypes.bool,
elStyle: PropTypes.object,
label: PropTypes.string,
record: PropTypes.object,
source: PropTypes.string.isRequired,
};
const PureUrlField = pure(UrlField);
PureUrlField.defaultProps = {
addLabel: true,
};
export default PureUrlField;
|
examples/react-router/src/shared/containers/TopLevelPageContainer.js | jasonblanchard/react-announce-doc-title | import React from 'react';
import { PropTypes } from 'react';
import { Link } from 'react-router';
import { AnnounceDocTitle } from 'react-announce-doc-title';
const propTypes = {
children: PropTypes.any,
};
export default class TopLevelPageContainer extends React.Component {
render() {
return (
<AnnounceDocTitle title="Settings - React App">
<div>
<h2>Settings</h2>
This has a title, but it should be overwritten by its children. Speaking of...
<Link to="/settings/section">Go to child</Link>
<br />
{this.props.children}
</div>
</AnnounceDocTitle>
);
}
}
TopLevelPageContainer.propTypes = propTypes;
|
acceptance/src/components/ThemeTitle.js | Autodesk/hig | import React from 'react';
import ThemeContext from '@hig/theme-context';
function ThemeTitle({ children }) {
return (
<ThemeContext.Consumer>{({ metadata, resolvedRoles }) => {
return (
<p style={{color: resolvedRoles["colorScheme.textColor"]}}>{metadata.name}</p>
)
}}</ThemeContext.Consumer>
)
}
export default ThemeTitle;
|
app/entries/notFound.js | mariopeixoto/isomorphic-react-webpack-boilerplate | 'use strict';
/*global document, window */
import React from 'react';
window.React = React;
import Client from '../client';
import buildRoutes from '../routes';
import Website from 'react-proxy!../views/website/Website';
import NotFound from '../views/notFound/NotFound';
const routes = buildRoutes(Website, NotFound);
Client.run(routes, document.getElementById('app'));
|
src/ex5.js | bouzuya/exercise-in-react | import React from 'react';
var MessageInput = React.createClass({
displayName: 'MessageInput',
onChange: function(e) {
this.props.onChange(e.target.value);
},
onKeyDown: function(e) {
if (e.keyCode === 13) {
this.props.onSubmit(e.target.value);
e.target.value = '';
}
},
render: function() {
return React.createElement('input', {
onChange: this.onChange, onKeyDown: this.onKeyDown
});
}
});
var MessageOutput = React.createClass({
displayName: 'MessageOutput',
render: function() {
return React.createElement(
'div', null,
React.createElement('span', null, 'Hello, ', this.props.message),
React.createElement(
'ul', null,
this.props.messages.map(function (i, index) {
return React.createElement('li', { key: index }, i);
})
)
);
}
});
var Hello3 = React.createClass({
displayName: 'Hello3',
getInitialState: function() {
return { message: 'bouzuya', messages: [] };
},
onTextChanged: function(text) {
this.setState({ message: text });
},
onTextSubmitted: function(text) {
var messages = this.state.messages.concat(text);
this.setState({ messages: messages });
},
render: function() {
return React.createElement(
'div', null,
React.createElement(MessageInput, {
onChange: this.onTextChanged,
onSubmit: this.onTextSubmitted
}),
React.createElement(MessageOutput, {
message: this.state.message,
messages: this.state.messages
})
);
}
});
export default React.createElement(Hello3);
|
powerpiapp/elements/menu.js | Knapsacks/power-pi-v2 | import React, { Component } from 'react';
import { View, Text } from 'react-native';
import { Header, Spinner } from './common';
export default class Menu extends Component {
constructor(props) {
super(props);
this.state = { energy: '', money_saved: '', charging_status: '', days: '' };
}
componentDidMount() {
return fetch('https://helllabs-app.herokuapp.com/device/metrics')
.then((response) => response.json())
.then((responseJson) => {
console.log(responseJson);
this.setState({ energy: Math.round(responseJson.energy),
money_saved: Math.round(responseJson.money_saved),
charging_status: responseJson.charging_status,
days: responseJson.days });
})
.catch((error) => {
console.error(error);
});
}
toLoadOrNotToLoad() {
if (this.state.energy === ''){
return (
<Spinner />
);
}
}
render() {
return (
<View style={{ flex: 4, width: 300, marginBottom: 10 }}>
<Header headerText={this.props.userDetail.name} />
<View style={{ flex: 2, flexDirection: 'row' }}>
<View style={{ flex: 1, backgroundColor: '#2EC4B6' }}>
<Text style={styles.text}>Charging Status</Text>
<Text style={styles.text2}>{this.state.charging_status}</Text>
</View>
<View style={{ flex: 1, backgroundColor: '#E71D36' }}>
<Text style={styles.text}>Energy Saved</Text>
<Text style={styles.text2}>{this.state.energy}</Text>
</View>
</View>
<View style={{ flex: 2, flexDirection: 'row' }}>
<View style={{ flex: 1, backgroundColor: '#1A535C' }}>
<Text style={styles.text}>Money Saved</Text>
<Text style={styles.text2}>{this.state.money_saved}</Text>
</View>
<View style={{ flex: 1, backgroundColor: '#FF9F1C' }}>
<Text style={styles.text}>Days Consumed</Text>
<Text style={styles.text2}>{this.state.days}</Text>
</View>
</View>
{this.toLoadOrNotToLoad()}
</View>
);
}
}
const styles = {
text: {
padding: 20,
color: '#FDFFFC',
margin: 5,
textAlign: 'center',
fontSize: 18
},
text2: {
padding: 20,
color: '#FDFFFC',
margin: 5,
textAlign: 'center',
fontWeight: 'bold',
fontSize: 20
}
};
|
docs/src/GridPage.js | jsbranco/react-materialize | import React from 'react';
import Row from '../../src/Row';
import Col from '../../src/Col';
import ReactPlayground from './ReactPlayground';
import PropTable from './PropTable';
import store from './store';
import Samples from './Samples';
import grid from '../../examples/Grid';
class GridPage extends React.Component {
componentDidMount() {
store.emit('component', 'Grid');
}
render() {
return (
<Row>
<Col m={9} s={12} l={10}>
<p className='caption'>
We are using a standard 12 column fluid responsive grid system. The grid helps you layout your page in an ordered, easy fashion.
</p>
<h4 className='col s12'>
12 Columns
</h4>
<Col s={12}>
<ReactPlayground code={ Samples.grid }>
{grid}
</ReactPlayground>
</Col>
<Col s={12}>
<PropTable component='Row'/>
<PropTable component='Col'/>
</Col>
</Col>
</Row>
);
}
}
export default GridPage;
|
src/js/components/Toast.js | linde12/grommet | // (C) Copyright 2014-2016 Hewlett Packard Enterprise Development LP
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import ReactDOM from 'react-dom';
import classnames from 'classnames';
import Button from './Button';
import Status from './icons/Status';
import CloseIcon from './icons/base/Close';
import CSSClassnames from '../utils/CSSClassnames';
import { announce } from '../utils/Announcer';
const CLASS_ROOT = CSSClassnames.TOAST;
const APP = CSSClassnames.APP;
const DURATION = 8000;
const ANIMATION_DURATION = 1000;
class ToastContents extends Component {
constructor () {
super();
this._onClose = this._onClose.bind(this);
this.state = {};
}
getChildContext () {
return {
history: this.props.history,
intl: this.props.intl,
router: this.props.router,
store: this.props.store
};
}
componentDidMount () {
announce(this._contentsRef.innerText);
this._timer = setTimeout(this._onClose, DURATION);
}
componentWillUnmount () {
clearTimeout(this._timer);
this._timer = undefined;
}
_onClose () {
const { onClose } = this.props;
clearTimeout(this._timer);
this._timer = undefined;
this.setState({ closing: true });
if (onClose) {
setTimeout(onClose, ANIMATION_DURATION);
}
}
render () {
const { children, onClose, size, status } = this.props;
const { closing } = this.state;
const classNames = classnames(
CLASS_ROOT, {
[`${CLASS_ROOT}--${size}`]: size,
[`${CLASS_ROOT}--closing`]: closing
}
);
let statusIcon;
if (status) {
statusIcon = (
<Status className={`${CLASS_ROOT}__status`} value={status}
size={size === 'large' ? 'medium' : size} />
);
}
let closeControl;
if (onClose) {
closeControl = (
<Button className={`${CLASS_ROOT}__closer`}
icon={<CloseIcon />} onClick={this._onClose} />
);
}
return (
<div className={classNames}>
{statusIcon}
<div ref={(ref) => this._contentsRef = ref}
className={`${CLASS_ROOT}__contents`}>
{children}
</div>
{closeControl}
</div>
);
}
}
ToastContents.propTypes = {
history: PropTypes.object,
intl: PropTypes.object,
onClose: PropTypes.func,
router: PropTypes.any,
size: PropTypes.oneOf(['small', 'medium', 'large']),
store: PropTypes.any
};
// Because Toast creates a new DOM render context, the context
// is not transfered. For now, we hard code these specific ones.
// TODO: Either figure out how to introspect the context and transfer
// whatever we find or have callers explicitly indicate which parts
// of the context to transfer somehow.
ToastContents.childContextTypes = {
history: PropTypes.object,
intl: PropTypes.object,
router: PropTypes.any,
store: PropTypes.object
};
export default class Toast extends Component {
componentDidMount () {
this._addLayer();
this._renderLayer();
}
componentDidUpdate () {
this._renderLayer();
}
componentWillUnmount () {
this._removeLayer();
}
_addLayer () {
const { id } = this.props;
const element = document.createElement('div');
if (id) {
element.id = id;
}
element.className = `${CLASS_ROOT}__container`;
// insert before .app, if possible.
var appElements = document.querySelectorAll(`.${APP}`);
var beforeElement;
if (appElements.length > 0) {
beforeElement = appElements[0];
} else {
beforeElement = document.body.firstChild;
}
if (beforeElement) {
this._element =
beforeElement.parentNode.insertBefore(element, beforeElement);
}
}
_renderLayer () {
if (this._element) {
this._element.className = `${CLASS_ROOT}__container`;
const contents = (
<ToastContents {...this.props}
history={this.context.history}
intl={this.context.intl}
router={this.context.router}
store={this.context.store} />
);
ReactDOM.render(contents, this._element);
}
}
_removeLayer () {
ReactDOM.unmountComponentAtNode(this._element);
this._element.parentNode.removeChild(this._element);
this._element = undefined;
}
render () {
return (<span style={{display: 'none'}} />);
}
}
Toast.propTypes = {
onClose: PropTypes.func,
size: PropTypes.oneOf(['small', 'medium', 'large']),
status: PropTypes.string
};
Toast.defaultProps = {
size: 'medium'
};
|
webclient/src/account/StoryItem.js | jadiego/bloom | import React, { Component } from 'react';
import { Button, Icon, Label, Checkbox, Segment, Header, Container, Popup } from 'semantic-ui-react'
import moment from "moment";
import { Link } from 'react-router-dom';
import DeleteStoryModal from './DeleteStoryModal';
import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
import { togglePrivacy } from '../redux/actions';
class StoryItem extends Component {
toggle = (e) => {
e.preventDefault()
const story = { ...this.props }
this.props.togglePrivacy(!story.private, story)
}
render() {
let { name, id, description, createdAt, togglePrivacy } = this.props
return (
<Segment className='story-item' padded>
<Checkbox toggle label="Privacy Type" onChange={this.toggle} checked={this.props.private} className='story-toggle' />
<span className='story-privacy-string'>{
this.props.private ? " PRIVATE" : " PUBLIC"
}</span>
<Popup
trigger={
<Icon name='ellipsis vertical' style={{ float: "right", fontSize: "16px", cursor:"pointer" }} />
}
on='click'
basic
hideOnScroll={true}
style={{zIndex: 900}}
position='left center'
>
<DeleteStoryModal storyid={id} />
</Popup>
<Header as='h1' className='story-name'>{name}</Header>
<Container>
<div className='story-description'>{description}</div>
<div className='story-buttons'>
<div className='story-date'><span style={{ color: "rgb(141, 149, 157)" }}>Created On</span> {moment(createdAt).format("LLL")}</div>
<Link className='ui button edit-story-button green' to={`/story/${id}/edit`}>
<Icon name='pencil' />
Edit
</Link>
<div style={{ clear: "both" }}></div>
</div>
</Container>
</Segment>
)
}
}
const mapStateToProps = (state) => {
return {
currentStory: state.currentStory
}
}
const mapDispatchToProps = (dispatch) => {
return bindActionCreators({
togglePrivacy,
}, dispatch)
}
export default connect(mapStateToProps, mapDispatchToProps)(StoryItem) |
src/ui/Error.js | tannercollin/Notica | 'use strict';
import React from 'react';
export default class Error extends React.Component {
render(){
return (
<div className="container">
<div className="row">
<div className="twelve columns">
<h4>Error</h4>
<p>
Something went wrong so we stopped everything and went fishing.
</p>
<video className="u-max-full-width" poster="https://i.imgur.com/vfcuwyah.jpg" preload="auto" autoPlay={true} muted="muted" loop="loop" webkit-playsinline="">
<source src="https://i.imgur.com/vfcuwya.mp4" type="video/mp4" />
</video>
</div>
</div>
</div>
);
}
}
|
21/node_modules/browser-sync/node_modules/bs-recipes/recipes/webpack.react-hot-loader/app/js/main.js | bdSpring/zhou-task02 | import React from 'react';
// It's important to not define HelloWorld component right in this file
// because in that case it will do full page reload on change
import HelloWorld from './HelloWorld.jsx';
React.render(<HelloWorld />, document.getElementById('react-root'));
|
src/svg-icons/action/bug-report.js | xmityaz/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let ActionBugReport = (props) => (
<SvgIcon {...props}>
<path d="M20 8h-2.81c-.45-.78-1.07-1.45-1.82-1.96L17 4.41 15.59 3l-2.17 2.17C12.96 5.06 12.49 5 12 5c-.49 0-.96.06-1.41.17L8.41 3 7 4.41l1.62 1.63C7.88 6.55 7.26 7.22 6.81 8H4v2h2.09c-.05.33-.09.66-.09 1v1H4v2h2v1c0 .34.04.67.09 1H4v2h2.81c1.04 1.79 2.97 3 5.19 3s4.15-1.21 5.19-3H20v-2h-2.09c.05-.33.09-.66.09-1v-1h2v-2h-2v-1c0-.34-.04-.67-.09-1H20V8zm-6 8h-4v-2h4v2zm0-4h-4v-2h4v2z"/>
</SvgIcon>
);
ActionBugReport = pure(ActionBugReport);
ActionBugReport.displayName = 'ActionBugReport';
ActionBugReport.muiName = 'SvgIcon';
export default ActionBugReport;
|
src/routes/Home/components/HomeView.js | trixyrabbit/Exile | import React from 'react'
import DuckImage from '../assets/Duck.jpg'
import './HomeView.scss'
import { Row } from 'react-flexbox-grid/lib/index'
export const HomeView = () => (
<div >
<Row center='xs'>
<h4>Welcome!</h4>
</Row>
<img
alt='This is a duck, because Redux!'
className='duck'
src={DuckImage} />
</div>
)
export default HomeView
|
demo/index.js | 111StudioKK/react-plan | import React from 'react';
import ReactDOM from 'react-dom';
import Responsive from '../src/Responsive.jsx';
import Viewport from '../src/Viewport.jsx';
import App from './App.jsx';
new Responsive();
ReactDOM.render(<Viewport><App /></Viewport>, document.getElementById('root'));
|
app/javascript/mastodon/components/load_gap.js | riku6460/chikuwagoddon | import React from 'react';
import PropTypes from 'prop-types';
import { injectIntl, defineMessages } from 'react-intl';
const messages = defineMessages({
load_more: { id: 'status.load_more', defaultMessage: 'Load more' },
});
export default @injectIntl
class LoadGap extends React.PureComponent {
static propTypes = {
disabled: PropTypes.bool,
maxId: PropTypes.string,
onClick: PropTypes.func.isRequired,
intl: PropTypes.object.isRequired,
};
handleClick = () => {
this.props.onClick(this.props.maxId);
}
render () {
const { disabled, intl } = this.props;
return (
<button className='load-more load-gap' disabled={disabled} onClick={this.handleClick} aria-label={intl.formatMessage(messages.load_more)}>
<i className='fa fa-ellipsis-h' />
</button>
);
}
}
|
src-admin/src/Tabs/Options.js | ioBroker/ioBroker.admin | import React, { Component } from 'react';
import { withStyles } from '@material-ui/core/styles';
import PropTypes from 'prop-types';
import Security from '@material-ui/icons/Security';
import Logo from '@iobroker/adapter-react/Components/Logo';
import I18n from '@iobroker/adapter-react/i18n';
import CustomSelect from '../Components/CustomSelect';
import CustomInput from '../Components/CustomInput';
import CustomCheckbox from '../Components/CustomCheckbox';
import CustomModal from '../Components/CustomModal';
import Toast from '../Components/Toast';
const styles = theme => ({
blockWrapper: {
display: 'flex',
flexDirection: 'column',
marginRight: 20,
'@media screen and (max-width: 360px)': {
marginRight: 0
}
},
displayNone: {
display: 'none !important'
},
tab: {
width: '100%',
minHeight: '100%'
},
column: {
display: 'inline-block',
verticalAlign: 'top',
marginRight: 20
},
columnSettings: {
width: 'calc(100% - 10px)',
},
blockWrapperCheckbox: {
display: 'flex',
flexFlow: 'wrap'
},
ipInputStyle: {
marginTop: 10,
width: 900,
marginRight: 20,
'@media screen and (max-width: 940px)': {
width: '100%'
}
},
blockWarning: {
background: '#2196f3',
color: '#fff',
margin: '20px 2px',
padding: 8,
fontSize: 20
},
blockWarningContent: {
marginBottom: 200,
flexFlow: 'wrap',
display: 'flex',
alignItems: 'flex-end'
}
});
class Options extends Component {
constructor(props) {
super(props);
this.state = {
toast: '',
ipAddressOptions: [],
certificatesOptions: [],
usersOptions: [],
openModal: false
};
}
componentDidMount() {
const { socket, common: { host } } = this.props;
socket.getRawSocket().emit('getHostByIp', host, (err, data) => {
if (data) {
let IPs4 = [{ title: `[IPv4] 0.0.0.0 - ${I18n.t('open_ip')}`, value: '0.0.0.0', family: 'ipv4' }];
let IPs6 = [{ title: '[IPv6] ::', value: '::', family: 'ipv6' }];
if (data.native.hardware && data.native.hardware.networkInterfaces) {
for (let eth in data.native.hardware.networkInterfaces) {
if (!data.native.hardware.networkInterfaces.hasOwnProperty(eth)) {
continue;
}
for (let num = 0; num < data.native.hardware.networkInterfaces[eth].length; num++) {
if (data.native.hardware.networkInterfaces[eth][num].family !== 'IPv6') {
IPs4.push({ title: `[${data.native.hardware.networkInterfaces[eth][num].family}] ${data.native.hardware.networkInterfaces[eth][num].address} - ${eth}`, value: data.native.hardware.networkInterfaces[eth][num].address, family: 'ipv4' });
} else {
IPs6.push({ title: `[${data.native.hardware.networkInterfaces[eth][num].family}] ${data.native.hardware.networkInterfaces[eth][num].address} - ${eth}`, value: data.native.hardware.networkInterfaces[eth][num].address, family: 'ipv6' });
}
}
}
}
for (let i = 0; i < IPs6.length; i++) {
IPs4.push(IPs6[i]);
}
this.setState({ ipAddressOptions: IPs4 });
}
})
socket.getCertificates()
.then(list =>
this.setState({ certificatesOptions: list }));
socket.getUsers()
.then(list =>
this.setState({ usersOptions: list }));
}
componentDidUpdate(prevProps) {
const { native: { auth, secure } } = prevProps;
if (!this.props.native.secure && this.props.native.auth && !this.state.openModal && ((auth !== this.props.native.auth) || (secure !== this.props.native.secure))) {
this.setState({ openModal: true });
}
}
renderConfirmDialog() {
return <CustomModal
open={this.state.openModal}
buttonClick={() => {
this.props.onChange('auth', false, () =>
this.setState({ openModal: false, toast: 'Authentication was deactivated' }));
}}
close={() => this.setState({ openModal: false })}
titleOk={I18n.t('Disable authentication')}
titleCancel={I18n.t('Ignore warning')}>
<div className={classes.blockWarning}>{I18n.t('Warning!')}</div>
<div className={classes.blockWarningContent}><Security style={{ width: 100, height: 100 }} />{I18n.t('Unsecure_Auth')}</div>
</CustomModal>;
}
render() {
const { instance, common, classes, native, onLoad, onChange } = this.props;
const { certificatesOptions, ipAddressOptions, usersOptions, toast } = this.state;
let newCommon = JSON.parse(JSON.stringify(common));
newCommon.icon = newCommon.extIcon;
return <form className={classes.tab}>
<Toast message={toast} onClose={() => this.setState({ toast: '' })} />
{this.renderConfirmDialog()}
<Logo
instance={instance}
classes={undefined}
common={newCommon}
native={native}
onError={text => this.setState({ errorText: text })}
onLoad={onLoad}
/>
<div className={`${classes.column} ${classes.columnSettings}`}>
<div>
<CustomSelect
title='IP'
attr='bind'
className={classes.ipInputStyle}
options={ipAddressOptions}
native={native}
onChange={onChange}
/>
<CustomInput
title='Port'
attr='port'
type='number'
style={{ marginTop: 5 }}
native={native}
onChange={onChange}
/>
</div>
<div className={classes.blockWrapperCheckbox}>
<div className={classes.blockWrapper}>
<CustomCheckbox
title='Secure(HTTPS)'
attr='secure'
style={{ marginTop: 10 }}
native={native}
onChange={onChange}
/>
<CustomCheckbox
title='Authentication'
attr='auth'
style={{ marginTop: 10 }}
native={native}
onChange={onChange}
/>
</div>
<div className={classes.blockWrapper}>
<div className={`${classes.blockWrapperCheckbox} ${native['secure'] ? null : classes.displayNone}`} >
<CustomSelect
title='Public certificate'
attr='certPublic'
options={[
{ title: I18n.t('nothing'), value: '' }, ...certificatesOptions.filter(({ type }) => type === 'public').map(({ name }) => ({ title: name, value: name }))
]}
style={{ marginTop: 10, marginRight: 20 }}
native={native}
onChange={onChange}
/>
<CustomSelect
title='Private certificate'
attr='certPrivate'
options={[
{ title: I18n.t('nothing'), value: '' }, ...certificatesOptions.filter(({ type }) => type === 'private').map(({ name }) => ({ title: name, value: name }))
]}
style={{ marginTop: 10, marginRight: 20 }}
native={native}
onChange={onChange}
/>
<CustomSelect
title='Chained certificate'
attr='certChained'
options={[
{ title: I18n.t('nothing'), value: '' }, ...certificatesOptions.filter(({ type }) => type === 'chained').map(({ name }) => ({ title: name, value: name }))
]}
style={{ marginTop: 10 }}
native={native}
onChange={onChange}
/>
</div>
<CustomSelect
className={!native['auth'] ? null : classes.displayNone}
title='Run as'
attr='defaultUser'
options={usersOptions.map(({ _id, common: { name } }) => ({ title: name, value: _id.replace('system.user.', '') }))}
style={{ marginTop: 10, width: 300 }}
native={native}
onChange={onChange}
/>
<CustomInput
className={native['auth'] ? null : classes.displayNone}
title='Login timeout(sec)'
attr='ttl'
type='number'
style={{ marginTop: -1, width: 300 }}
native={native}
onChange={onChange}
/>
</div>
<div className={classes.blockWrapper}>
<CustomSelect
title='Auto update'
attr='autoUpdate'
style={{ marginTop: 10 }}
native={native}
options={[
{value: 0, title: 'manually'},
{value: 12, title: 'every 12 hours'},
{value: 24, title: 'every day'},
{value: 48, title: 'every 2 days'},
{value: 72, title: 'every 3 days'},
{value: 168, title: 'every week'},
{value: 336, title: 'every 2 weeks'},
{value: 720, title: 'monthly'},
]}
onChange={onChange}
/>
<CustomInput
title='Events threshold value'
attr='thresholdValue'
style={{ marginTop: 10 }}
native={native}
onChange={onChange}
/>
</div>
</div>
</div>
</form>;
}
}
Options.propTypes = {
common: PropTypes.object.isRequired,
native: PropTypes.object.isRequired,
instance: PropTypes.number.isRequired,
adapterName: PropTypes.string.isRequired,
onError: PropTypes.func,
onLoad: PropTypes.func,
onChange: PropTypes.func,
changed: PropTypes.bool,
socket: PropTypes.object.isRequired,
};
export default withStyles(styles)(Options); |
src/index.js | cesarandreu/react-redux | import React from 'react';
import createAll from './components/createAll';
export const { Provider, connect } = createAll(React);
|
html/material-ui/demo/src/App.js | fishjar/gabe-study-notes | import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';
import Button from 'material-ui/Button';
class App extends Component {
render() {
return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<h1 className="App-title">Welcome to React</h1>
</header>
<p className="App-intro">
To get started, edit <code>src/App.js</code> and save to reload.
</p>
<div>
<Button variant="raised" color="primary">Hello World</Button>
</div>
</div>
);
}
}
export default App;
|
src/ButtonInput.js | Terminux/react-bootstrap | import React from 'react';
import Button from './Button';
import FormGroup from './FormGroup';
import InputBase from './InputBase';
import childrenValueValidation from './utils/childrenValueInputValidation';
class ButtonInput extends InputBase {
renderFormGroup(children) {
let {bsStyle, value, ...other} = this.props;
return <FormGroup {...other}>{children}</FormGroup>;
}
renderInput() {
let {children, value, ...other} = this.props;
let val = children ? children : value;
return <Button {...other} componentClass="input" ref="input" key="input" value={val} />;
}
}
ButtonInput.types = Button.types;
ButtonInput.defaultProps = {
type: 'button'
};
ButtonInput.propTypes = {
type: React.PropTypes.oneOf(ButtonInput.types),
bsStyle() {
// defer to Button propTypes of bsStyle
return null;
},
children: childrenValueValidation,
value: childrenValueValidation
};
export default ButtonInput;
|
src/explore/Pager.js | petertrotman/critrolemoments | import React from 'react';
import PropTypes from 'prop-types';
import styled from 'styled-components';
import { adjustHue, desaturate } from 'polished';
const Container = styled.div`
width: 100%;
margin: 0.5em 1em;
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
button {
all: unset;
padding: 0.5em;
margin: 0 0.1em;
width: 3em;
text-align: center;
box-sizing: border-box;
font-family: 'Cinzel Decorative', sans-serif;
font-weight: bold;
font-size: 1.4em;
letter-spacing: 2px;
border-radius: 5px;
background: linear-gradient(0deg,
${props => desaturate(0.15, adjustHue(6, props.theme.primary))},
${props => desaturate(0.15, adjustHue(-6, props.theme.primary))});
cursor: pointer;
color: #fff;
box-shadow: 0px 4px 8px #AAA;
transform: translateY(-2px);
@media (hover) {
box-shadow: none;
transform: none;
}
:hover {
box-shadow: 0px 4px 8px #AAA;
transform: translateY(-2px);
}
:active {
box-shadow: none;
transform: translateY(0);
}
}
select {
margin: 0 0.4em;
font-size: 1.2em;
}
`;
const Pager = ({ data, requestMoments }) => {
if (!data || !data.order || !data.hasFetched) return null;
const numPages = Math.ceil(data.fetchedIndex.length / data.options.limit);
function handleClick(e, increment) {
e.preventDefault();
const newPage = data.options.page + increment;
if (newPage < 0 || newPage >= numPages) return;
requestMoments({ page: newPage });
}
function handleSelect(e) {
e.preventDefault();
requestMoments({ page: parseInt(e.target.value, 10) });
}
/* eslint-disable react/no-array-index-key */
return (
<Container>
<div>
<button onClick={e => handleClick(e, -1)}>{ '<' }</button>
</div>
<span>
Page
<select value={data.options.page} onChange={e => handleSelect(e)}>
{ [...Array(numPages)].map((x, i) => <option value={i} key={i}>{i + 1}</option>) }
</select>
of { numPages }
</span>
<div>
<button onClick={e => handleClick(e, 1)}>{ '>' }</button>
</div>
</Container>
);
/* eslint-enable react/no-array-index-key */
};
Pager.propTypes = {
data: PropTypes.shape({
options: PropTypes.shape({
page: PropTypes.number.isRequired,
}).isRequired,
}).isRequired,
requestMoments: PropTypes.func.isRequired,
};
export default Pager;
|
client/index.js | dimitri-a/wp2_budget | import { Provider } from 'react-redux';
import ReactDOM from 'react-dom';
import React from 'react';
import App from 'containers/App';
import store from 'store';
import 'index.html';
// Load SCSS
import './scss/app.scss';
ReactDOM.render(
<Provider store={store}>
<App />
</Provider>,
document.getElementById('root')
);
|
src/parser/deathknight/unholy/modules/features/ScourgeStrikeEfficiency.js | fyruna/WoWAnalyzer | import React from 'react';
import SPELLS from 'common/SPELLS';
import SpellIcon from 'common/SpellIcon';
import SpellLink from 'common/SpellLink';
import { formatPercentage } from 'common/format';
import Analyzer from 'parser/core/Analyzer';
import Enemies from 'parser/shared/modules/Enemies';
import StatisticBox, { STATISTIC_ORDER } from 'interface/others/StatisticBox';
import { encodeTargetString } from 'parser/shared/modules/EnemyInstances';
class ScourgeStrikeEfficiency extends Analyzer {
static dependencies = {
enemies: Enemies,
};
constructor(...args) {
super(...args);
this.active = !this.selectedCombatant.hasTalent(SPELLS.CLAWING_SHADOWS_TALENT.id);
}
// used to track how many stacks a target has
targets = {};
totalScourgeStrikeCasts = 0;
scourgeStrikeCastsZeroWounds = 0;
on_byPlayer_applydebuffstack(event){
const spellId = event.ability.guid;
if(spellId === SPELLS.FESTERING_WOUND.id){
this.targets[encodeTargetString(event.targetID, event.targetInstance)] = event.stack;
}
}
on_byPlayer_removedebuffstack(event){
const spellId = event.ability.guid;
if(spellId === SPELLS.FESTERING_WOUND.id){
this.targets[encodeTargetString(event.targetID, event.targetInstance)] = event.stack;
}
}
on_byPlayer_removedebuff(event){
const spellId = event.ability.guid;
if(spellId === SPELLS.FESTERING_WOUND.id){
this.targets[encodeTargetString(event.targetID, event.targetInstance)] = 0;
}
}
on_byPlayer_cast(event){
const spellId = event.ability.guid;
if(spellId === SPELLS.SCOURGE_STRIKE.id){
this.totalScourgeStrikeCasts++;
if(this.targets.hasOwnProperty(encodeTargetString(event.targetID, event.targetInstance))) {
const currentTargetWounds = this.targets[encodeTargetString(event.targetID, event.targetInstance)];
if(currentTargetWounds < 1){
this.scourgeStrikeCastsZeroWounds++;
}
} else {
this.scourgeStrikeCastsZeroWounds++;
}
}
}
suggestions(when) {
const percentCastZeroWounds = this.scourgeStrikeCastsZeroWounds/this.totalScourgeStrikeCasts;
const strikeEfficiency = 1 - percentCastZeroWounds;
when(strikeEfficiency).isLessThan(0.90)
.addSuggestion((suggest, actual, recommended) => {
return suggest(<span>You are casting <SpellLink id={SPELLS.SCOURGE_STRIKE.id} /> too often. When spending runes remember to cast <SpellLink id={SPELLS.FESTERING_STRIKE.id} /> instead on targets with no stacks of <SpellLink id={SPELLS.FESTERING_WOUND.id} /></span>)
.icon(SPELLS.SCOURGE_STRIKE.icon)
.actual(`${formatPercentage(actual)}% of Scourge Strikes were used with Wounds on the target`)
.recommended(`>${formatPercentage(recommended)}% is recommended`)
.regular(recommended - 0.10).major(recommended - 0.20);
});
}
statistic() {
const percentCastZeroWounds = this.scourgeStrikeCastsZeroWounds/this.totalScourgeStrikeCasts;
const strikeEfficiency = 1 - percentCastZeroWounds;
return (
<StatisticBox
icon={<SpellIcon id={SPELLS.SCOURGE_STRIKE.id} />}
value={`${formatPercentage(strikeEfficiency)} %`}
label="Scourge Strike Efficiency"
tooltip={`${this.scourgeStrikeCastsZeroWounds} out of ${this.totalScourgeStrikeCasts} Scourge Strikes were used with no Festering Wounds on the target.`}
/>
);
}
statisticOrder = STATISTIC_ORDER.CORE(3);
}
export default ScourgeStrikeEfficiency;
|
new-lamassu-admin/src/components/editableTable/Context.js | naconner/lamassu-server | import React from 'react'
export default React.createContext()
|
src/svg-icons/communication/forum.js | ArcanisCz/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let CommunicationForum = (props) => (
<SvgIcon {...props}>
<path d="M21 6h-2v9H6v2c0 .55.45 1 1 1h11l4 4V7c0-.55-.45-1-1-1zm-4 6V3c0-.55-.45-1-1-1H3c-.55 0-1 .45-1 1v14l4-4h10c.55 0 1-.45 1-1z"/>
</SvgIcon>
);
CommunicationForum = pure(CommunicationForum);
CommunicationForum.displayName = 'CommunicationForum';
CommunicationForum.muiName = 'SvgIcon';
export default CommunicationForum;
|
client/src/components/Signup/Signup.js | Velocies/raptor-ads | import React, { Component } from 'react';
import { Button, Grid } from 'semantic-ui-react';
import { connect } from 'react-redux';
import { toggleSignupLink } from '../../actions';
import CustomerSignup from '../Signup/CustomerSignup';
import ProSignup from '../Signup/ProSignup';
class Signup extends Component {
constructor() {
super();
this.findActiveLink = this.findActiveLink.bind(this);
}
findActiveLink(link) {
return this.props.activeLink === link ? 'active' : '';
}
render() {
const { toggleActiveLink } = this.props;
const { activeLink: link } = this.props;
return (
<div>
<Grid centered>
<div className="signup-buttons">
<Button.Group size="large">
<Button
onClick={() => toggleActiveLink('customer')}
className={this.findActiveLink('customer')}
>
Customer
</Button>
<Button.Or />
<Button
onClick={() => toggleActiveLink('professional')}
className={this.findActiveLink('professional')}
>
Professional
</Button>
</Button.Group>
</div>
</Grid>
{link === 'professional' ? <ProSignup /> : <CustomerSignup />}
</div>
);
}
}
Signup.propTypes = {
activeLink: React.PropTypes.string.isRequired,
toggleActiveLink: React.PropTypes.func.isRequired,
};
const mapStateToProps = state =>
({
activeLink: state.auth.signupForm.activeLink,
});
const mapDispatchToProps = dispatch =>
({
toggleActiveLink: link => dispatch(toggleSignupLink(link)),
});
export default connect(mapStateToProps, mapDispatchToProps)(Signup);
|
src/layouts/CoreLayout/CoreLayout.js | mje0002/originReact | import React from 'react'
import Header from '../../components/Header'
import './CoreLayout.scss'
import '../../styles/core.scss'
export const CoreLayout = ({ children }) => (
<div className='container text-center'>
<Header />
<div className='core-layout__viewport'>
{children}
</div>
</div>
)
CoreLayout.propTypes = {
children : React.PropTypes.element.isRequired
}
export default CoreLayout
|
src/containers/RouteSelection.js | kyledavid/rock-genius | import React from 'react'
import { BrowserRouter, Link, Route } from 'react-router-dom'
class RouteSelection extends React.Component {
render() {
return (
<div className="shelf-outer-wrapper">
<aside id="detail-shelf">
<div className="shelf-inner-wrapper">
<h1>Choose a Route</h1>
<ul className="route-list">
<li><Link to="/boulders/the-pearl/the pearl" >The Pearl</Link></li>
<li><Link to="/boulders/the-pearl/the clam" >The Clam</Link></li>
</ul>
</div>
</aside>
</div>
)
}
}
export default RouteSelection
|
src/Input.js | simonliubo/react-ui | import React from 'react';
import InputBase from './InputBase';
import * as FormControls from './FormControls';
import deprecationWarning from './utils/deprecationWarning';
class Input extends InputBase {
render() {
if (this.props.type === 'static') {
deprecationWarning('Input type=static', 'StaticText');
return <FormControls.Static {...this.props} />;
}
return super.render();
}
}
Input.propTypes = {
type: React.PropTypes.string
};
export default Input;
|
pages/api/list-item.js | cherniavskii/material-ui | import React from 'react';
import withRoot from 'docs/src/modules/components/withRoot';
import MarkdownDocs from 'docs/src/modules/components/MarkdownDocs';
import markdown from './list-item.md';
function Page() {
return <MarkdownDocs markdown={markdown} />;
}
export default withRoot(Page);
|
tests/site7/code2/components/sections.js | dominikwilkowski/cuttlebelle | import PropTypes from 'prop-types';
import React from 'react';
/**
* The Sections component for section text
*/
const Sections = ({ _parseMD, headline }) => (
<div>
{ _parseMD( headline ) }
</div>
);
Sections.propTypes = {
/**
* headline: |
* ## Intro
*
* **Welcome to my site**
*
* Also check out the other pages: [page1](/page1) and [page2](/page1/page2)
* A bunch more links would be [website](http://cuttlebelle.com/) and a [hash link](#below).
*/
headline: PropTypes.string.isRequired,
};
Sections.defaultProps = {};
export default Sections;
|
app/components/IssueIcon/index.js | KarandikarMihir/react-boilerplate | import React from 'react';
function IssueIcon(props) {
return (
<svg
height="1em"
width="0.875em"
className={props.className}
>
<path d="M7 2.3c3.14 0 5.7 2.56 5.7 5.7S10.14 13.7 7 13.7 1.3 11.14 1.3 8s2.56-5.7 5.7-5.7m0-1.3C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7S10.86 1 7 1z m1 3H6v5h2V4z m0 6H6v2h2V10z" />
</svg>
);
}
IssueIcon.propTypes = {
className: React.PropTypes.string,
};
export default IssueIcon;
|
src/components/Weui/panel/panel_footer.js | ynu/ecard-wxe | /**
* Created by n7best
*/
import React from 'react';
import classNames from 'classnames';
export default class PanelFooter extends React.Component {
render() {
const {children, ...others} = this.props;
const Component = this.props.href ? 'a' : 'div';
const className = classNames({
weui_panel_ft: true
});
return (
<Component className={className} {...others}>{children}</Component>
);
}
}; |
2-alpha/src/components/HelperEnds.js | saturninoharris/primer-design | import React from 'react'
import styled from 'styled-components'
const HangingEnd = styled.span`
position: relative;
z-index: -9;
font-family: monospace;
color: ${p => p.theme.textDefault};
letter-spacing: -3px;
opacity: 0.7;
> span {
position: absolute;
min-width: 25px;
}
`
const HangingOffLeft = HangingEnd.extend`
right: 2px; /* for " 5'- ", the dash is a bit long, so adding some space*/
text-align: right;
`
const HangingOffRight = HangingEnd.extend`
left: -1px;
`
export function Left5 () {
return <HangingEnd><HangingOffLeft>5'-</HangingOffLeft></HangingEnd>
}
export function Left3 () {
return <HangingEnd><HangingOffLeft>3'-</HangingOffLeft></HangingEnd>
}
export function Right5 () {
return <HangingEnd><HangingOffRight>-5'</HangingOffRight></HangingEnd>
}
export function Right3 () {
return <HangingEnd><HangingOffRight>-3'</HangingOffRight></HangingEnd>
}
|
packages/material-ui-icons/src/LocalGroceryStore.js | cherniavskii/material-ui | import React from 'react';
import createSvgIcon from './utils/createSvgIcon';
export default createSvgIcon(
<g><path d="M7 18c-1.1 0-1.99.9-1.99 2S5.9 22 7 22s2-.9 2-2-.9-2-2-2zM1 2v2h2l3.6 7.59-1.35 2.45c-.16.28-.25.61-.25.96 0 1.1.9 2 2 2h12v-2H7.42c-.14 0-.25-.11-.25-.25l.03-.12.9-1.63h7.45c.75 0 1.41-.41 1.75-1.03l3.58-6.49c.08-.14.12-.31.12-.48 0-.55-.45-1-1-1H5.21l-.94-2H1zm16 16c-1.1 0-1.99.9-1.99 2s.89 2 1.99 2 2-.9 2-2-.9-2-2-2z" /></g>
, 'LocalGroceryStore');
|
demo/tabs/tabs.js | eferte/react-mdl-1 | import React from 'react';
import Tabs, { Tab } from '../../src/tabs/Tabs';
class Demo extends React.Component {
constructor(props) {
super(props);
this.state = {
activeTab: 0
};
this._handleChange = this._handleChange.bind(this);
}
_handleChange(tabId) {
this.setState({
activeTab: tabId
});
}
_getTabContent() {
var list = [];
switch(this.state.activeTab) {
case 1:
list.push('Tywin', 'Cersei', 'Jamie', 'Tyrion');
break;
case 2:
list.push('Viserys', 'Daenerys');
break;
default:
list.push('Eddard', 'Catelyn', 'Robb', 'Sansa', 'Brandon', 'Arya', 'Rickon');
break;
}
return (
<ul>
{list.map(e => <li key={e}>{e}</li>)}
</ul>
);
}
render() {
return (
<div style={{display: 'inline-block', paddingLeft: '30%'}}>
<Tabs activeTab={this.state.activeTab} onChange={this._handleChange}>
<Tab>Starks</Tab>
<Tab>Lannisters</Tab>
<Tab>Targaryens</Tab>
</Tabs>
<section>
{this._getTabContent()}
</section>
</div>
);
}
}
React.render(<Demo />, document.getElementById('app'));
|
app/javascript/mastodon/features/home_timeline/components/column_settings.js | ikuradon/mastodon | import React from 'react';
import PropTypes from 'prop-types';
import ImmutablePropTypes from 'react-immutable-proptypes';
import { injectIntl, FormattedMessage } from 'react-intl';
import SettingToggle from '../../notifications/components/setting_toggle';
export default @injectIntl
class ColumnSettings extends React.PureComponent {
static propTypes = {
settings: ImmutablePropTypes.map.isRequired,
onChange: PropTypes.func.isRequired,
intl: PropTypes.object.isRequired,
};
render () {
const { settings, onChange } = this.props;
return (
<div>
<span className='column-settings__section'><FormattedMessage id='home.column_settings.basic' defaultMessage='Basic' /></span>
<div className='column-settings__row'>
<SettingToggle prefix='home_timeline' settings={settings} settingPath={['shows', 'reblog']} onChange={onChange} label={<FormattedMessage id='home.column_settings.show_reblogs' defaultMessage='Show boosts' />} />
</div>
<div className='column-settings__row'>
<SettingToggle prefix='home_timeline' settings={settings} settingPath={['shows', 'reply']} onChange={onChange} label={<FormattedMessage id='home.column_settings.show_replies' defaultMessage='Show replies' />} />
</div>
</div>
);
}
}
|
ui/src/js/common/footer/pages/Social.js | Dica-Developer/weplantaforest | import counterpart from 'counterpart';
import React, { Component } from 'react';
require('./social.less');
export default class Social extends Component {
render() {
var that = this;
return (
<div className="container paddingTopBottom15 social">
<div className="row">
<div className="col-md-12">
<h1>{counterpart.translate('FOOTER_PAGES.SOCIAL')}</h1>
</div>
</div>
<div className="row">
<div style={{ marginBottom: 10 + 'px' }}>{counterpart.translate('NEWSLETTER.BODY')}</div>
<iframe
frameborder="0"
marginheight="0"
marginwidth="0"
scrolling="no"
width="100%"
height="91"
allowtransparency="true"
src="https://t924dfe8a.emailsys1a.net/126/2029/86f32163be/subscribe/form.html"
></iframe>
</div>
<div className="row">
<div style={{ marginBottom: 10 + 'px' }}>{counterpart.translate('NEWSLETTER.SOCIAL')}</div>
<div className="col-md-4">
<a href="https://de-de.facebook.com/iplantatree/">
<img src="/assets/images/facebook.png" alt={'facebook'} height="80" />
</a>
</div>
<div className="col-md-4">
<a href="https://twitter.com/iplantatree?lang=de">
<img src="/assets/images/twitter.png" alt={'twitter'} height="80" />
</a>
</div>
<div className="col-md-4">
<a href="https://www.youtube.com/channel/UC3N_Y8sxT7HA0fIXRLvSi7A">
<img src="/assets/images/youtube.jpg" alt={'youtube'} height="80" />
</a>
</div>
</div>
</div>
);
}
}
/* vim: set softtabstop=2:shiftwidth=2:expandtab */
|
src/components/Error/index.js | jiangxy/react-antd-admin | import React from 'react';
import {Icon} from 'antd';
import './index.less';
/**
* 显示错误信息
* 可以当404页来用
*/
class Error extends React.PureComponent {
render() {
return (
<div className="not-found">
<div style={{ fontSize:32 }}><Icon type="frown-o"/></div>
<h1>{this.props.errorMsg || '404 Not Found'}</h1>
</div>
);
}
}
export default Error;
|
src/svg-icons/action/trending-up.js | pancho111203/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let ActionTrendingUp = (props) => (
<SvgIcon {...props}>
<path d="M16 6l2.29 2.29-4.88 4.88-4-4L2 16.59 3.41 18l6-6 4 4 6.3-6.29L22 12V6z"/>
</SvgIcon>
);
ActionTrendingUp = pure(ActionTrendingUp);
ActionTrendingUp.displayName = 'ActionTrendingUp';
ActionTrendingUp.muiName = 'SvgIcon';
export default ActionTrendingUp;
|
docs/app/Examples/modules/Transition/Types/index.js | shengnian/shengnian-ui-react | import React from 'react'
import { Message } from 'shengnian-ui-react'
import ComponentExample from 'docs/app/Components/ComponentDoc/ComponentExample'
import ExampleSection from 'docs/app/Components/ComponentDoc/ExampleSection'
const TransitionTypesExamples = () => (
<ExampleSection title='Types'>
<ComponentExample
title='Transition'
description='A Transition animates a single child by toggling the the visible prop.'
examplePath='modules/Transition/Types/TransitionExampleTransition'
>
<Message warning>
<p>Do not unmount a Transition child or else it cannot be animated.</p>
<Message.List>
<Message.Item>
Use the <code>unmountOnHide</code> prop to unmount the child after the animation exits.
</Message.Item>
<Message.Item>
Use a <code>Transition.Group</code> to animate children as they mount and unmount.
</Message.Item>
</Message.List>
</Message>
</ComponentExample>
<ComponentExample
title='Transition Group'
description='A Transition Group animates children as they mount and unmount.'
examplePath='modules/Transition/Types/TransitionExampleGroup'
/>
</ExampleSection>
)
export default TransitionTypesExamples
|
src/graphs/FutureSnowFallGraph.js | ehaughee/snocon | import React, { Component } from 'react';
import { Line } from 'react-chartjs-2';
let convert = require('convert-units');
let moment = require('moment');
class FutureSnowFallGraph extends Component {
constructor(props) {
super(props);
const dates = this.props.snowfallAmounts.map(({validTime, value}) => {
return moment(validTime.match(/(.*?)\//)[1]).format('HH:mm dd MMM DD');
});
const levels = this.props.snowfallAmounts.map(({validTime, value}) => {
return convert(value).from('mm').to('in').toFixed(0);
});
const lightBlueColor = 'rgb(66, 134, 244)';
this.state = {
data: {
labels: dates,
datasets: [
{
label: 'Snow Fall (in)',
fill: false,
backgroundColor: lightBlueColor,
borderWidth: 2,
borderColor: 'black',
pointBorderColor: lightBlueColor,
data: levels,
},
],
},
};
this.options = {
responsive: true,
maintainAspectRatio: false,
};
}
render() {
return (
<Line data={this.state.data} options={this.options} />
);
}
}
export default FutureSnowFallGraph;
|
src/scenes/Dummy/Dummy.js | constelation/native-starter | // @flow
// Imports {{{
import { StatusBar } from 'react-native'
import { bind } from 'decko'
import Event_ from 'constelation-event_'
import React from 'react'
import Style_ from 'constelation-style_'
import Text from 'constelation-text'
import View from 'constelation-view'
// }}}
type Props = {
navigation: {
goBack: Function,
},
}
export default class Dummy extends React.Component<void, Props, void> {
@bind handlePress() {
this.props.navigation.goBack()
}
render() {
return (
<View grow>
<StatusBar
animated
barStyle='light-content'
/>
<Event_ onPress={this.handlePress}>
<Style_ backgroundColor='black'>
<View
grow
center
padding={10}
>
<Text
size={20}
color='white'
>
HAI
</Text>
</View>
</Style_>
</Event_>
</View>
)
}
}
|
src/components/Footer/Footer.js | Zubergoff/project | /**
* React Starter Kit (https://www.reactstarterkit.com/)
*
* Copyright © 2014-2016 Kriasoft, LLC. All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE.txt file in the root directory of this source tree.
*/
import React, { Component } from 'react';
import s from './Footer.scss';
import withStyles from '../../decorators/withStyles';
import Link from '../Link';
@withStyles(s)
class Footer extends Component {
render() {
return (
<div className={s.root}>
<div className={s.container}>
<span className={s.text}>© Your Company</span>
<span className={s.spacer}>·</span>
<a className={s.link} href="/" onClick={Link.handleClick}>Home</a>
<span className={s.spacer}>·</span>
<a className={s.link} href="/privacy" onClick={Link.handleClick}>Privacy</a>
<span className={s.spacer}>·</span>
<a className={s.link} href="/not-found" onClick={Link.handleClick}>Not Found</a>
</div>
</div>
);
}
}
export default Footer;
|
app/javascript/mastodon/components/status_list.js | glitch-soc/mastodon | import { debounce } from 'lodash';
import React from 'react';
import ImmutablePropTypes from 'react-immutable-proptypes';
import PropTypes from 'prop-types';
import StatusContainer from '../containers/status_container';
import ImmutablePureComponent from 'react-immutable-pure-component';
import LoadGap from './load_gap';
import ScrollableList from './scrollable_list';
import RegenerationIndicator from 'mastodon/components/regeneration_indicator';
export default class StatusList extends ImmutablePureComponent {
static propTypes = {
scrollKey: PropTypes.string.isRequired,
statusIds: ImmutablePropTypes.list.isRequired,
featuredStatusIds: ImmutablePropTypes.list,
onLoadMore: PropTypes.func,
onScrollToTop: PropTypes.func,
onScroll: PropTypes.func,
trackScroll: PropTypes.bool,
isLoading: PropTypes.bool,
isPartial: PropTypes.bool,
hasMore: PropTypes.bool,
prepend: PropTypes.node,
emptyMessage: PropTypes.node,
alwaysPrepend: PropTypes.bool,
withCounters: PropTypes.bool,
timelineId: PropTypes.string,
};
static defaultProps = {
trackScroll: true,
};
getFeaturedStatusCount = () => {
return this.props.featuredStatusIds ? this.props.featuredStatusIds.size : 0;
}
getCurrentStatusIndex = (id, featured) => {
if (featured) {
return this.props.featuredStatusIds.indexOf(id);
} else {
return this.props.statusIds.indexOf(id) + this.getFeaturedStatusCount();
}
}
handleMoveUp = (id, featured) => {
const elementIndex = this.getCurrentStatusIndex(id, featured) - 1;
this._selectChild(elementIndex, true);
}
handleMoveDown = (id, featured) => {
const elementIndex = this.getCurrentStatusIndex(id, featured) + 1;
this._selectChild(elementIndex, false);
}
handleLoadOlder = debounce(() => {
this.props.onLoadMore(this.props.statusIds.size > 0 ? this.props.statusIds.last() : undefined);
}, 300, { leading: true })
_selectChild (index, align_top) {
const container = this.node.node;
const element = container.querySelector(`article:nth-of-type(${index + 1}) .focusable`);
if (element) {
if (align_top && container.scrollTop > element.offsetTop) {
element.scrollIntoView(true);
} else if (!align_top && container.scrollTop + container.clientHeight < element.offsetTop + element.offsetHeight) {
element.scrollIntoView(false);
}
element.focus();
}
}
setRef = c => {
this.node = c;
}
render () {
const { statusIds, featuredStatusIds, onLoadMore, timelineId, ...other } = this.props;
const { isLoading, isPartial } = other;
if (isPartial) {
return <RegenerationIndicator />;
}
let scrollableContent = (isLoading || statusIds.size > 0) ? (
statusIds.map((statusId, index) => statusId === null ? (
<LoadGap
key={'gap:' + statusIds.get(index + 1)}
disabled={isLoading}
maxId={index > 0 ? statusIds.get(index - 1) : null}
onClick={onLoadMore}
/>
) : (
<StatusContainer
key={statusId}
id={statusId}
onMoveUp={this.handleMoveUp}
onMoveDown={this.handleMoveDown}
contextType={timelineId}
scrollKey={this.props.scrollKey}
showThread
withCounters={this.props.withCounters}
/>
))
) : null;
if (scrollableContent && featuredStatusIds) {
scrollableContent = featuredStatusIds.map(statusId => (
<StatusContainer
key={`f-${statusId}`}
id={statusId}
featured
onMoveUp={this.handleMoveUp}
onMoveDown={this.handleMoveDown}
contextType={timelineId}
showThread
withCounters={this.props.withCounters}
/>
)).concat(scrollableContent);
}
return (
<ScrollableList {...other} showLoading={isLoading && statusIds.size === 0} onLoadMore={onLoadMore && this.handleLoadOlder} ref={this.setRef}>
{scrollableContent}
</ScrollableList>
);
}
}
|
src/js/Components/Common/ColorPicker/ColorPicker.js | mattgordils/DropSplash | import React, { Component } from 'react';
import SketchPicker from 'react-color';
import 'sass/components/common/color-picker';
export default class App extends Component {
render () {
return (
<div className="color-picker">
<SketchPicker />
</div>
);
}
}
|
client/Terminal.js | CGamesPlay/hterminal | import React from 'react';
import ReactDOM from 'react-dom';
import BottomScroller from './BottomScroller';
import debounce from './util/debounce';
import { inputFromEvent } from './KeyEvent';
import { SectionGroup, Section } from './SectionGroup';
import './Terminal.css';
export default class Terminal extends React.Component {
constructor(props) {
super(props);
// These methods need to be bound because they are used to add/remove event
// listeners
this.forceUpdate = this.forceUpdate.bind(this);
this.delayResize = debounce(this.calculateWindowSize.bind(this), 100);
this.handleExit = this.handleExit.bind(this);
this.handleExecute = this.handleExecute.bind(this);
}
componentDidMount() {
this.addListenersToDriver(this.props.driver);
this.refs.container.addEventListener('keydown', this.handleKeyEvent.bind(this), false);
this.refs.container.addEventListener('keypress', this.handleKeyEvent.bind(this), false);
this.refs.container.focus();
this.calculateWindowSize();
window.addEventListener('resize', this.delayResize, false);
}
componentWillReceiveProps(newProps) {
if (newProps.driver !== this.props.driver) {
this.removeListenersFromDriver(this.props.driver);
this.addListenersToDriver(newProps.driver);
}
}
addListenersToDriver(driver) {
driver.on('update', this.forceUpdate);
driver.on('exit', this.handleExit);
driver.setFixedSections([ "hterminal-status" ]);
}
removeListenersFromDriver(driver) {
driver.removeListener('update', this.forceUpdate);
driver.removeListener('exit', this.handleExit);
}
render() {
let groups = this.props.driver.groups.map((r, i) =>
<SectionGroup
key={r.uniqueId}
group={r}
readOnly={r.isFinished() || i != this.props.driver.groups.length - 1}
onExecute={this.handleExecute} />
);
return (
<div ref="container" className="terminal" tabIndex={-1} onPaste={this.handlePaste.bind(this)}>
<BottomScroller ref="scroller" className="terminal-content">
{groups}
</BottomScroller>
{this.renderStatusBar()}
</div>
);
}
renderStatusBar() {
let section = this.props.driver.fixedSections["hterminal-status"];
// Only show the status bar if it has contents
if (section && section.content.length > 0) {
return (
<Section className="status-bar"
style={{ padding: this.props.minimumPadding }}
section={section}
onExecute={this.handleExecute.bind(this)}
onUpdate={this.calculateWindowSize.bind(this)} />
);
} else {
return null;
}
}
handleKeyEvent(e) {
var input = inputFromEvent(e, this.props.driver.keypadMode);
if (input.length > 0) {
e.preventDefault();
this.refs.scroller.scrollToBottom();
this.props.onInput(input);
}
}
handlePaste(e) {
if (e.clipboardData.types.indexOf("text/plain") != -1) {
let pasted = e.clipboardData.getData("text/plain");
e.preventDefault();
this.refs.scroller.scrollToBottom();
this.props.onInput(pasted);
}
}
handleExecute(command) {
this.props.onInput(command + "\r");
}
handleExit(code, status) {
window.close();
}
calculateFontSize() {
var currentStyle = window.getComputedStyle(this.refs.container);
var styleKey = currentStyle.fontFamily + ":" + currentStyle.fontSize;
if (this.styleKey != styleKey) {
var el = document.createElement("SPAN");
var scrollerNode = ReactDOM.findDOMNode(this.refs.scroller);
el.innerHTML = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
scrollerNode.appendChild(el);
this.fontMetrics = [ el.offsetWidth / 26, el.offsetHeight ];
scrollerNode.removeChild(el);
this.styleKey = styleKey;
}
return this.fontMetrics;
}
calculateWindowSize() {
var fontMetrics = this.calculateFontSize();
var clientNode = ReactDOM.findDOMNode(this.refs.scroller);
// We require that there is whitespace around the left, right, and bottom.
// We apply the same padding to the top of the window, but the calculations
// don't include it because it will only be shown when the window is
// scrolled up.
var clientWidth = clientNode.clientWidth - this.props.minimumPadding * 2;
var clientHeight = clientNode.clientHeight - this.props.minimumPadding;
var columns = Math.floor(clientWidth / fontMetrics[0]);
var rows = Math.floor(clientHeight / fontMetrics[1]);
this.paddingX = clientWidth % fontMetrics[0];
this.paddingY = clientHeight % fontMetrics[1];
clientNode.style.paddingLeft = Math.floor(this.props.minimumPadding + this.paddingX / 2) + "px";
clientNode.style.paddingRight = Math.ceil(this.props.minimumPadding + this.paddingX / 2) + "px";
clientNode.style.paddingTop = Math.floor(this.props.minimumPadding + this.paddingY / 2) + "px";
clientNode.style.paddingBottom = Math.ceil(this.props.minimumPadding + this.paddingY / 2) + "px";
if ((columns != this.props.initialColumns || rows != this.props.initialRows) && this.props.onResize) {
this.props.onResize(columns, rows);
}
}
}
Terminal.defaultProps = {
// Default padding around each edge
minimumPadding: 3,
}
|
src/containers/Dashboard/Dashboard.js | nbuechler/ample-affect-exhibit | import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { Table, Button, Panel, Row, Col } from 'react-bootstrap';
import NLPDashboardList from '../../components/lists/NLPDashboardList';
class Dashboard extends Component {
constructor(props) {
super(props);
}
render () {
const { handleSubmit } = this.props;
const notImplemented = {textDecoration: "line-through", color: "gray"}
return (
<div>
<h1><i className="fa fa-globe" aria-hidden="true"></i> Overview</h1>
<p>View linguistic processes from prior analyses below:</p>
<br></br>
<Row>
<Col lg={12}>
<NLPDashboardList/>
</Col>
{/*
TODO: Make this a transparent module
<Col lg={3}>
<div>
<Panel header={'Begin a new process'}>
<div style={{marginBottom: '10px'}}>
For when you need your results right now.
</div>
<div style={{textAlign: 'right'}}>
<Button style={{width: '200px'}} bsSize="xsmall" href="#/nlp">
<i className="fa fa-fire" aria-hidden="true"></i> Fast Processing
</Button>
</div>
<hr></hr>
<div style={{marginBottom: '10px'}}>
For detailed results, that are the most precise.
</div>
<div style={{textAlign: 'right'}}>
<Button style={{width: '200px'}} bsSize="xsmall" href="#/nlp">
<i className="fa fa-tint" aria-hidden="true"></i> Precise Processing
</Button>
</div>
</Panel>
</div>
</Col>
*/}
</Row>
</div>
);
}
}
export default Dashboard
|
src/components/programs/inshelter/PrimaryTabs/ArtsCrafts.js | KidsFirstProject/KidsFirstProject.github.io | import React from 'react';
const ArtsCrafts = () => {
return (
<React.Fragment>
<h3>Arts and Crafts</h3>
<p>
To spark creativity and passion is to create a whole new perspective for
a child. With our arts and crafts activities, children will be able to
explore the world of colors and endless ideas to release stress and
promote imagination.
</p>
</React.Fragment>
);
};
export default ArtsCrafts;
|
analysis/demonhunterhavoc/src/modules/talents/CycleOfHatred.js | anom0ly/WoWAnalyzer | import { formatNumber } from 'common/format';
import SPELLS from 'common/SPELLS';
import { SpellIcon } from 'interface';
import Analyzer, { SELECTED_PLAYER } from 'parser/core/Analyzer';
import Events from 'parser/core/Events';
import SpellUsable from 'parser/shared/modules/SpellUsable';
import STATISTIC_ORDER from 'parser/ui/STATISTIC_ORDER';
import TalentStatisticBox from 'parser/ui/TalentStatisticBox';
import React from 'react';
/*
example report: https://www.warcraftlogs.com/reports/QxHJ9MTtmVYNXPLd/#fight=1&source=2
*/
const COOLDOWN_REDUCTION_MS = 3000;
class CycleOfHatred extends Analyzer {
static dependencies = {
spellUsable: SpellUsable,
};
totalCooldownReduction = 0;
constructor(...args) {
super(...args);
this.active = this.selectedCombatant.hasTalent(SPELLS.CYCLE_OF_HATRED_TALENT.id);
if (!this.active) {
return;
}
this.addEventListener(
Events.energize.by(SELECTED_PLAYER).spell(SPELLS.CHAOS_STRIKE_ENERGIZE),
this.onEnergizeEvent,
);
}
onEnergizeEvent(event) {
if (!this.spellUsable.isOnCooldown(SPELLS.EYE_BEAM.id)) {
return;
}
const effectiveReduction = this.spellUsable.reduceCooldown(
SPELLS.EYE_BEAM.id,
COOLDOWN_REDUCTION_MS,
);
this.totalCooldownReduction += effectiveReduction;
}
statistic() {
return (
<TalentStatisticBox
talent={SPELLS.CYCLE_OF_HATRED_TALENT.id}
position={STATISTIC_ORDER.OPTIONAL(7)}
value={
<>
{formatNumber(this.totalCooldownReduction / 1000)} sec{' '}
<small>
total <SpellIcon id={SPELLS.EYE_BEAM.id} /> Eye Beam cooldown reduction
</small>
</>
}
/>
);
}
}
export default CycleOfHatred;
|
src/index.js | dassaptorshi/ReactStarter | import React from 'react';
import ReactDOM from 'react-dom';
import { Provider } from 'react-redux';
import { createStore, applyMiddleware } from 'redux';
import App from './components/app';
import reducers from './reducers';
const createStoreWithMiddleware = applyMiddleware()(createStore);
ReactDOM.render(
<Provider store={createStoreWithMiddleware(reducers)}>
<App />
</Provider>
, document.querySelector('.container'));
|
examples/counter/index.js | dherault/redux | import React from 'react';
import Root from './containers/Root';
React.render(
<Root />,
document.getElementById('root')
);
|
frontend/app/js/utils/event.js | serverboards/serverboards | import React from 'react'
import rpc from 'app/rpc'
import { connect } from 'react-redux'
import { object_is_equal } from 'app/utils'
import serverboards_connect from 'app/containers/connect'
// Count of subscribers to one event, to subscribe again or desuscribe, or do nothing
let subscription_count={}
// Functions to call at event
let subscription_fns={}
export function subscribe(types){
let newsubs=[]
for(let t of types){
if (!subscription_count[t])
newsubs.push(t)
subscription_count[t]=(subscription_count[t] || 0)+1
}
if (newsubs.length!=0){
//console.log("Subscribe to %o", newsubs)
return rpc.call("event.subscribe", newsubs)
}
else{
return Promise.resolve("ok") // Fullfilled!
}
}
export function unsubscribe(types){
let newunsubs=[]
for(let t of types){
if (subscription_count[t]<=1)
newunsubs.push(t)
subscription_count[t]=(subscription_count[t] || 0)-1
}
if (newunsubs.length!=0){
// console.log("Unsubscribe to %o", newunsubs, subscription_count)
return rpc.call("event.unsubscribe", newunsubs)
}
else{
return Promise.resolve("ok") // Fullfilled!
}
}
// Sends again all subscription requests.
export function resubscribe(){
rpc.call("event.subscribe", Object.keys(subscription_count))
}
const PLAIN_EVENT_RE=/[-\w./]+/
export function on(event, fn){
subscribe([event])
const plain_event=PLAIN_EVENT_RE.exec(event)[0]
subscription_fns[plain_event]=(subscription_fns[plain_event] || []).concat([fn])
return fn
}
export function off(event, fn){
unsubscribe([event])
const plain_event=PLAIN_EVENT_RE.exec(event)[0]
if (fn)
subscription_fns[plain_event]=(subscription_fns[plain_event] || []).filter( (f) => (f != fn) )
else
delete subscription_fns[plain_event]
}
export function trigger(event, data){
// console.log("Trigger event %o(%o)", event, data, subscription_fns)
for (let fn of (subscription_fns[event] || [])){
if (fn){
try{
//console.log("Call %o", fn)
fn(data)
}
catch(e){
console.error(`Error processing event ${event}: %o`, e)
}
}
}
}
export function subscriptions(){
return rpc.call("event.subscriptions",[])
}
export function emit(type, args){
return rpc.call("event.emit", [type, args])
}
const event = {subscribe, unsubscribe, subscriptions, emit, on, off, trigger, subscription_fns}
// Inject the event manager into the RPC, required for triggers and some events
rpc.set_event( event )
export default event
|
ReactLab01/Public/js/main.js | knivek91/ReactLab01 | import React from 'react';
import { render } from 'react-dom';
import Home from './src/smart/home';
class Layout extends React.Component {
constructor(props) {
super(props);
this.state = {
message: ''
};
this.onChange = this.onChange.bind(this);
this.setDate = this.setDate.bind(this);
}
onChange(e) {
const name = e.target.name;
const value = e.target.value;
this.setState({ [name]: value });
}
render() {
const { message } = this.state
return (
<div className="jumbotron">
<input name="message" value={message} onChange={this.onChange} placeholder="Escribe . . . " className="form-control" />
<hr />
<Home message={message} />
</div>
)
}
}
render(
<Layout />,
document.getElementById('app')
); |
src/svg-icons/device/battery-charging-60.js | mmrtnz/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let DeviceBatteryCharging60 = (props) => (
<SvgIcon {...props}>
<path fillOpacity=".3" d="M15.67 4H14V2h-4v2H8.33C7.6 4 7 4.6 7 5.33V11h3.87L13 7v4h4V5.33C17 4.6 16.4 4 15.67 4z"/><path d="M13 12.5h2L11 20v-5.5H9l1.87-3.5H7v9.67C7 21.4 7.6 22 8.33 22h7.33c.74 0 1.34-.6 1.34-1.33V11h-4v1.5z"/>
</SvgIcon>
);
DeviceBatteryCharging60 = pure(DeviceBatteryCharging60);
DeviceBatteryCharging60.displayName = 'DeviceBatteryCharging60';
DeviceBatteryCharging60.muiName = 'SvgIcon';
export default DeviceBatteryCharging60;
|
example/App/index.js | nkbt/react-height | import React from 'react';
import {VariableText} from './VariableText';
import {Nested} from './Nested';
export default () => (
<div className="app">
<h1>react-height</h1>
<section className="section">
<h2>Example 1. Variable text</h2>
<VariableText />
</section>
<section className="section">
<h2>Example 2. Nested Blocks</h2>
<Nested />
</section>
</div>
);
|
examples/simple/index.js | shaunstanislaus/library-boilerplate | import React from 'react';
import App from './components/App';
React.render(
<App />,
document.getElementById('root')
);
|
src/main/resources/code/react/Apps/ManageRadars/components/Errors/WarningList.js | artieac/technologyradar | import React from 'react';
import ReactDOM from 'react-dom';
import createReactClass from 'create-react-class';
import { connect } from "react-redux";
import WarningListItem from './ErrorListItem';
class WarningList extends React.Component{
constructor(props){
super(props);
this.state = {
};
}
render() {
if(this.props.warnings !== undefined && this.props.warnings.length > 0){
return (
<div>
<div className="contentPageTitle">
<label>Warnings</label>
</div>
<div className="row">
<div className="col-md-12">
{
this.props.warnings.map((currentRow, index) => {
return <WarningListItem key={index} warning={currentRow} />
})
}
</div>
</div>
</div>
);
}
else{
return (<div className="hidden"></div>);
}
}
};
function mapStateToProps(state) {
return {
warnings: state.errorReducer.warnings
};
};
const mapDispatchToProps = dispatch => {
return {
}
};
export default connect(mapStateToProps, mapDispatchToProps)(WarningList); |
src/svg-icons/communication/call-merge.js | matthewoates/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let CommunicationCallMerge = (props) => (
<SvgIcon {...props}>
<path d="M17 20.41L18.41 19 15 15.59 13.59 17 17 20.41zM7.5 8H11v5.59L5.59 19 7 20.41l6-6V8h3.5L12 3.5 7.5 8z"/>
</SvgIcon>
);
CommunicationCallMerge = pure(CommunicationCallMerge);
CommunicationCallMerge.displayName = 'CommunicationCallMerge';
CommunicationCallMerge.muiName = 'SvgIcon';
export default CommunicationCallMerge;
|
src/components/Forms/Elements/AddToCart.js | CoreyDH/product-finder | import React from 'react';
import {Col, Row, Button, FormControl, FormGroup} from 'react-bootstrap';
export default class AddToCart extends React.Component {
constructor() {
super();
this.state = {
qty: '',
error: null,
loading: ''
}
// this.checkValidation = this.checkValidation.bind(this)
this.handleChange = this.handleChange.bind(this);
this.handleSubmit = this.handleSubmit.bind(this);
}
// checkValidation() {
//
// const validateCode = this.state.qty % this.props.unit;
// if(validateCode === 0) {
// this.setState({
// error: 'error'
// });
//
// return false;
//
// } else {
// this.setState({
// error: 'success'
// });
//
// return true;
// }
// }
handleChange(event) {
this.setState({
qty: event.target.value
});
}
handleSubmit(event) {
event.preventDefault();
this.setState(prevState => {
prevState.loading = 'processing-state';
});
}
render() {
return (
<Row>
<form className="product-finder-form-cart" onSubmit={this.handleSubmit}>
<FormGroup>
<Col xs={9} sm={6}>
<Row>
<FormControl
type="number"
className={`product-finder-unit-input ${this.state.loading}`}
value={this.state.qty}
min={this.props.unit}
step={this.props.unit}
placeholder="QTY"
onChange={this.handleChange} />
</Row>
</Col>
<Col xs={3} sm={6}>
<Button type="submit" bsStyle="primary">Add</Button>
</Col>
</FormGroup>
</form>
</Row>
)
};
}
|
frontend/hocs/confirmDirty.js | SkyPicker/Skywall | import React from 'react'
import {pull} from 'lodash'
import {withRouter} from 'react-router'
import getDisplayName from 'react-display-name'
import PropTypes from 'prop-types'
const confirmDirty = (WrappedComponent) => {
class ConfirmDirty extends React.Component {
static displayName = `ConfirmDirty(${getDisplayName(WrappedComponent)})`
static propTypes = {
route: PropTypes.object.isRequired,
router: PropTypes.shape({
setRouteLeaveHook: PropTypes.func.isRequired,
}).isRequired,
}
constructor(props) {
super(props)
this.hooks = []
this.resetLeaveHook = null
this.registerDirty = this.registerDirty.bind(this)
}
componentDidMount() {
this.resetLeaveHook = this.props.router.setRouteLeaveHook(this.props.route, () => {
for (const hook of this.hooks) {
const dirty = hook()
if (dirty) return dirty
}
})
}
componentWillUnmount() {
this.resetLeaveHook()
}
registerDirty(hook) {
this.hooks.push(hook)
return () => pull(this.hooks, hook)
}
render() {
return (
<WrappedComponent {...this.props} registerDirty={this.registerDirty} />
)
}
}
return withRouter(ConfirmDirty)
}
export default confirmDirty
|
fields/types/text/TextFilter.js | qwales1/keystone | import React from 'react';
import ReactDOM from 'react-dom';
import { FormField, FormInput, FormSelect, SegmentedControl } from 'elemental';
const INVERTED_OPTIONS = [
{ label: 'Matches', value: false },
{ label: 'Does NOT Match', value: true },
];
const MODE_OPTIONS = [
{ label: 'Contains', value: 'contains' },
{ label: 'Exactly', value: 'exactly' },
{ label: 'Begins with', value: 'beginsWith' },
{ label: 'Ends with', value: 'endsWith' },
];
function getDefaultValue () {
return {
mode: MODE_OPTIONS[0].value,
inverted: INVERTED_OPTIONS[0].value,
value: '',
};
}
var TextFilter = React.createClass({
propTypes: {
filter: React.PropTypes.shape({
mode: React.PropTypes.oneOf(MODE_OPTIONS.map(i => i.value)),
inverted: React.PropTypes.boolean,
value: React.PropTypes.string,
}),
},
statics: {
getDefaultValue: getDefaultValue,
},
getDefaultProps () {
return {
filter: getDefaultValue(),
};
},
updateFilter (value) {
this.props.onChange({ ...this.props.filter, ...value });
},
selectMode (mode) {
this.updateFilter({ mode });
ReactDOM.findDOMNode(this.refs.focusTarget).focus();
},
toggleInverted (inverted) {
this.updateFilter({ inverted });
ReactDOM.findDOMNode(this.refs.focusTarget).focus();
},
updateValue (e) {
this.updateFilter({ value: e.target.value });
},
render () {
const { field, filter } = this.props;
const mode = MODE_OPTIONS.filter(i => i.value === filter.mode)[0];
const placeholder = field.label + ' ' + mode.label.toLowerCase() + '...';
return (
<div>
<FormField>
<SegmentedControl equalWidthSegments options={INVERTED_OPTIONS} value={filter.inverted} onChange={this.toggleInverted} />
</FormField>
<FormSelect options={MODE_OPTIONS} onChange={this.selectMode} value={mode.value} />
<FormField>
<FormInput autofocus ref="focusTarget" value={this.props.filter.value} onChange={this.updateValue} placeholder={placeholder} />
</FormField>
</div>
);
},
});
module.exports = TextFilter;
|
examples/esp-chat-react-es6/js/components/ThreadSection.react.js | raybooysen/esp-js | import React from 'react';
import ThreadListItem from './ThreadListItem.react';
export default class ThreadSection extends React.Component {
constructor() {
super();
this._subscription = null;
}
componentWillMount() {
this._subscription = this.props.router
.getModelObservable()
.where(model => model.threadSection.hasChanges)
.observe(model => {
this.setState(model.threadSection);
});
}
componentWillUnmount() {
this._subscription.dispose();
}
render() {
if (this.state === null) {
return null;
}
var router = this.props.router;
var threadListItems = this.state.sortedThreads.map(thread => {
return (
<li key={thread.id}>
<ThreadListItem model={thread} router={router} />
</li>
);
}, this);
var unread = null;
if (this.state.unreadCount.isVisible) {
unread = <span>Unread threads: {this.state.unreadCount.value}</span>;
}
return (
<div className="thread-section">
<div className="thread-count">
{unread}
</div>
<ul className="thread-list">
{threadListItems}
</ul>
</div>
);
}
} |
src/components/dress/DressLabel.js | BinaryCool/LaceShop | import React from 'react';
let Utils = require('../../utils/Utils');
require('styles/dress/DressLabel.scss');
export default class DressModel extends React.Component {
render() {
return(
<div className="Dsy_switchTab">
<div className="Dsy_position">
<p className="Dsy_label_tit">选择标签位置:</p>
<div className="posi_warp">
<span className="posi_zs active"></span>
<span className="posi_ys"></span>
<span className="posi_zx"></span>
<span className="posi_yx"></span>
</div>
</div>
<div className="Dsy_label">
<p className="Dsy_label_tit">选择标签:</p>
<ul className="Dsy_labelUl">
<li className="active">企业名称</li>
<li>联系电话</li>
<li>花型价格</li>
<li>花型编号</li>
<li>自定义</li>
</ul>
</div>
</div>
);
}
} |
src/DropdownButton.js | jontewks/react-bootstrap | import React from 'react';
import BootstrapMixin from './BootstrapMixin';
import Dropdown from './Dropdown';
import NavDropdown from './NavDropdown';
import CustomPropTypes from './utils/CustomPropTypes';
import deprecationWarning from './utils/deprecationWarning';
import omit from 'lodash/object/omit';
class DropdownButton extends React.Component {
constructor(props) {
super(props);
}
render() {
let { title, navItem, ...props } = this.props;
let toggleProps = omit(props, Dropdown.ControlledComponent.propTypes);
if (navItem) {
return <NavDropdown {...this.props}/>;
}
return (
<Dropdown {...props}>
<Dropdown.Toggle {...toggleProps}>
{title}
</Dropdown.Toggle>
<Dropdown.Menu>
{this.props.children}
</Dropdown.Menu>
</Dropdown>
);
}
}
DropdownButton.propTypes = {
/**
* When used with the `title` prop, the noCaret option will not render a caret icon, in the toggle element.
*/
noCaret: React.PropTypes.bool,
/**
* Specify whether this Dropdown is part of a Nav component
*
* @type {bool}
* @deprecated Use the `NavDropdown` instead.
*/
navItem: CustomPropTypes.all([
React.PropTypes.bool,
function(props) {
if (props.navItem) {
deprecationWarning('navItem', 'NavDropdown component', 'https://github.com/react-bootstrap/react-bootstrap/issues/526');
}
}
]),
title: React.PropTypes.node.isRequired,
...Dropdown.propTypes,
...BootstrapMixin.propTypes
};
DropdownButton.defaultProps = {
pullRight: false,
dropup: false,
navItem: false,
noCaret: false
};
export default DropdownButton;
|
examples/src/components/CustomRenderField.js | jaakerisalu/react-select | import React from 'react';
import Select from 'react-select';
function logChange() {
console.log.apply(console, [].concat(['Select value changed:'], Array.prototype.slice.apply(arguments)));
}
var CustomRenderField = React.createClass({
displayName: 'CustomRenderField',
propTypes: {
delimiter: React.PropTypes.string,
label: React.PropTypes.string,
multi: React.PropTypes.bool,
},
renderOption (option) {
return <span style={{ color: option.hex }}>{option.label} ({option.hex})</span>;
},
renderValue (option) {
return <strong style={{ color: option.hex }}>{option.label}</strong>;
},
render () {
var ops = [
{ label: 'Red', value: 'red', hex: '#EC6230' },
{ label: 'Green', value: 'green', hex: '#4ED84E' },
{ label: 'Blue', value: 'blue', hex: '#6D97E2' }
];
return (
<div className="section">
<h3 className="section-heading">{this.props.label}</h3>
<Select
delimiter={this.props.delimiter}
multi={this.props.multi}
allowCreate={true}
placeholder="Select your favourite"
options={ops}
optionRenderer={this.renderOption}
valueRenderer={this.renderValue}
onChange={logChange} />
</div>
);
}
});
module.exports = CustomRenderField; |
server/sonar-web/src/main/js/apps/web-api/components/WebApiApp.js | lbndev/sonarqube | /*
* SonarQube
* Copyright (C) 2009-2017 SonarSource SA
* mailto:info 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.
*/
// @flow
import React from 'react';
import { Link } from 'react-router';
import { fetchWebApi } from '../../../api/web-api';
import Menu from './Menu';
import Search from './Search';
import Domain from './Domain';
import { getActionKey, isDomainPathActive } from '../utils';
import type { Domain as DomainType } from '../../../api/web-api';
import '../styles/web-api.css';
type State = {
domains: Array<DomainType>,
searchQuery: string,
showDeprecated: boolean,
showInternal: boolean
};
export default class WebApiApp extends React.PureComponent {
mounted: boolean;
scrollToAction: () => void;
state: State = {
domains: [],
searchQuery: '',
showDeprecated: false,
showInternal: false
};
componentDidMount() {
this.mounted = true;
this.scrollToAction = this.scrollToAction.bind(this);
this.fetchList();
const footer = document.getElementById('footer');
if (footer) {
footer.classList.add('search-navigator-footer');
}
}
componentDidUpdate() {
this.toggleInternalInitially();
this.scrollToAction();
}
componentWillUnmount() {
this.mounted = false;
const footer = document.getElementById('footer');
if (footer) {
footer.classList.remove('search-navigator-footer');
}
}
fetchList(cb?: () => void) {
fetchWebApi().then(domains => {
if (this.mounted) {
this.setState({ domains }, cb);
}
});
}
scrollToAction() {
const splat = this.props.params.splat || '';
this.scrollToElement(splat);
}
scrollToElement(id: string) {
const element = document.getElementById(id);
if (element) {
const rect = element.getBoundingClientRect();
const top = rect.top + window.pageYOffset - 20;
window.scrollTo(0, top);
} else {
window.scrollTo(0, 0);
}
}
toggleInternalInitially() {
const splat = this.props.params.splat || '';
const { domains, showInternal } = this.state;
if (!showInternal) {
domains.forEach(domain => {
if (domain.path === splat && domain.internal) {
this.setState({ showInternal: true });
}
domain.actions.forEach(action => {
const actionKey = getActionKey(domain.path, action.key);
if (actionKey === splat && action.internal) {
this.setState({ showInternal: true });
}
});
});
}
}
handleSearch(searchQuery: string) {
this.setState({ searchQuery });
}
handleToggleInternal() {
const splat = this.props.params.splat || '';
const { router } = this.context;
const { domains } = this.state;
const domain = domains.find(domain => isDomainPathActive(domain.path, splat));
const showInternal = !this.state.showInternal;
if (domain && domain.internal && !showInternal) {
router.push('/web_api');
}
this.setState({ showInternal });
}
handleToggleDeprecated() {
this.setState(state => ({ showDeprecated: !state.showDeprecated }));
}
render() {
const splat = this.props.params.splat || '';
const { domains, showInternal, showDeprecated, searchQuery } = this.state;
const domain = domains.find(domain => isDomainPathActive(domain.path, splat));
return (
<div className="search-navigator sticky">
<div className="search-navigator-side search-navigator-side-light" style={{ top: 30 }}>
<div className="web-api-page-header">
<Link to="/web_api/">
<h1>Web API</h1>
</Link>
</div>
<Search
showDeprecated={showDeprecated}
showInternal={showInternal}
onSearch={this.handleSearch.bind(this)}
onToggleInternal={this.handleToggleInternal.bind(this)}
onToggleDeprecated={this.handleToggleDeprecated.bind(this)}
/>
<Menu
domains={this.state.domains}
showDeprecated={showDeprecated}
showInternal={showInternal}
searchQuery={searchQuery}
splat={splat}
/>
</div>
<div className="search-navigator-workspace">
{domain &&
<Domain
key={domain.path}
domain={domain}
showDeprecated={showDeprecated}
showInternal={showInternal}
searchQuery={searchQuery}
/>}
</div>
</div>
);
}
}
WebApiApp.contextTypes = {
router: React.PropTypes.object.isRequired
};
|
packages/react-scripts/fixtures/kitchensink/src/features/syntax/AsyncAwait.js | scyankai/create-react-app | /**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
import React, { Component } from 'react';
import PropTypes from 'prop-types';
async function load() {
return [
{ id: 1, name: '1' },
{ id: 2, name: '2' },
{ id: 3, name: '3' },
{ id: 4, name: '4' },
];
}
export default class extends Component {
static propTypes = {
onReady: PropTypes.func.isRequired,
};
constructor(props) {
super(props);
this.state = { users: [] };
}
async componentDidMount() {
const users = await load();
this.setState({ users });
}
componentDidUpdate() {
this.props.onReady();
}
render() {
return (
<div id="feature-async-await">
{this.state.users.map(user =>
<div key={user.id}>
{user.name}
</div>
)}
</div>
);
}
}
|
ui/src/components/Html/index.js | LearningLocker/learninglocker | /* eslint-disable react/no-danger */
import React from 'react';
import PropTypes from 'prop-types';
import serialize from 'serialize-javascript';
import Helmet from 'react-helmet';
import config from 'ui/config';
const html = ({
protocol, // http or https
style, // raw styles to be embedded directly into the document
scripts, // scripts to be linked in the document body
state, // initial state of the client side store
children, // output of server side route render
}) => {
const head = Helmet.rewind();
return (
<html className="no-js" lang="en">
<head>
{head.base.toComponent()}
{head.title.toComponent()}
{head.meta.toComponent()}
{head.link.toComponent()}
{head.script.toComponent()}
<link rel="shortcut icon" href={`${config.assetPath}static/favicon.ico`} />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" href={`${config.assetPath}static/core.css`} />
{style && <style id="css" dangerouslySetInnerHTML={{ __html: style }} />}
</head>
<body>
<div id="content" dangerouslySetInnerHTML={{ __html: children }} />
{state && (
<script
dangerouslySetInnerHTML={{ __html: `
window.__data=${serialize(state)};
window.rootUrl='${protocol}://${config.host}:${config.port}';
` }}
charSet="UTF-8" />
)}
{scripts && scripts.map(script => <script key={script} src={script} />)}
</body>
</html>
);
};
html.propTypes = {
protocol: PropTypes.string,
style: PropTypes.string,
scripts: PropTypes.arrayOf(PropTypes.string.isRequired),
state: PropTypes.object,
children: PropTypes.string,
};
export default html;
|
src/DatePicker/CalendarMonth.js | pradel/material-ui | import React from 'react';
import {isBetweenDates, isEqualDate, getWeekArray} from './dateUtils';
import DayButton from './DayButton';
import ClearFix from '../internal/ClearFix';
class CalendarMonth extends React.Component {
static propTypes = {
autoOk: React.PropTypes.bool,
displayDate: React.PropTypes.object.isRequired,
firstDayOfWeek: React.PropTypes.number,
maxDate: React.PropTypes.object,
minDate: React.PropTypes.object,
onDayTouchTap: React.PropTypes.func,
selectedDate: React.PropTypes.object.isRequired,
shouldDisableDate: React.PropTypes.func,
};
isSelectedDateDisabled() {
return this.selectedDateDisabled;
}
getWeekElements() {
const weekArray = getWeekArray(this.props.displayDate, this.props.firstDayOfWeek);
return weekArray.map((week, i) => {
return (
<ClearFix key={i}>
{this.getDayElements(week, i)}
</ClearFix>
);
}, this);
}
getDayElements(week, i) {
return week.map((day, j) => {
const isSameDate = isEqualDate(this.props.selectedDate, day);
const disabled = this.shouldDisableDate(day);
const selected = !disabled && isSameDate;
if (isSameDate) {
if (disabled) {
this.selectedDateDisabled = true;
} else {
this.selectedDateDisabled = false;
}
}
return (
<DayButton
key={`db${(i + j)}`}
date={day}
onTouchTap={this.handleTouchTap}
selected={selected}
disabled={disabled}
/>
);
}, this);
}
handleTouchTap = (event, date) => {
if (this.props.onDayTouchTap) this.props.onDayTouchTap(event, date);
};
shouldDisableDate(day) {
if (day === null) return false;
let disabled = !isBetweenDates(day, this.props.minDate, this.props.maxDate);
if (!disabled && this.props.shouldDisableDate) disabled = this.props.shouldDisableDate(day);
return disabled;
}
render() {
const styles = {
lineHeight: '32px',
textAlign: 'center',
padding: '16px 14px 0 14px',
};
return (
<div style={styles}>
{this.getWeekElements()}
</div>
);
}
}
export default CalendarMonth;
|
frontend/src/RecordsTable.js | paulobichara/customers | import React, { Component } from 'react';
import Griddle from 'griddle-react';
export default class RecordsTable extends Component {
constructor(props) {
super(props);
this.state = {
"results": [],
"filter" : "",
"currentPage": 0,
"maxPages": 0,
"externalResultsPerPage": 5,
"externalSortColumn": "id",
"externalSortAscending": true
};
this.setPage = this.setPage.bind(this);
this.changeSort = this.changeSort.bind(this);
this.setFilter = this.setFilter.bind(this);
this.setPageSize = this.setPageSize.bind(this);
}
fetchExternalData(filter, currentPage, resultsPerPage, sortColumn, sortAsc) {
const baseUrl = "https://localhost/customers";
const url = baseUrl + "/api/rest/users"
+ "?filter=" + encodeURIComponent(filter ? filter : "")
+ "&resultsPerPage=" + resultsPerPage
+ "¤tPage=" + currentPage
+ "&sortField=" + sortColumn
+ "&sortAscending=" + sortAsc;
const casUrl = baseUrl + "/cas/login?service=";
fetch(url, {
credentials: 'include'
})
.then(result=> {
if (result.url && result.url.indexOf(casUrl) === 0) {
window.location.href = casUrl + encodeURIComponent(window.location.href);
return false;
} else {
return result.json();
}
})
.then(response=>this.setState({
"filter" : response.filter,
"results" : response.results,
"maxPages" : response.numberOfPages,
"externalResultsPerPage" : response.resultsPerPage,
"currentPage" : response.currentPage,
"externalSortColumn" : response.sortField,
"externalSortAscending" : response.sortAscending }));
}
componentDidMount() {
this.fetchExternalData(
this.state.filter,
this.state.currentPage,
this.state.externalResultsPerPage,
this.state.externalSortColumn,
this.state.externalSortAscending);
}
//what page is currently viewed
setPage(index) {
//This should interact with the data source to get the page at the given index
index = index > this.state.maxPages ? this.state.maxPages : index < 0 ? 0 : index;
this.fetchExternalData(
this.state.filter,
index,
this.state.externalResultsPerPage,
this.state.externalSortColumn,
this.state.externalSortAscending);
}
//this changes whether data is sorted in ascending or descending order
changeSort(sort, sortAscending) {
this.fetchExternalData(
this.state.filter,
this.state.currentPage,
this.state.externalResultsPerPage,
sort,
sortAscending);
}
//this method handles the filtering of the data
setFilter(filter) {
this.fetchExternalData(
filter,
this.state.currentPage,
this.state.externalResultsPerPage,
this.state.externalSortColumn,
this.state.externalSortAscending);
}
//this method handles determining the page size
setPageSize(size) {
this.fetchExternalData(
this.state.filter,
this.state.currentPage,
size,
this.state.externalSortColumn,
this.state.externalSortAscending);
}
render() {
return (
<Griddle
tableClassName={'table table-bordered table-striped table-hover'}
useGriddleStyles={true}
showFilter={true}
showSettings={true}
settingsToggleClassName='btn btn-default'
useExternal={true} externalSetPage={this.setPage}
externalChangeSort={this.changeSort} externalSetFilter={this.setFilter}
externalSetPageSize={this.setPageSize} externalMaxPage={this.state.maxPages}
externalCurrentPage={this.state.currentPage} results={this.state.results}
resultsPerPage={this.state.externalResultsPerPage}
externalSortColumn={this.state.externalSortColumn}
externalSortAscending={this.state.externalSortAscending}/>
);
}
} |
src/components/project.js | pritchardtw/ReactPersonalSite | import React, { Component } from 'react';
import HomeTab from './hometab';
import PictureViewer from './pictureviewer';
export default class Project extends Component {
render() {
const { title, description, images } = this.props;
const style = (images.length > 1 ? "rowofthree" : '');
return(
<div className="project">
<HomeTab />
<h1>{title}</h1>
{
this.props.link ? <a href={this.props.link} target="_blank">Check it out here!</a> : <a></a>
}
<p>
{description}
</p>
<br/>
<PictureViewer images={images} pictureStyle={style}/>
</div>
);
}
}
|
src/icons/CreateNewFolderIcon.js | kiloe/ui | import React from 'react';
import Icon from '../Icon';
export default class CreateNewFolderIcon extends Icon {
getSVG(){return <svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 48 48"><path d="M40 12H24l-4-4H8c-2.21 0-3.98 1.79-3.98 4L4 36c0 2.21 1.79 4 4 4h32c2.21 0 4-1.79 4-4V16c0-2.21-1.79-4-4-4zm-2 16h-6v6h-4v-6h-6v-4h6v-6h4v6h6v4z"/></svg>;}
}; |
docs/src/app/app.js | lawrence-yu/material-ui | import React from 'react';
import {render} from 'react-dom';
import {Router, useRouterHistory} from 'react-router';
import AppRoutes from './AppRoutes';
import injectTapEventPlugin from 'react-tap-event-plugin';
import {createHashHistory} from 'history';
// Helpers for debugging
window.React = React;
window.Perf = require('react-addons-perf');
// Needed for onTouchTap
// http://stackoverflow.com/a/34015469/988941
injectTapEventPlugin();
/**
* Render the main app component. You can read more about the react-router here:
* https://github.com/reactjs/react-router/blob/master/docs/guides/README.md
*/
render(
<Router
history={useRouterHistory(createHashHistory)({queryKey: false})}
onUpdate={() => window.scrollTo(0, 0)}
>
{AppRoutes}
</Router>
, document.getElementById('app'));
|
sandbox/src/components/ScanIcon.js | coreaps/public | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from 'material-ui/SvgIcon';
let ActionScanBarcode = (props) => (
<SvgIcon {...props}>
<path transform="translate(2, -3)" d="M0 4h4v20h-4zM6 4h2v20h-2zM10 4h2v20h-2zM16 4h2v20h-2zM24 4h2v20h-2zM30 4h2v20h-2zM20 4h1v20h-1zM14 4h1v20h-1zM27 4h1v20h-1zM0 26h2v2h-2zM6 26h2v2h-2zM10 26h2v2h-2zM20 26h2v2h-2zM30 26h2v2h-2zM24 26h4v2h-4zM14 26h4v2h-4z"/>
</SvgIcon>
);
ActionScanBarcode = pure(ActionScanBarcode);
ActionScanBarcode.displayName = 'ActionAccessibility';
ActionScanBarcode.muiName = 'SvgIcon';
export default ActionScanBarcode;
|
containers/AddTodo.js | FlorianEdelmaier/SimpleReduxDemo | import React from 'react';
class AddTodo extends React.Component {
render() {
return (
<div>
<input type='text' ref={(node) => this.input = node} />
<button onClick={() => this.handleClick()}>
Add
</button>
</div>
);
}
handleClick() {
let text = this.input.value;
this.props.onAddClick(text);
this.input.value = '';
}
}
AddTodo.propTypes = {
onAddClick: React.PropTypes.func.isRequired
};
export default AddTodo;
|
views/prompt.js | kaze13/black-screen | import _ from 'lodash';
import React from 'react';
import Autocomplete from './autocomplete';
import DecorationToggle from './decoration_toggle';
// TODO: Make sure we only update the view when the model changes.
export default React.createClass({
getInitialState() {
return {
suggestions: [],
selectedAutocompleteIndex: 0,
latestKeyCode: null,
caretPosition: 0,
caretOffset: 0
}
},
getInputNode() {
// TODO: Try to cache.
return this.refs.command.getDOMNode()
},
componentWillMount() {
var keysDownStream = createEventHandler();
var [passThroughKeys, promptKeys] = keysDownStream.partition(_ => this.props.status == 'in-progress');
passThroughKeys
.filter(_.negate(isMetaKey))
.map(stopBubblingUp)
.forEach(event => this.props.invocation.write(event));
var meaningfulKeysDownStream = promptKeys.filter(isDefinedKey).map(stopBubblingUp);
var [navigateAutocompleteStream, navigateHistoryStream] = meaningfulKeysDownStream
.filter(event => keys.goDown(event) || keys.goUp(event))
.partition(this.autocompleteIsShown);
keysDownStream.filter(_.negate(isCommandKey))
.forEach(event => this.setState({latestKeyCode: event.keyCode}));
promptKeys.filter(keys.enter).forEach(this.execute);
meaningfulKeysDownStream.filter(this.autocompleteIsShown)
.filter(keys.tab)
.forEach(this.selectAutocomplete);
meaningfulKeysDownStream.filter(keys.deleteWord).forEach(this.deleteWord);
navigateHistoryStream.forEach(this.navigateHistory);
navigateAutocompleteStream.forEach(this.navigateAutocomplete);
this.handlers = {
onKeyDown: keysDownStream
};
},
componentDidMount() {
$(this.getDOMNode()).fixedsticky();
$('.fixedsticky-dummy').remove();
this.getInputNode().focus();
},
componentDidUpdate(prevProps, prevState) {
var inputNode = this.getInputNode();
inputNode.innerText = this.getText();
if (prevState.caretPosition != this.state.caretPosition || prevState.caretOffset != this.state.caretOffset) {
setCaretPosition(inputNode, this.state.caretPosition);
}
if (prevState.caretPosition != this.state.caretPosition) {
this.setState({caretOffset: $(inputNode).caret('offset')});
}
scrollToBottom();
},
execute() {
if (!this.isEmpty()) {
// Timeout prevents two-line input on cd.
setTimeout(() => this.props.prompt.execute(), 0);
}
},
getText() {
return this.props.prompt.buffer.toString();
},
setText(text) {
this.props.invocation.setPromptText(text);
this.setState({caretPosition: this.props.prompt.buffer.cursor.column()});
},
isEmpty() {
return this.getText().replace(/\s/g, '').length == 0;
},
navigateHistory(event) {
if (keys.goUp(event)) {
var prevCommand = this.props.prompt.history.getPrevious();
if (typeof prevCommand != 'undefined') {
this.setText(prevCommand);
}
} else {
this.setText(this.props.prompt.history.getNext() || '');
}
},
navigateAutocomplete(event) {
if (keys.goUp(event)) {
var index = Math.max(0, this.state.selectedAutocompleteIndex - 1)
} else {
index = Math.min(this.state.suggestions.length - 1, this.state.selectedAutocompleteIndex + 1)
}
this.setState({selectedAutocompleteIndex: index});
},
selectAutocomplete() {
var state = this.state;
const suggestion = state.suggestions[state.selectedAutocompleteIndex];
this.props.prompt.replaceCurrentLexeme(suggestion);
if (!suggestion.partial) {
this.props.prompt.buffer.write(' ');
}
this.props.prompt.getSuggestions().then(suggestions => {
this.setState({
suggestions: suggestions,
selectedAutocompleteIndex: 0,
caretPosition: this.props.prompt.buffer.cursor.column()
})
}
);
},
deleteWord() {
// TODO: Remove the word under the caret instead of the last one.
var newCommand = this.props.prompt.getWholeCommand().slice(0, -1).join(' ');
if (newCommand.length) {
newCommand += ' ';
}
this.setText(newCommand);
},
handleInput(event) {
this.setText(event.target.innerText);
//TODO: make it a stream.
this.props.prompt.getSuggestions().then(suggestions =>
this.setState({
suggestions: suggestions,
selectedAutocompleteIndex: 0,
caretPosition: this.props.prompt.buffer.cursor.column()
})
);
},
handleScrollToTop(event) {
stopBubblingUp(event);
const offset = $(this.props.invocationView.getDOMNode()).offset().top - 10;
$('html, body').animate({ scrollTop: offset }, 300);
},
handleKeyPress(event) {
if (this.props.status == 'in-progress') {
stopBubblingUp(event);
}
},
showAutocomplete() {
//TODO: use streams.
return this.refs.command &&
this.state.suggestions.length &&
this.props.status == 'not-started' && !_.contains([13, 27], this.state.latestKeyCode);
},
autocompleteIsShown() {
return this.refs.autocomplete;
},
render() {
var classes = ['prompt-wrapper', 'fixedsticky', this.props.status].join(' ');
if (this.showAutocomplete()) {
var autocomplete = <Autocomplete suggestions={this.state.suggestions}
caretOffset={this.state.caretOffset}
selectedIndex={this.state.selectedAutocompleteIndex}
ref="autocomplete"/>;
}
if (this.props.invocationView.state.canBeDecorated) {
var decorationToggle = <DecorationToggle invocation={this.props.invocationView}/>;
}
if (this.props.invocation.hasOutput()) {
var scrollToTop = <a href="#" className="scroll-to-top" onClick={this.handleScrollToTop}>
<i className="fa fa-long-arrow-up"></i>
</a>;
}
return (
<div className={classes}>
<div className="prompt-decoration">
<div className="arrow"/>
</div>
<div className="prompt"
onKeyDown={this.handlers.onKeyDown}
onInput={this.handleInput}
onKeyPress={this.handleKeyPress}
type="text"
ref="command"
contentEditable="true"/>
{autocomplete}
<div className="actions">
{decorationToggle}
{scrollToTop}
</div>
</div>
)
}
});
|
app/containers/TravelPage/index.js | olivia-leach/jaylivia-react | import React from 'react';
import { Link } from 'react-router'
const Scroll = require('react-scroll');
const ScrollLink = Scroll.Link;
export default class HotelsPage extends React.PureComponent {
render() {
return (
<article id="travel">
<h1 className="section-header">Travel & Transportation</h1>
<div className="content-wrapper travel">
<div className='travel-block'>
<h1>Air Travel</h1>
<p>
The closest airports are Stewart Newburgh International and Albany Airport, both about an hour from Woodstock.
Another great small option is the Westchester County Airport, which is less than 2 hours away.
You can also fly into the three major airports in the New York City area: JFK, LaGuardia, or Newark.
The wedding is about 2 1/2 hours from NYC and 3 1/2 hours from Boston via car.
</p>
</div>
<div className='travel-block'>
<h1>Getting Around</h1>
<p>
We recommend renting a car (or finding a friend who already has one) and enjoying the scenic drive from any of the airports along the Hudson River to the Catskills.
There is <Link to='thingstodo'>so much to do</Link> in the region and having a car is the best way to explore.
If you rent a car and will be driving yourself to your accommodations and/or the venue, we recommend loading up any directions you will need ahead of time.
Service can be spotty!
</p>
</div>
<div className='travel-block'>
<h1>No car? Here are some other options:</h1>
<ul>
<li>
<div className='flex'>
<h4>Trailway Bus</h4>
</div>
<h5>Port Authority Bus Terminal to Woodstock, NY</h5>
<p>
This trip takes two hours and thirty minutes and costs $29.
The Woodstock station is very close to the venue and area lodging (still requires a taxi ride, however).
Taxi information is available below.
Tickets available at <a target='_blank' href="http://trailwaysny.com">trailwaysny.com</a>.
</p>
</li>
<li>
<h4>Amtrak</h4>
<h5>Penn Station to Rhinecliff, NY</h5>
<p>
This trip takes 1 hour and 45 minutes and costs $28, but it's another 40 minutes by taxi from the Rhinecliff station to the wedding venue and area lodging.
Tickets available at <a target='_blank' href="http://amtrak.com">amtrak.com</a>.
</p>
</li>
</ul>
</div>
<div className='travel-block'>
<h1>Taxis and Local Transport</h1>
<p>
If you want to explore the area without your own car, one of the taxi companies below can take you around.
These companies are small with limited fleets, however, so be sure to call ahead the day before to reserve the ride(s) you need.
In very exciting news, <span className='bold'>Lyft</span> and <span className='bold'>Uber</span> are now options in the Hudson Valley!
Just be prepared to wait a bit longer than you normally do in a big city.
</p>
<br />
<ul>
<li>
<h4>Woodstock Town Car</h4>
<a target='_blank' href='http://woodstocktowncar.com'>woodstocktowncar.com</a>
<p>(845) 679-6656</p>
</li>
<li>
<h4>Kingston Kab</h4>
<a tareget='_blank' href='http://kingstonkabs.com'>kingstonkabs.com</a>
<p>(845) 331-TAXI</p>
</li>
</ul>
</div>
<div className='travel-block'>
<h1>Wedding Transportation</h1>
<p>
We are providing bus transportation to the wedding from the following locations: Kingston Best Western, The Lodge, and <a target='_blank' href='https://goo.gl/maps/hpymfA4abhy' className='rsvp-link'>downtown Woodstock</a>.
School buses will be leaving these locations at 4:15pm and will return to the same locations after the reception.
If you are staying elsewhere you will need to arrange your own transportation to the venue.
Parking is available on site, but it is somewhat limited, so we encourage carpooling!
</p>
</div>
</div>
</article>
);
}
}
|
containers/live/CommonCitys.js | DemocraciaEnRed/democraciaenred.github.io | import React from 'react';
function CommonCitys () {
return(
<React.Fragment>
<div className="common-citys">
<div className="container-bulma">
<h1>Incubadora de Ciudades Comunes</h1>
<div className="after-playback">
<div className="videoWrapper">
<iframe
width="853"
height="480"
src={`https://www.youtube.com/embed/NmH6-CvpK24`}
frameborder="0"
allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture"
allowfullscreen>
</iframe>
</div>
</div>
<p>
<strong>#VolverALaCalle</strong> busca soluciones replicables, de bajo costo y alto impacto para reactivar los espacios públicos con distanciamiento físico y recuperar la confianza perdida en la vida urbana.<br/>
En el marco del programa de incubación los proyectos ganadores del #IDEATÓN, Agustín Frizzera, Director Ejecutivo de Democracia En Red y Coordinador de Causas Comunes, charló sobre Gobierno Abierto y Nuevas Tecnologías.<br/>
Conocé más en <a href="http://ciudadescomunes.org">http://ciudadescomunes.org</a>
</p>
</div>
<div className="container-bulma">
<h1>
<span>El impacto de la crisis actual en las decisiones de las ciudades</span>
</h1>
<div className="after-playback">
<div className="videoWrapper">
<iframe
width="853"
height="480"
src={`https://www.youtube.com/embed/jMs-S-MCdyg`}
frameborder="0"
allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture"
allowfullscreen>
</iframe>
</div>
</div>
<p>
<span>
<strong>Maria Buhigas</strong> Regidora del Ayuntamiento de Barcelona<br/>
Modera: <br/>Agustin Frizzera - Democracia en red <br/><br/>
</span>
</p>
</div>
</div>
</React.Fragment>
)
}
export default CommonCitys; |
src/client/pages/popular-languages/PopularLanguages.js | developersdo/opensource | import React from 'react'
import { map } from 'lodash'
import store from '~/store/store'
import Loading from '~/components/loading/Loading'
const style = {
position: {
width: 40,
display: 'inline-block',
fontSize: 18,
},
name: {
fontSize: 22,
marginRight: 10,
},
progress: {
height: 10,
}
}
class AboutPopularLanguages extends React.Component {
state = {
repos: [],
loading: true
}
componentDidMount() {
store.getRepos().then((response) => {
this.setState({
repos: response.items,
loading: !response.ready
})
})
}
render() {
const { repos, loading } = this.state
if (loading) {
return <Loading />
}
// Count languages for each repos.
const totals = repos.reduce((total, repo) => {
repo.languages.forEach((lang) => {
if (!total[lang.name]) {
total[lang.name] = 0
}
total[lang.name]++
})
return total
}, {})
// Create language stats.
const languages = map(totals, (total, name) => ({
name,
total,
percentage: ((total / repos.length) * 100).toFixed(2)
}))
languages.sort((a, b) => b.total - a.total)
const topLanguages = languages.slice(0, 10)
return (
<div>
<h4>Popular Languages</h4>
{topLanguages.map(({name, total, percentage}, index) => (
<div key={name}>
<span className="grey-text text-darken-3" style={style.position}>#{index + 1}</span>
<span style={style.name}>{name}</span>
<strong className="grey-text text-darken-2">{percentage}%</strong>
<div className="progress blue lighten-4" style={style.progress}>
<div className="determinate blue darken-2" style={{ width: `${percentage}%` }}></div>
</div>
</div>
))}
</div>
)
}
}
export default AboutPopularLanguages
|
src/scripts/components/status/Status.component.js | ModuloM/kodokojo-ui | /**
* Kodo Kojo - Software factory done right
* Copyright © 2016 Kodo Kojo ([email protected])
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import React from 'react'
import { intlShape, injectIntl } from 'react-intl'
// component
import statusTheme from './status.scss'
import { getStatusByState } from '../../services/param.service'
export class Status extends React.Component {
static propTypes = {
intl: intlShape.isRequired,
state: React.PropTypes.string
}
render() {
const { state } = this.props
const { formatMessage } = this.props.intl
const status = getStatusByState(state)
return (
<img
className={ statusTheme.status }
onLoad={ (e) => e.target.classList.add(statusTheme['status--loaded']) }
src={ status.image }
title={ formatMessage({ id: `status-${status.label}-label` }) }
/>
)
}
}
export default injectIntl(Status)
|
frontend/app_v2/src/common/categoryIcons/BearPaw.js | First-Peoples-Cultural-Council/fv-web-ui | import React from 'react'
import PropTypes from 'prop-types'
/**
* @summary BearPaw
* @component
*
* @param {object} props
*
* @returns {node} jsx markup
*/
function BearPaw({ styling }) {
return (
<svg className={styling} xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 100 100" stroke="currentColor">
<title>BearPaw</title>
<path d="M50.522,88c2.232,0-3.799,4.332,12.844,5.175c16.643,0.842,16.307-23.582,10.053-27.793 c-6.255-4.211-2.345-5.534-6.479-11.43c-4.133-5.896-16.418-5.293-16.418-5.293s-12.307-0.603-16.446,5.293 c-4.14,5.896-0.224,7.219-6.488,11.43c-6.264,4.211-6.601,28.635,10.068,27.793C54.325,92.332,48.285,88,50.522,88z" />
<path d="M36.828,93.446c-0.001,0-0.001,0-0.002,0c-8.234-0.002-11.354-6.207-12.482-9.906c-2.117-6.944-0.607-15.87,3.105-18.365 c3.492-2.348,3.731-3.719,4.063-5.618c0.247-1.415,0.555-3.176,2.361-5.748c3.529-5.026,12.899-5.417,15.687-5.417 c0.596,0,0.952,0.017,0.975,0.018c0-0.001,0.355-0.018,0.951-0.018c2.783,0,12.138,0.391,15.661,5.417 c1.804,2.572,2.11,4.334,2.357,5.749c0.331,1.898,0.57,3.271,4.056,5.617c3.713,2.5,5.218,11.435,3.097,18.384 c-1.166,3.816-4.479,10.292-13.302,9.866c-12.415-0.629-12.452-3.236-12.471-4.638c-0.007-0.499-0.016-0.537-0.36-0.537 c-0.346,0-0.354,0.038-0.362,0.538c-0.021,1.4-0.06,4.008-12.491,4.637C37.383,93.438,37.104,93.446,36.828,93.446z M49.559,48.891 c-2.727,0-11.888,0.375-15.278,5.205c-1.742,2.481-2.026,4.11-2.277,5.547c-0.339,1.945-0.608,3.481-4.276,5.946 c-3.555,2.391-4.968,11.043-2.906,17.806c1.087,3.566,4.092,9.55,12.003,9.552c0.001,0,0.002,0,0.002,0 c0.268,0,0.539-0.007,0.816-0.021c11.964-0.604,12-2.995,12.017-4.145c0.007-0.459,0.015-1.03,0.862-1.03 c0.845,0,0.854,0.571,0.859,1.03c0.017,1.148,0.051,3.54,11.997,4.145c0.277,0.015,0.55,0.021,0.817,0.021 c7.892,0,10.894-5.973,11.98-9.533c2.066-6.768,0.658-15.43-2.897-17.824c-3.662-2.465-3.931-4.001-4.27-5.946 c-0.25-1.437-0.534-3.065-2.274-5.547c-3.385-4.829-12.529-5.205-15.251-5.205c-0.598,0-0.946,0.017-0.95,0.017 C50.507,48.908,50.157,48.891,49.559,48.891z" />
<ellipse cx="50" cy="27.306" rx="7.833" ry="11.694" />
<path d="M50,39.25c-4.457,0-8.083-5.358-8.083-11.944S45.543,15.362,50,15.362s8.083,5.358,8.083,11.944S54.457,39.25,50,39.25z M50,15.862c-4.182,0-7.583,5.134-7.583,11.444S45.818,38.75,50,38.75s7.583-5.134,7.583-11.444S54.182,15.862,50,15.862z" />
<polyline points="47.986,16.833 50,8.698 51.79,16.833 " />
<polygon points="48.229,16.893 47.743,16.772 50.014,7.6 52.034,16.779 51.546,16.886 49.986,9.796 " />
<ellipse
transform="matrix(0.9478 -0.3189 0.3189 0.9478 -10.2543 10.6704)"
cx="27.46"
cy="36.651"
rx="6.5"
ry="11.5"
/>
<path d="M29.905,47.999c-3.332,0-7.05-3.867-8.842-9.195c-2.066-6.141-0.877-12.102,2.65-13.289c0.415-0.14,0.853-0.21,1.302-0.21 c3.332,0,7.05,3.867,8.842,9.195c2.066,6.141,0.877,12.102-2.65,13.289C30.792,47.928,30.354,47.999,29.905,47.999z M25.015,25.804 c-0.395,0-0.779,0.062-1.143,0.184c-3.266,1.099-4.314,6.777-2.336,12.656c1.726,5.13,5.246,8.854,8.369,8.854 c0.395,0,0.779-0.062,1.143-0.184c3.266-1.099,4.314-6.777,2.336-12.656C31.657,29.528,28.138,25.804,25.015,25.804z" />
<path d="M22.18,29.799c0,0-0.548-8.964,0.875-9.782c0,0,1.322,9.527,2.319,9.451" />
<path d="M21.93,29.814c-0.093-1.522-0.482-9.162,1-10.014l0.321-0.185l0.051,0.367c0.587,4.229,1.552,8.964,2.089,9.241 l0.002,0.494c-0.007,0-0.015,0-0.022,0c-0.967,0-1.871-4.811-2.484-9.1c-0.648,1.434-0.642,6.158-0.458,9.166L21.93,29.814z" />
<path d="M22.722,56.137c1.803,4.698,0.809,9.231-2.22,10.124c-3.028,0.894-6.945-2.19-8.748-6.888 c-1.803-4.698-0.809-9.231,2.221-10.125C17.003,48.355,20.919,51.439,22.722,56.137z" />
<path d="M19.414,66.665c-2.972,0-6.292-3.029-7.893-7.202c-1.155-3.011-1.224-6.065-0.185-8.17 c0.578-1.169,1.466-1.959,2.568-2.284c0.37-0.109,0.759-0.164,1.159-0.164c2.972,0,6.291,3.029,7.893,7.202 c1.155,3.012,1.224,6.065,0.184,8.171c-0.577,1.169-1.465,1.958-2.566,2.283C20.204,66.609,19.814,66.665,19.414,66.665z M15.063,49.345c-0.352,0-0.694,0.048-1.017,0.144c-0.965,0.285-1.747,0.985-2.261,2.026c-0.979,1.981-0.903,4.886,0.203,7.769 c1.53,3.987,4.653,6.882,7.426,6.882c0.352,0,0.694-0.049,1.018-0.145c0.964-0.284,1.746-0.983,2.26-2.024 c0.979-1.981,0.904-4.887-0.203-7.77C20.958,52.239,17.835,49.345,15.063,49.345z" />
<path d="M12.539,52.407c0,0-0.487-6.996,0.779-7.634c0,0,1.177,7.435,2.065,7.376" />
<path d="M12.289,52.425c-0.083-1.196-0.431-7.196,0.917-7.875l0.306-0.154l0.054,0.338c0.517,3.268,1.366,6.939,1.834,7.17l0,0.494 c-0.007,0.001-0.014,0.001-0.02,0.001c-0.869,0.001-1.674-3.71-2.223-7.055c-0.511,1.135-0.54,4.59-0.369,7.045L12.289,52.425z" />
<path d="M66.913,34.578c-1.979,6.02-0.889,11.828,2.435,12.973s7.622-2.808,9.601-8.826c1.979-6.02,0.887-11.828-2.437-12.973 C73.189,24.607,68.891,28.56,66.913,34.578z" />
<path d="M70.542,47.998L70.542,47.998c-0.44,0-0.869-0.071-1.275-0.211c-3.447-1.187-4.61-7.148-2.591-13.287 c1.751-5.329,5.386-9.196,8.643-9.196c0.439,0,0.868,0.071,1.274,0.211c3.448,1.188,4.611,7.149,2.593,13.288 C77.435,44.131,73.799,47.998,70.542,47.998z M75.318,25.804c-3.048,0-6.482,3.723-8.168,8.852 c-1.934,5.881-0.912,11.56,2.278,12.658c0.354,0.122,0.729,0.184,1.113,0.184c3.047,0,6.482-3.722,8.169-8.852 c1.934-5.88,0.91-11.559-2.28-12.659C76.076,25.866,75.702,25.804,75.318,25.804z" />
<path d="M78.088,29.799c0,0,0.534-8.964-0.854-9.782c0,0-1.292,9.527-2.267,9.451" />
<path d="M78.338,29.813l-0.5-0.029c0.179-2.996,0.186-7.69-0.438-9.147c-0.604,4.32-1.505,9.176-2.453,9.08l0.039-0.498 c0.491-0.287,1.414-4.923,1.999-9.236l0.051-0.373l0.324,0.191C78.808,20.653,78.428,28.292,78.338,29.813z" />
<path d="M78.396,56.137c-1.641,4.698-0.735,9.231,2.022,10.124c2.756,0.894,6.323-2.19,7.965-6.888 c1.642-4.698,0.736-9.231-2.021-10.124C83.603,48.355,80.037,51.44,78.396,56.137z" />
<path d="M81.408,66.665L81.408,66.665c-0.368,0-0.728-0.057-1.067-0.166c-0.948-0.308-1.728-1.03-2.254-2.09 c-1.03-2.074-1.003-5.276,0.072-8.354c1.461-4.178,4.493-7.209,7.211-7.209c0.368,0,0.728,0.056,1.068,0.166 c0.948,0.307,1.728,1.03,2.254,2.089c1.03,2.075,1.002,5.276-0.073,8.354C87.159,63.633,84.127,66.665,81.408,66.665z M85.37,49.345c-2.513,0-5.347,2.891-6.738,6.874c-1.032,2.957-1.07,6.01-0.098,7.968c0.466,0.937,1.144,1.572,1.961,1.836 c0.29,0.095,0.598,0.143,0.913,0.143c2.513,0,5.347-2.892,6.738-6.874c1.033-2.956,1.07-6.009,0.099-7.968 c-0.465-0.937-1.144-1.572-1.961-1.836C85.993,49.393,85.687,49.345,85.37,49.345z" />
<path d="M87.668,52.407c0,0,0.444-6.996-0.709-7.634c0,0-1.071,7.435-1.88,7.376" />
<path d="M87.917,52.423l-0.498-0.031c0.152-2.403,0.132-5.762-0.303-6.972c-0.694,4.633-1.379,6.98-2.035,6.98 c-0.007,0-0.014,0-0.021-0.001l0.037-0.498c0.377-0.261,1.147-3.924,1.614-7.163l0.051-0.358l0.317,0.175 C88.31,45.234,87.993,51.229,87.917,52.423z" />
</svg>
)
}
// PROPTYPES
const { string } = PropTypes
BearPaw.propTypes = {
styling: string,
}
export default BearPaw
|
src/svg-icons/content/remove-circle-outline.js | ngbrown/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let ContentRemoveCircleOutline = (props) => (
<SvgIcon {...props}>
<path d="M7 11v2h10v-2H7zm5-9C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8z"/>
</SvgIcon>
);
ContentRemoveCircleOutline = pure(ContentRemoveCircleOutline);
ContentRemoveCircleOutline.displayName = 'ContentRemoveCircleOutline';
ContentRemoveCircleOutline.muiName = 'SvgIcon';
export default ContentRemoveCircleOutline;
|
src/components/dumb/Base/Input/index.js | apedyashev/reactjs-jobs-aggregator | // libs
import React from 'react';
// components
import TextField from 'material-ui/TextField';
export default function Input(props) {
return <TextField {...props} />;
}
|
src/svg-icons/image/photo-library.js | manchesergit/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let ImagePhotoLibrary = (props) => (
<SvgIcon {...props}>
<path d="M22 16V4c0-1.1-.9-2-2-2H8c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2zm-11-4l2.03 2.71L16 11l4 5H8l3-4zM2 6v14c0 1.1.9 2 2 2h14v-2H4V6H2z"/>
</SvgIcon>
);
ImagePhotoLibrary = pure(ImagePhotoLibrary);
ImagePhotoLibrary.displayName = 'ImagePhotoLibrary';
ImagePhotoLibrary.muiName = 'SvgIcon';
export default ImagePhotoLibrary;
|
app/javascript/mastodon/features/ui/components/report_modal.js | glitch-soc/mastodon | import React from 'react';
import { connect } from 'react-redux';
import { submitReport } from 'mastodon/actions/reports';
import { expandAccountTimeline } from 'mastodon/actions/timelines';
import { fetchRules } from 'mastodon/actions/rules';
import PropTypes from 'prop-types';
import ImmutablePropTypes from 'react-immutable-proptypes';
import { makeGetAccount } from 'mastodon/selectors';
import { defineMessages, FormattedMessage, injectIntl } from 'react-intl';
import { OrderedSet } from 'immutable';
import ImmutablePureComponent from 'react-immutable-pure-component';
import IconButton from 'mastodon/components/icon_button';
import Category from 'mastodon/features/report/category';
import Statuses from 'mastodon/features/report/statuses';
import Rules from 'mastodon/features/report/rules';
import Comment from 'mastodon/features/report/comment';
import Thanks from 'mastodon/features/report/thanks';
const messages = defineMessages({
close: { id: 'lightbox.close', defaultMessage: 'Close' },
});
const makeMapStateToProps = () => {
const getAccount = makeGetAccount();
const mapStateToProps = (state, { accountId }) => ({
account: getAccount(state, accountId),
});
return mapStateToProps;
};
export default @connect(makeMapStateToProps)
@injectIntl
class ReportModal extends ImmutablePureComponent {
static propTypes = {
accountId: PropTypes.string.isRequired,
statusId: PropTypes.string,
dispatch: PropTypes.func.isRequired,
intl: PropTypes.object.isRequired,
account: ImmutablePropTypes.map.isRequired,
};
state = {
step: 'category',
selectedStatusIds: OrderedSet(this.props.statusId ? [this.props.statusId] : []),
comment: '',
category: null,
selectedRuleIds: OrderedSet(),
forward: true,
isSubmitting: false,
isSubmitted: false,
};
handleSubmit = () => {
const { dispatch, accountId } = this.props;
const { selectedStatusIds, comment, category, selectedRuleIds, forward } = this.state;
this.setState({ isSubmitting: true });
dispatch(submitReport({
account_id: accountId,
status_ids: selectedStatusIds.toArray(),
comment,
forward,
category,
rule_ids: selectedRuleIds.toArray(),
}, this.handleSuccess, this.handleFail));
};
handleSuccess = () => {
this.setState({ isSubmitting: false, isSubmitted: true, step: 'thanks' });
};
handleFail = () => {
this.setState({ isSubmitting: false });
};
handleStatusToggle = (statusId, checked) => {
const { selectedStatusIds } = this.state;
if (checked) {
this.setState({ selectedStatusIds: selectedStatusIds.add(statusId) });
} else {
this.setState({ selectedStatusIds: selectedStatusIds.remove(statusId) });
}
};
handleRuleToggle = (ruleId, checked) => {
const { selectedRuleIds } = this.state;
if (checked) {
this.setState({ selectedRuleIds: selectedRuleIds.add(ruleId) });
} else {
this.setState({ selectedRuleIds: selectedRuleIds.remove(ruleId) });
}
}
handleChangeCategory = category => {
this.setState({ category });
};
handleChangeComment = comment => {
this.setState({ comment });
};
handleChangeForward = forward => {
this.setState({ forward });
};
handleNextStep = step => {
this.setState({ step });
};
componentDidMount () {
const { dispatch, accountId } = this.props;
dispatch(expandAccountTimeline(accountId, { withReplies: true }));
dispatch(fetchRules());
}
render () {
const {
accountId,
account,
intl,
onClose,
} = this.props;
if (!account) {
return null;
}
const {
step,
selectedStatusIds,
selectedRuleIds,
comment,
forward,
category,
isSubmitting,
isSubmitted,
} = this.state;
const domain = account.get('acct').split('@')[1];
const isRemote = !!domain;
let stepComponent;
switch(step) {
case 'category':
stepComponent = (
<Category
onNextStep={this.handleNextStep}
startedFrom={this.props.statusId ? 'status' : 'account'}
category={category}
onChangeCategory={this.handleChangeCategory}
/>
);
break;
case 'rules':
stepComponent = (
<Rules
onNextStep={this.handleNextStep}
selectedRuleIds={selectedRuleIds}
onToggle={this.handleRuleToggle}
/>
);
break;
case 'statuses':
stepComponent = (
<Statuses
onNextStep={this.handleNextStep}
accountId={accountId}
selectedStatusIds={selectedStatusIds}
onToggle={this.handleStatusToggle}
/>
);
break;
case 'comment':
stepComponent = (
<Comment
onSubmit={this.handleSubmit}
isSubmitting={isSubmitting}
isRemote={isRemote}
comment={comment}
forward={forward}
domain={domain}
onChangeComment={this.handleChangeComment}
onChangeForward={this.handleChangeForward}
/>
);
break;
case 'thanks':
stepComponent = (
<Thanks
submitted={isSubmitted}
account={account}
onClose={onClose}
/>
);
}
return (
<div className='modal-root__modal report-dialog-modal'>
<div className='report-modal__target'>
<IconButton className='report-modal__close' title={intl.formatMessage(messages.close)} icon='times' onClick={onClose} size={20} />
<FormattedMessage id='report.target' defaultMessage='Report {target}' values={{ target: <strong>{account.get('acct')}</strong> }} />
</div>
<div className='report-dialog-modal__container'>
{stepComponent}
</div>
</div>
);
}
}
|
src/components/feed/actions.js | alexcurtis/react-fbpage | 'use strict';
import React from 'react';
import Radium from 'radium';
@Radium
class Actions extends React.Component {
constructor(props){
super(props);
}
render(){
return (
<div style={this.props.style.base}/>
);
}
}
Actions.propTypes = {
style: React.PropTypes.object
};
export default Actions;
|
src/entypo/StarOutlined.js | cox-auto-kc/react-entypo | import React from 'react';
import EntypoIcon from '../EntypoIcon';
const iconClass = 'entypo-svgicon entypo--StarOutlined';
let EntypoStarOutlined = (props) => (
<EntypoIcon propClass={iconClass} {...props}>
<path d="M18.8,8.022h-6.413L10,1.3L7.611,8.022H1.199l5.232,3.947L4.56,18.898L10,14.744l5.438,4.154l-1.869-6.929L18.8,8.022z M10,12.783l-3.014,2.5l1.243-3.562l-2.851-2.3L8.9,9.522l1.1-4.04l1.099,4.04l3.521-0.101l-2.851,2.3l1.243,3.562L10,12.783z"/>
</EntypoIcon>
);
export default EntypoStarOutlined;
|
src/svg-icons/device/bluetooth.js | matthewoates/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let DeviceBluetooth = (props) => (
<SvgIcon {...props}>
<path d="M17.71 7.71L12 2h-1v7.59L6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 11 14.41V22h1l5.71-5.71-4.3-4.29 4.3-4.29zM13 5.83l1.88 1.88L13 9.59V5.83zm1.88 10.46L13 18.17v-3.76l1.88 1.88z"/>
</SvgIcon>
);
DeviceBluetooth = pure(DeviceBluetooth);
DeviceBluetooth.displayName = 'DeviceBluetooth';
DeviceBluetooth.muiName = 'SvgIcon';
export default DeviceBluetooth;
|
demo/Generator.js | xadn/react-jumbo-list | import React from 'react';
import Chance from 'chance';
const chance = new Chance();
const Generator = {
items(count) {
var list = [];
for (let i = 0; i < count; i++) {
const key = `i-${i}`;
const style = {border: '1px solid black'};
const text = chance.sentence({words: chance.natural({min: 1, max: 40})});
list.push(<div key={key} style={style}>{text}</div>);
}
return list;
}
};
export default Generator; |
packages/material-ui-icons/src/MarkunreadMailbox.js | dsslimshaddy/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from 'material-ui/SvgIcon';
let MarkunreadMailbox = props =>
<SvgIcon {...props}>
<path d="M20 6H10v6H8V4h6V0H6v6H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2z" />
</SvgIcon>;
MarkunreadMailbox = pure(MarkunreadMailbox);
MarkunreadMailbox.muiName = 'SvgIcon';
export default MarkunreadMailbox;
|
blueocean-material-icons/src/js/components/svg-icons/action/stars.js | kzantow/blueocean-plugin | import React from 'react';
import SvgIcon from '../../SvgIcon';
const ActionStars = (props) => (
<SvgIcon {...props}>
<path d="M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zm4.24 16L12 15.45 7.77 18l1.12-4.81-3.73-3.23 4.92-.42L12 5l1.92 4.53 4.92.42-3.73 3.23L16.23 18z"/>
</SvgIcon>
);
ActionStars.displayName = 'ActionStars';
ActionStars.muiName = 'SvgIcon';
export default ActionStars;
|
app/src/app/components/App.js | leonardiwagner/minibook | import React from 'react';
import Header from './Header.jsx';
import Timeline from '../container/Timeline';
import EventWriter from '../container/EventWriter';
const App = () => (
<div>
<Header />
<EventWriter />
<Timeline />
</div>
)
export default App |
docs/src/app/pages/components/Toggle/Page.js | GetAmbassador/react-ions | import React from 'react'
import PropsList from 'private/modules/PropsList'
import docs from '!!docgen!react-ions/lib/components/Toggle/Toggle'
import CodeExample from 'private/modules/CodeExample'
import ExampleToggleDefault from './ExampleToggleDefault'
import exampleToggleDefaultCode from '!raw!./ExampleToggleDefault'
import ExampleToggleOn from './ExampleToggleOn'
import exampleToggleOnCode from '!raw!./ExampleToggleOn'
import ExampleToggleDisabled from './ExampleToggleDisabled'
import exampleToggleDisabledCode from '!raw!./ExampleToggleDisabled'
import ExampleToggleLoading from './ExampleToggleLoading'
import exampleToggleLoadingCode from '!raw!./ExampleToggleLoading'
import ExampleToggleOptClass from './ExampleToggleOptClass'
import exampleToggleOptClassCode from '!raw!./ExampleToggleOptClass'
import ExampleToggleCallback from './ExampleToggleCallback'
import exampleToggleCallbackCode from '!raw!./ExampleToggleCallback'
import ExampleToggleCustomText from './ExampleToggleCustomText'
import exampleToggleCustomText from '!raw!./ExampleToggleCustomText'
import ExampleToggleConfirmation from './ExampleToggleConfirmation'
import exampleToggleConfirmation from '!raw!./ExampleToggleConfirmation'
import styles from 'private/css/content'
const description = {
toggleDefault: 'This is the `toggle component` as it appears by default.',
toggleOn: 'This is the `toggle component` with initial state set to True.',
toggleDisabled: 'This is the disabled `toggle component`.',
toggleOptClass: 'This is the `toggle component` with an optional class.',
toggleCallback: 'This is the `toggle component` with a callback function. __Note__: the `style import` and `code` tag is for display purposes only.',
toggleCustomText: 'This is the `toggle component` with text.',
toggleConfirmation: 'This is the `toggle component` with a confirmation.',
toggleLoading: 'This is the `toggle component` with a loader.'
}
const TogglePage = () => (
<div>
<div className={styles.content}>
<div className={styles.block}>
<CodeExample
title='Default Toggle'
description={description.toggleDefault}
markup={exampleToggleDefaultCode}>
<ExampleToggleDefault />
</CodeExample>
<CodeExample
title='Toggle On'
description={description.toggleOn}
markup={exampleToggleOnCode}>
<ExampleToggleOn />
</CodeExample>
<CodeExample
title='Disabled Toggle'
description={description.toggleDisabled}
markup={exampleToggleDisabledCode}>
<ExampleToggleDisabled />
</CodeExample>
<CodeExample
title='Toggle with optional class'
description={description.toggleOptClass}
markup={exampleToggleOptClassCode}>
<ExampleToggleOptClass />
</CodeExample>
<CodeExample
title='Toggle with callback function'
description={description.toggleCallback}
markup={exampleToggleCallbackCode}>
<ExampleToggleCallback />
</CodeExample>
<CodeExample
title='Toggle with Text'
description={description.toggleCustomText}
markup={exampleToggleCustomText}>
<ExampleToggleCustomText />
</CodeExample>
<CodeExample
title='Toggle with Confirmation'
description={description.toggleConfirmation}
markup={exampleToggleConfirmation}>
<ExampleToggleConfirmation />
</CodeExample>
<CodeExample
title='Toggle with Loader'
description={description.toggleLoading}
markup={exampleToggleLoadingCode}>
<ExampleToggleLoading />
</CodeExample>
<div className={styles.block}>
<h3>Props</h3>
<PropsList list={docs[0].props} />
</div>
</div>
</div>
</div>
)
export default TogglePage
|
src/Input/index.js | christianalfoni/ducky-components | import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import styles from './styles.css';
import WrapperStyles from '../Wrapper/styles.css';
import TypographyStyles from '../Typography/styles.css';
import Typography from '../Typography';
function Input(props) {
const capitalizeFirstLetter = (string) => {
return string.charAt(0).toUpperCase() + string.slice(1);
};
return (
<div className={classNames(styles.wrapper, {[props.className]: props.className})}>
<input
autoFocus={props.autoFocus}
className={classNames(styles.input, TypographyStyles.bodyTextNormal, WrapperStyles.short, {
[styles.error]: props.errorMessage || props.error
})}
name={props.name}
onBlur={props.onBlur}
onChange={props.onChange}
pattern={props.inputType === 'number' ? '\\d*' : null}
placeholder={capitalizeFirstLetter(props.placeholder)}
type={props.inputType}
value={props.value}
/>
<Typography
className={classNames(styles.errorMessage, {
[styles.errorMessageActive]: props.errorMessage
})}
type="bodyTextNormal"
>
{props.errorMessage}
</Typography>
</div>
);
}
Input.propTypes = {
autoFocus: PropTypes.bool,
className: PropTypes.string,
error: PropTypes.bool,
errorMessage: PropTypes.node,
inputType: PropTypes.string,
name: PropTypes.string,
onBlur: PropTypes.func,
onChange: PropTypes.func,
placeholder: PropTypes.string,
value: PropTypes.string
};
export default Input;
|
app/javascript/mastodon/features/compose/components/warning.js | pinfort/mastodon | import React from 'react';
import PropTypes from 'prop-types';
import Motion from '../../ui/util/optional_motion';
import spring from 'react-motion/lib/spring';
export default class Warning extends React.PureComponent {
static propTypes = {
message: PropTypes.node.isRequired,
};
render () {
const { message } = this.props;
return (
<Motion defaultStyle={{ opacity: 0, scaleX: 0.85, scaleY: 0.75 }} style={{ opacity: spring(1, { damping: 35, stiffness: 400 }), scaleX: spring(1, { damping: 35, stiffness: 400 }), scaleY: spring(1, { damping: 35, stiffness: 400 }) }}>
{({ opacity, scaleX, scaleY }) => (
<div className='compose-form__warning' style={{ opacity: opacity, transform: `scale(${scaleX}, ${scaleY})` }}>
{message}
</div>
)}
</Motion>
);
}
}
|
src/main/js/app.react.js | adw1n/hub-traffic | import React from 'react';
import ReactDOM from 'react-dom';
// import Plotly from 'plotly.js/dist/plotly.js';
function getNthDayDate(date, nthDay){
return new Date(new Date(date).setDate(date.getDate()+nthDay))
}
function getNextDayDate(date){
return getNthDayDate(date, 1)
}
function differenceInDays(date1, date2){
return Math.round(Math.abs((date1-date2))/(1000*60*60*24));
}
const GitHubTrafficAPIDays = 14;
const SmallGraphThresholdDays = 30;
class GitHubRepositoryViewsChart extends React.Component{
constructor(props){
super(props);
this.state = {
id: this.props.name+"-visits"
};
this.chartTitle="Visitors";
this.uniqueLineTitle="unique visitors";
this.totalLineTitle="visits";
this.getDateStr = this.getDateStr.bind(this);
this.getChartValues = this.getChartValues.bind(this);
}
getDateStr(date){
let monthNo = date.getMonth()+1;
return ((monthNo>=10 ? monthNo : "0"+monthNo)
+"/"
+(date.getDate()>=10 ? date.getDate() : "0"+date.getDate()));
}
getChartValues(values){
let dates = values.map(value => new Date(value.timestamp));
let allValues = values.map(value => {
return {date: new Date(value.timestamp), count: value.count, uniques: value.uniques}
});
const minDate = dates.length ? new Date(Math.min.apply(null,dates)) : new Date();
const maxDate = dates.length ? new Date(Math.max.apply(null,dates)) : new Date();
const startDate = new Date(
Math.min(
minDate ? minDate : new Date(),
getNthDayDate(new Date(), -GitHubTrafficAPIDays)
)
);
const endDate = new Date(Math.max(maxDate ? maxDate : new Date(), new Date()));
let date = startDate;
while(date < endDate){
if(!dates.find(item => item.toDateString()===date.toDateString())){ // test if date with same day already exists
allValues.push({date: new Date(date), count: 0, uniques: 0})
}
date=getNextDayDate(date);
}
allValues.sort((val1, val2) => val1.date.getTime()-val2.date.getTime());
return (
{ startDate, endDate,
values: allValues.map(value => {
return {date: this.getDateStr(value.date), count: value.count, uniques: value.uniques}
})
});
}
componentDidMount(){
// https://plot.ly/javascript/responsive-fluid-layout/
let gd3 = Plotly.d3.select('#'+this.state.id)
.append('div')
.style({
width: '100%'
});
let gd = gd3.node();
Plotly.plot(gd, this.data, this.layout);
// TODO take care of removing this callback when component is unmounted (not needed so far)
$(window).resize(()=>Plotly.Plots.resize(gd));
}
// after changes to this.props.values stuff will break - no more updates (but that does not concern me, since
// my app won't need to redraw the charts)
render(){
const values = this.getChartValues(this.props.values);
const totalCount = {
x: values.values.map(val => val.date),
y: values.values.map(val => val.count),
mode: 'lines',
marker: {
color: 'blue',
size: 8
},
line: {
color: 'blue',
width: 1
},
name: this.totalLineTitle
};
const uniqueCount = {
x: values.values.map(val => val.date),
y: values.values.map(val => val.uniques),
mode: 'lines',
marker: {
color: 'green',
size: 8
},
line: {
color: 'green',
width: 1
},
name: this.uniqueLineTitle,
yaxis: 'y2'
};
this.layout = {
title: this.chartTitle,
yaxis: { //https://plot.ly/javascript/multiple-axes/
side: 'left',
color: 'blue',
tickformat: "d" // only integer numbers
},
yaxis2: {
overlaying: 'y',
side: 'right',
color: 'green',
tickformat: "d"
}
};
// this fixes case when repo had no visitors / clones
// in that case chart is being drawn icorrectly with Y axis <-1,1>
if(Math.max(...totalCount.y)<=0){
console.log("applied");
this.layout.yaxis.range = [0,1];
}
if(Math.max(...uniqueCount.y)<=0){
this.layout.yaxis2.range = [0,1];
}
this.data = [ totalCount, uniqueCount];
const timePeriodInDays = differenceInDays(values.startDate, values.endDate);
return (
<div className={"col-sm-12 col-lg-"+(timePeriodInDays>SmallGraphThresholdDays ? 12 : 6)} id={this.state.id}>
</div>
);
}
}
class GitHubRepositoryClonesChart extends GitHubRepositoryViewsChart{
constructor(props){
super(props);
this.state = {
id: this.props.name+"-clones"
};
this.chartTitle="Git clones";
this.uniqueLineTitle="unique cloners";
this.totalLineTitle="clones"
}
}
class GitHubRepositoryChart extends React.Component{
render(){
return (
<div className="row">
<div className="col-lg-12"><h4>{this.props.name}</h4></div>
<GitHubRepositoryViewsChart name={this.props.name} values={this.props.views}/>
<GitHubRepositoryClonesChart name={this.props.name} values={this.props.clones}/>
</div>
)
}
}
class LoginHeader extends React.Component{
}
function getRandomInt(minimum, maximum) {
return Math.floor(Math.random() * (maximum - minimum + 1)) + minimum;
}
function getDemoChartData(startDate, endDate, maximumViews, maximumUniqueViews, maximumClones, maximumUniqueClones){
console.assert(startDate.getTime()<=endDate.getTime());
let date = new Date(startDate);
let views = [];
let clones = [];
while(date <= endDate){
let count = getRandomInt(0, maximumViews);
views.push({
timestamp: date.getTime(),
count,
uniques: getRandomInt(count > 0 ? 1 : 0, Math.min(maximumUniqueViews, count))
});
count = getRandomInt(0, maximumClones);
clones.push({
timestamp: date.getTime(),
count,
uniques: getRandomInt(count > 0 ? 1 : 0, Math.min(maximumUniqueClones, count))
});
date = getNextDayDate(date);
}
return {views, clones};
}
class DemoExample extends React.Component{
constructor(props){
super(props);
const endDate = new Date();
let demoRepoNames = [
{name: "repo-1", startDate: new Date("Wed Jan 01 2020 02:00:00 GMT+0200 (CEST)")},
{name: "repo-2", startDate: getNthDayDate(endDate, -20)},
{name: "repo-3", startDate: getNthDayDate(endDate, -40)}
];
this.demoRepos=demoRepoNames.map(repo => {
let repoData = getDemoChartData(
repo.startDate,
endDate ? endDate : console.assert("messed up"),
100,
10,
50,
9
);
repoData.name = repo.name;
return repoData;
});
}
render(){
const repos = this.demoRepos.map(repo => <GitHubRepositoryChart key={repo.name}
name={repo.name}
views={repo.views}
clones={repo.clones}/>
);
return (
<div>
<h2 className="text-center">DEMO</h2>
<p>user: JohnDoe</p>
{repos}
</div>
);
}
}
class Repos extends React.Component{
constructor(props){
super(props);
this.state={
user: null,
repositories: [],
error: false
}
}
componentDidMount(){
$.get("/api/githubUser", data => {
this.setState({
user: data
});
console.log(data);
}).done(()=>{
$.get("/api/repository/traffic",data =>{
console.log(data);
this.setState({
repositories: data
})
}).fail(() => {
this.setState({
error: true
})
})
})
}
render(){
const user = this.state.user;
const error = this.state.error;
console.log("user: ");
console.log(user);
console.log("repositories: ");
console.log(this.state.repositories);
const repositories = this.state.repositories.map(repo=>{
return <GitHubRepositoryChart key={repo.name.name}
name={repo.name.name}
views={repo.views ? repo.views : []}
clones={repo.clones ? repo.clones : []} />
});
return (
<div>
<p>user: {user ? user.name : ""}</p>
{repositories.length ? repositories : ( error ? "Error: failed to fetch data from the server." :
<div>
<i className="fa fa-refresh fa-spin fa-3x fa-fw" style={{position: "relative", left: "50%"}}></i>
<span className="sr-only">Loading...</span>
</div>
)}
</div>
)
}
}
class Page extends React.Component{
render(){
return currentUser=="anonymousUser" ? <DemoExample/> : <Repos/>
}
}
class UnregisterButton extends React.Component{
constructor(props){
super(props);
this.unregister=this.unregister.bind(this);
}
unregister(){
console.log("unregister clicked");
$.ajax({
method: "DELETE",
url: "/api/user"
}).done(()=>{
console.log("done -> logout");
window.location.href="/logout"
}).fail(()=>{
console.log("fail");
// TODO display error msg in red - ERROR: failed to unregister
})
}
componentDidMount(){
$("#unregisterButton").click(this.unregister);
}
render(){
return (
<a className="nav-link page-scroll" data-toggle="modal" data-target="#myModal" href="#myModal">
Unregister
</a>
)
}
}
class NavigationButtons extends React.Component{
render(){
return this.props.logged ? (
<ul className="navbar-nav ml-auto">
<li className="nav-item">
<a className="nav-link page-scroll" href="/logout">logout</a>
</li>
<li className="nav-item">
<UnregisterButton />
</li>
</ul>
) : (
<ul className="navbar-nav ml-auto">
<li className="nav-item">
<a className="nav-link page-scroll" href="#demo">demo</a>
</li>
<li className="nav-item">
<a className="nav-link page-scroll" href="/login">login</a>
</li>
</ul>
)
}
}
// ========================================
ReactDOM.render(
<NavigationButtons logged={currentUser=="anonymousUser" ? false : true}/>,
document.getElementById('navbarExample')
);
ReactDOM.render(
<Page/>,
document.getElementById('react')
);
|
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.