path stringlengths 5 195 | repo_name stringlengths 5 79 | content stringlengths 25 1.01M |
|---|---|---|
src/PageHeader.js | zanjs/react-bootstrap | import React from 'react';
import classNames from 'classnames';
const PageHeader = React.createClass({
render() {
return (
<div {...this.props} className={classNames(this.props.className, 'page-header')}>
<h1>{this.props.children}</h1>
</div>
);
}
});
export default PageHeader;
|
src/components/Common/RadioInputField.js | oraclesorg/ico-wizard | import React from 'react';
import '../../assets/stylesheets/application.css';
export const RadioInputField = (props) => {
const inputs = props.items
.map((item, index) => (
<label className="radio-inline" key={index}>
<input
type="radio"
checked={props.selectedItem === item.value}
onChange={props.onChange}
value={item.value}
/>
<span className="title">{item.label}</span>
</label>
))
return (
<div className={props.extraClassName}>
<label className="label">{props.title}</label>
<div className="radios-inline">
{ inputs }
</div>
<p className="description">{props.description}</p>
</div>
);
}
|
src/containers/Asians/Published/BreakRounds/ViewMatchUps/SmallMatchUps/index.js | westoncolemanl/tabbr-web | import React from 'react'
import { connect } from 'react-redux'
import withStyles from 'material-ui/styles/withStyles'
import Card, {
CardHeader
} from 'material-ui/Card'
import List, {
ListItem,
ListItemText
} from 'material-ui/List'
import Divider from 'material-ui/Divider'
const styles = theme => ({
root: {
marginTop: theme.spacing.unit * 3
}
})
export default withStyles(styles)(connect(mapStateToProps)(({
breakRoomsThisRound,
returnBreakAdjudicatorInformation,
venuesById,
teamsById,
breakTeamsById,
classes
}) =>
<div>
{breakRoomsThisRound.map(breakRoom =>
<Card
key={breakRoom._id}
className={classes.root}
>
<CardHeader
title={`Room ${venuesById[breakRoom.venue].name}`}
subheader={`Rank ${breakRoom.rank}`}
/>
<Divider />
<List>
<ListItem>
<ListItemText
primary={teamsById[breakTeamsById[breakRoom.gov].team].name}
secondary={'Government'}
/>
</ListItem>
<ListItem>
<ListItemText
primary={teamsById[breakTeamsById[breakRoom.opp].team].name}
secondary={'Opposition'}
/>
</ListItem>
<Divider />
<ListItem>
<ListItemText
primary={returnBreakAdjudicatorInformation(breakRoom.chair)}
secondary={'Chair'}
/>
</ListItem>
<Divider />
{breakRoom.panels.map(panel =>
<ListItem
key={panel}
>
<ListItemText
primary={returnBreakAdjudicatorInformation(panel)}
secondary={'Panelist'}
/>
</ListItem>
)}
</List>
<Divider />
</Card>
)}
</div>
))
function mapStateToProps (state, ownProps) {
return {
teamsById: state.teams.data,
breakTeamsById: state.breakTeams.data,
venuesById: state.venues.data
}
}
|
wrappers/md.js | karolklp/slonecznikowe2 | import React from 'react'
import 'css/markdown-styles.css'
import Helmet from 'react-helmet'
import { config } from 'config'
module.exports = React.createClass({
propTypes () {
return {
router: React.PropTypes.object,
}
},
render () {
const post = this.props.route.page.data
return (
<div className="markdown">
<Helmet
title={`${config.siteTitle} | ${post.title}`}
/>
<h1>{post.title}</h1>
<div dangerouslySetInnerHTML={{ __html: post.body }} />
</div>
)
},
})
|
src/cms/preview-templates/ResumePagePreview.js | eejdoowad/dawoodjee.com | import React from 'react';
import { ResumePageTemplate } from '../../templates/resume-page';
const ResumePagePreview = ({ entry, widgetFor }) => (
<AboutPageTemplate title={entry.getIn(['data', 'title'])} content={widgetFor('body')} />
);
export default ResumePagePreview;
|
src/svg-icons/image/brightness-5.js | lawrence-yu/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let ImageBrightness5 = (props) => (
<SvgIcon {...props}>
<path d="M20 15.31L23.31 12 20 8.69V4h-4.69L12 .69 8.69 4H4v4.69L.69 12 4 15.31V20h4.69L12 23.31 15.31 20H20v-4.69zM12 18c-3.31 0-6-2.69-6-6s2.69-6 6-6 6 2.69 6 6-2.69 6-6 6z"/>
</SvgIcon>
);
ImageBrightness5 = pure(ImageBrightness5);
ImageBrightness5.displayName = 'ImageBrightness5';
ImageBrightness5.muiName = 'SvgIcon';
export default ImageBrightness5;
|
frontend/containers/SignUp.js | tahosalodge/camping-guide | import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { reduxForm, Field } from 'redux-form';
import { connect } from 'react-redux';
import { Link } from 'react-router-dom';
import Messages from '../components/Messages';
import Errors from '../components/Errors';
import { signupRequest } from '../redux/modules/signup';
class Signup extends Component {
static propTypes = {
handleSubmit: PropTypes.func.isRequired,
signupRequest: PropTypes.func.isRequired,
signup: PropTypes.shape({
requesting: PropTypes.bool,
successful: PropTypes.bool,
messages: PropTypes.array,
errors: PropTypes.array
}).isRequired
};
submit = (values) => {
this.props.signupRequest(values);
};
render() {
const { handleSubmit, signup: { requesting, successful, messages, errors } } = this.props;
return (
<div className="signup">
<form className="widget-form" onSubmit={handleSubmit(this.submit)}>
<h1>Signup</h1>
<label htmlFor="name">Name</label>
<Field
name="name"
type="text"
id="name"
className="name"
label="Name"
component="input"
/>
<label htmlFor="email">Email</label>
<Field
name="email"
type="text"
id="email"
className="email"
label="Email"
component="input"
/>
<label htmlFor="password">Password</label>
<Field
name="password"
type="password"
id="password"
className="password"
label="Password"
component="input"
/>
<button action="submit">SIGNUP</button>
</form>
<div className="auth-messages">
{!requesting &&
!!errors.length && <Errors message="Failure to signup due to:" errors={errors} />}
{!requesting && !!messages.length && <Messages messages={messages} />}
{!requesting &&
successful && (
<div>
Signup Successful! <Link to="/login">Click here to Login »</Link>
</div>
)}
{!requesting && !successful && <Link to="/login">Already a Member? Login Here »</Link>}
</div>
</div>
);
}
}
const mapStateToProps = state => ({
signup: state.signup
});
const connected = connect(mapStateToProps, { signupRequest })(Signup);
const formed = reduxForm({
form: 'signup'
})(connected);
export default formed;
|
src/interface/icons/Timeline.js | fyruna/WoWAnalyzer | import React from 'react';
// https://thenounproject.com/search/?q=timeline&i=151027
// timeline by Alexander Blagochevsky from the Noun Project
const Icon = ({ ...other }) => (
<svg xmlns="http://www.w3.org/2000/svg" viewBox="4 4 56 56" className="icon" {...other}>
<path d="M14 52h28V42H14v10zm2-8h24v6H16v-6zM58 30H22v10h36V30zm-2 8H24v-6h32v6zM46 18H6v10h40V18zm-2 8H8v-6h36v6zM58 6H18v10h40V6zm-2 8H20V8h36v6zM4 56h56v2H4z" />
</svg>
);
export default Icon;
|
src/svg-icons/places/room-service.js | pancho111203/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let PlacesRoomService = (props) => (
<SvgIcon {...props}>
<path d="M2 17h20v2H2zm11.84-9.21c.1-.24.16-.51.16-.79 0-1.1-.9-2-2-2s-2 .9-2 2c0 .28.06.55.16.79C6.25 8.6 3.27 11.93 3 16h18c-.27-4.07-3.25-7.4-7.16-8.21z"/>
</SvgIcon>
);
PlacesRoomService = pure(PlacesRoomService);
PlacesRoomService.displayName = 'PlacesRoomService';
PlacesRoomService.muiName = 'SvgIcon';
export default PlacesRoomService;
|
src/index.js | jmahc/hhhng | import React from 'react';
import { render } from 'react-dom';
import { Provider } from 'react-redux';
import { createStore } from 'redux';
import App from './components/App';
import todoApp from './reducers';
import './index.css';
let store = createStore(todoApp);
const rootEl = document.getElementById('root');
render(
<Provider store={store}>
<App />
</Provider>,
rootEl
);
|
src/components/DynLoader.js | ekatzenstein/DynamoDictionary_React | import React from 'react';
import FileLabel from './FileLabel';
export default function DynLoader(props){
return(
<FileLabel accept={".dyn"} label={props.force ? "Add Dynamo File" : "Update Dynamo File"} readFile={props.readFile} loaded={props.loaded}/>
)
}
|
app/infra/route-manager.js | btg5679/portalReact | import FS from 'fs';
import express from 'express';
import axios from 'axios';
import nconf from 'nconf';
import React from 'react'
import {renderToString} from 'react-dom/server';
import {match, RoutingContext} from 'react-router';
import baseManager from './base-manager';
import routes from '../routes';
import ContextWrapper from '../components/common/ContextWrapper';
const routeManager = Object.assign({}, baseManager, {
configureDevelopmentEnv(app) {
const apiRouter = this.createApiRouter();
const pagesRouter = this.createPageRouter();
app.use('/api', apiRouter);
app.use('/', pagesRouter);
},
createPageRouter() {
const router = express.Router();
router.get('*', (req, res) => {
match({routes, location: req.originalUrl}, (err, redirectLocation, renderProps) => {
const {promises, components} = this.mapComponentsToPromises(
renderProps.components, renderProps.params);
Promise.all(promises).then((values) => {
const data = this.prepareData(values, components);
const html = this.render(renderProps, data);
res.render('index', {
content: html,
context: JSON.stringify(data)
});
}).catch((err) => {
res.status(500).send(err);
});
});
});
return router;
},
mapComponentsToPromises(components, params) {
const filteredComponents = components.filter((Component) => {
return (typeof Component.loadAction === 'function');
});
const promises = filteredComponents.map(function(Component) {
return Component.loadAction(params, nconf.get('domain'));
});
return {promises, components: filteredComponents};
},
prepareData(values, components) {
const map = {};
values.forEach((value, index) => {
map[components[0].NAME] = value.data;
});
return map;
},
render(renderProps, data) {
let html = renderToString(
<ContextWrapper data={data}>
<RoutingContext {...renderProps}/>
</ContextWrapper>
);
return html;
},
createApiRouter(app) {
const router = express.Router();
this.createLastestBillsRoute(router);
this.createDetailedBillRoute(router);
this.createAccountSummaryRoute(router);
return router;
},
createAccountSummaryRoute(router) {
router.get('/api/account-summary', (req, res) => {
this.retrieveAccounts((err, data) => {
if(!err) {
res.json(data);
} else {
res.status(500).send(err);
}
});
});
},
createLastestBillsRoute(router) {
router.get('/latest-bills', (req, res) => {
this.retrieveLatestBills((err, data) => {
if(!err) {
res.json(data);
} else {
res.status(500).send(err);
}
});
});
},
createDetailedBillRoute(router) {
router.get('/bill/:id', (req, res) => {
const id = req.params.id;
this.retrieveDetailedBills((err, data) => {
if(!err) {
const billData = data.items.filter((item) => {
return item.id === id;
})[0];
res.json(billData);
} else {
res.status(500).send(err);
}
});
});
},
retrieveAccounts(callback) {
FS.readFile('./app/fixtures/account.json', 'utf-8', (err, content) => {
callback(err, JSON.parse(content));
});
},
retrieveLatestBills(callback) {
FS.readFile('./app/fixtures/latest-bills.json', 'utf-8', (err, content) => {
callback(err, JSON.parse(content));
});
},
retrieveDetailedBills(callback) {
FS.readFile('./app/fixtures/detailed-bills.json', 'utf-8', (err, content) => {
callback(err, JSON.parse(content));
});
}
});
export default routeManager; |
packages/skypager-ui/src/components/SearchInput/index.js | stylish/stylish | import React from 'react'
import InputWithIcon from 'ui/components/InputWithIcon'
export class SearchInput extends React.Component {
constructor (props) {
super(props)
this.state = {
value: props.value
}
}
handleChange (e) {
let { target } = e
let { name, value } = target
let oldValue = this.state.value
this.setState({
[name]: value
})
this.props.onChange(value, oldValue)
}
render () {
const handleChange = this.handleChange.bind(this)
const { value } = this.state
return <input type='text' />
}
}
SearchInput.propTypes = {
value: React.PropTypes.string,
onChange: React.PropTypes.func
}
export default SearchInput
|
examples/counter/containers/CounterApp.js | Creamov/redux | import React, { Component } from 'react';
import { bindActionCreators } from 'redux';
import { connect } from 'redux/react';
import Counter from '../components/Counter';
import * as CounterActions from '../actions/CounterActions';
@connect(state => ({
counter: state.counter
}))
export default class CounterApp extends Component {
render() {
const { counter, dispatch } = this.props;
return (
<Counter counter={counter}
{...bindActionCreators(CounterActions, dispatch)} />
);
}
}
|
src/index.js | vire/resit | import React from 'react';
import configureStore from './configureStore';
import { Provider } from 'react-redux';
import App from './App';
React.render(
<Provider store={configureStore()}>
{() => <App/>}
</Provider>,
document.getElementById('root')
);
|
packages/react/src/components/ListItem/ListItem.js | carbon-design-system/carbon-components | /**
* Copyright IBM Corp. 2016, 2018
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/
import PropTypes from 'prop-types';
import React from 'react';
import classnames from 'classnames';
import { settings } from 'carbon-components';
const { prefix } = settings;
const ListItem = ({ children, className, ...other }) => {
const classNames = classnames(`${prefix}--list__item`, className);
return (
<li className={classNames} {...other}>
{children}
</li>
);
};
ListItem.propTypes = {
/**
* Specify the content for the ListItem
*/
children: PropTypes.node,
/**
* Specify an optional className to apply to the underlying `<li>` node
*/
className: PropTypes.string,
};
export default ListItem;
|
blueocean-material-icons/src/js/components/svg-icons/image/photo-album.js | kzantow/blueocean-plugin | import React from 'react';
import SvgIcon from '../../SvgIcon';
const ImagePhotoAlbum = (props) => (
<SvgIcon {...props}>
<path d="M18 2H6c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zM6 4h5v8l-2.5-1.5L6 12V4zm0 15l3-3.86 2.14 2.58 3-3.86L18 19H6z"/>
</SvgIcon>
);
ImagePhotoAlbum.displayName = 'ImagePhotoAlbum';
ImagePhotoAlbum.muiName = 'SvgIcon';
export default ImagePhotoAlbum;
|
src/entypo/FolderMusic.js | cox-auto-kc/react-entypo | import React from 'react';
import EntypoIcon from '../EntypoIcon';
const iconClass = 'entypo-svgicon entypo--FolderMusic';
let EntypoFolderMusic = (props) => (
<EntypoIcon propClass={iconClass} {...props}>
<path d="M18.405,2.799C18.293,2.359,17.749,2,17.195,2H2.805c-0.555,0-1.099,0.359-1.21,0.799L1.394,4h17.211L18.405,2.799z M19.412,5H0.587C0.245,5-0.022,5.294,0.01,5.635l0.923,11.669C0.971,17.698,1.303,18,1.699,18H18.3c0.397,0,0.728-0.302,0.766-0.696l0.923-11.669C20.022,5.294,19.754,5,19.412,5z M11.942,12.521c-0.128,0.265-0.258,0.279-0.202,0c0.146-0.721,0.047-2.269-1.043-2.441v3.294c0,0.674-0.311,1.262-1.136,1.528c-0.802,0.256-1.699-0.011-1.908-0.586c-0.21-0.576,0.261-1.276,1.052-1.564c0.442-0.161,0.954-0.203,1.299-0.07V8h0.694C10.697,9.633,13.516,9.275,11.942,12.521z"/>
</EntypoIcon>
);
export default EntypoFolderMusic;
|
docs/src/app/components/pages/components/RaisedButton/ExampleIcon.js | mmrtnz/material-ui | import React from 'react';
import RaisedButton from 'material-ui/RaisedButton';
import {fullWhite} from 'material-ui/styles/colors';
import ActionAndroid from 'material-ui/svg-icons/action/android';
import FontIcon from 'material-ui/FontIcon';
const style = {
margin: 12,
};
const RaisedButtonExampleIcon = () => (
<div>
<RaisedButton
icon={<ActionAndroid />}
style={style}
/>
<RaisedButton
backgroundColor="#a4c639"
icon={<ActionAndroid color={fullWhite} />}
style={style}
/>
<RaisedButton
href="https://github.com/callemall/material-ui"
target="_blank"
secondary={true}
icon={<FontIcon className="muidocs-icon-custom-github" />}
style={style}
/>
</div>
);
export default RaisedButtonExampleIcon;
|
assets/components/Button.js | mijia/web-starter-kit | import React from 'react';
import classnames from 'classnames';
import _ from 'lodash';
function mdlUpgrade(Component) {
const MDLComponent = React.createClass({
componentDidMount() {
componentHandler.upgradeDom();
},
componentDidUpdate() {
componentHandler.upgradeDom();
},
render() {
return <Component {...this.props} />
},
});
return MDLComponent;
}
const Icon = (props) => {
return (<i className='material-icons' style={props.style}>{props.name}</i>);
};
const ClassedButton = (props) => {
let btnProps = {
className: props.className,
to: props.to,
style: props.style,
onClick: (evt) => props.onClick && props.onClick(evt),
};
if (props.id) {
btnProps.id = props.id;
}
let children = [];
let toReverse = false;
if (props.icon) {
const alignRight = props.iconAlign === 'right';
toReverse = alignRight;
let iconStyle = _.assign({}, props.iconStyle);
if (props.title) {
alignRight ? iconStyle['marginLeft'] = 8 : iconStyle['marginRight'] = 8;
}
children.push(<Icon style={iconStyle} name={props.icon} key="icon" />);
}
if (props.title) {
children.push(<span key='title'>{props.title}</span>);
}
if (toReverse) {
children.reverse();
}
return props.to ? <Link {...btnProps}>{children}</Link> : <button {...btnProps}>{children}</button>;
};
const Button = (props) => {
const claz = classnames('mdl-button mdl-js-button mdl-js-ripple-effect', {
'mdl-button--colored': props.color === 'colored',
'mdl-button--primary': props.color === 'primary',
'mdl-button--accent': props.color === 'accent',
'mdl-button--raised': props.raised === true,
});
return <ClassedButton className={claz} {...props} />;
};
export default mdlUpgrade(Button);
|
src/data-loader/view/FileUploadComponent.js | sozemego/StatHelper | import React from 'react';
import {SpinnerComponent} from '../../common/component/SpinnerComponent';
export default class FileUploadComponent extends React.Component {
constructor(props) {
super(props);
}
_getSpinner = () => {
return this.props.loading ? <SpinnerComponent/> : null;
};
_extractFile = event => {
this.props.onFileUpload(event.target.files[0]);
};
render() {
const {
_extractFile,
_getSpinner
} = this;
return (
<div>
<input type="file" onChange={_extractFile} accept=".xls,.xlsx,.csv"/>
{_getSpinner()}
</div>
);
}
} |
client/src/components/dataset/validate.js | OpenChemistry/materialsdatabank | import React, { Component } from 'react';
import _ from 'lodash';
import { connect } from 'react-redux'
import { loadDatasetById } from '../../redux/ducks/datasets'
import { loadJob } from '../../redux/ducks/jobs';
import { validateDataSet } from '../../redux/ducks/upload';
import selectors from '../../redux/selectors';
import { Button, Table, TableRow, TableCell, TableHead, TableBody } from '@material-ui/core';
const INACTIVE = 'INACTIVE';
const QUEUED = 'QUEUED';
const RUNNING = 'RUNNING';
const SUCCESS = 'SUCCESS';
const ERROR = 'ERROR';
const CANCELED = 'CANCELED';
const JOB_STATUS = {
0: INACTIVE,
1: QUEUED,
2: RUNNING,
3: SUCCESS,
4: ERROR,
5: CANCELED
}
const STATUS_LABEL = {
INACTIVE: 'Inactive',
QUEUED: 'Queued',
RUNNING: 'Running',
SUCCESS: 'Success',
ERROR: 'Error',
CANCELED: 'Canceled'
}
const CAN_RESTART = {
INACTIVE: false,
QUEUED: false,
RUNNING: false,
SUCCESS: true,
ERROR: true,
CANCELED: true
}
const STATUS_COLOR = {
INACTIVE: '#FFC107',
QUEUED: '#FFC107',
RUNNING: '#FFC107',
SUCCESS: '#4CAF50',
ERROR: '#F44336',
CANCELED: '#F44336'
}
const getR1 = (dataset) => {
if (
!_.isNil(dataset) &&
!_.isNil(dataset.validation) &&
!_.isNil(dataset.validation.r1)
) {
return dataset.validation.r1;
}
return null;
}
const getJobId = (dataset) => {
if (
!_.isNil(dataset) &&
!_.isNil(dataset.validation) &&
!_.isNil(dataset.validation.jobId)
) {
return dataset.validation.jobId;
}
return null;
}
class ValidateTable extends Component {
fetchJobInfo = () => {
const { dataset } = this.props;
const jobId = getJobId(dataset);
if (!_.isNil(jobId)) {
this.props.dispatch(loadJob(jobId));
}
}
fetchDataSet = () => {
const { dataset } = this.props;
if (!_.isNil(dataset)) {
this.props.dispatch(loadDatasetById(dataset._id));
}
}
startValidation = () => {
const { dataset } = this.props;
if (!_.isNil(dataset)) {
this.props.dispatch(validateDataSet(dataset._id));
}
}
render() {
const { dataset, job } = this.props;
const jobId = getJobId(dataset);
const hasJobId = !_.isNil(jobId);
if (hasJobId && _.isNil(job)) {
// If the dataset has a job id, but no job matching was already in the store,
// dispatch an action to fetch it
this.fetchJobInfo();
}
let canRestart = !hasJobId;
let label = null;
let result = getR1(dataset);
let color = null;
if (!_.isNil(job)) {
const status = JOB_STATUS[job.status];
canRestart = CAN_RESTART[status];
label = STATUS_LABEL[status];
color = STATUS_COLOR[status];
if (_.isNil(getR1(dataset)) && status === SUCCESS) {
// If job is completed, but the dataset doesn't have an r1 value,
// it needs to be fetched from the server
this.fetchDataSet();
}
}
// if (!_.isNil(dataset)) {
// result = dataset.validation.r1 || null;
// }
return (
<div>
<Table>
<TableHead>
<TableRow>
<TableCell style={{width: '100%'}}></TableCell>
<TableCell>Result</TableCell>
<TableCell>Status</TableCell>
<TableCell>Refresh status</TableCell>
<TableCell>Start validation</TableCell>
</TableRow>
</TableHead>
<TableBody>
<TableRow>
<TableCell>
R1 Validation
</TableCell>
<TableCell>
{result ? result.toFixed(6) : null}
</TableCell>
<TableCell>
<div style={{color}}>
{label}
</div>
</TableCell>
<TableCell>
<Button variant="contained" size="small" disabled={!hasJobId} onClick={this.fetchJobInfo}>
Refresh
</Button>
</TableCell>
<TableCell>
<Button variant="contained" size="small" disabled={!canRestart} onClick={this.startValidation}>
{hasJobId ? 'Restart' : 'Start'}
</Button>
</TableCell>
</TableRow>
</TableBody>
</Table>
</div>
)
}
}
function mapStateToProps(state, ownProps) {
let props = {
dataset: null,
job: null
};
if (!_.isNull(ownProps._id)) {
let dataset = selectors.datasets.getDatasetById(state, ownProps._id);
props['dataset'] = dataset;
let jobId = getJobId(dataset);
if (!_.isNil(jobId)) {
let job = selectors.jobs.getJob(state, jobId);
props['job'] = job;
}
}
return props;
}
export default connect(mapStateToProps)(ValidateTable)
|
src/events-timeline.js | liorbentov/events-timeline | import React, { Component } from 'react';
import PropTypes from 'prop-types';
class EventsTimeline extends Component {
constructor(props) {
super(props);
this.handlePointClick = this.handlePointClick.bind(this);
const { currentIndex } = props;
const right = this.getRight(currentIndex);
this.state = { right, currentIndex };
}
getRight(index) {
const eventsAmount = this.props.events.length;
const gap = 100 / eventsAmount;
const halfGap = gap / 2;
const multiplyBy = eventsAmount - index;
const right = (gap * multiplyBy) - halfGap;
return right;
}
handlePointClick(currentIndex) {
const { onClick, events } = this.props;
const right = this.getRight(currentIndex);
this.setState({ right, currentIndex });
if (onClick) {
onClick(events[currentIndex]);
}
}
mapItems() {
const { events } = this.props;
return events.map((item, index) => {
const onClick = () => this.handlePointClick(index);
const style = this.getEventStyle(index);
const classes = [!item.title && 'untitled-event'].filter(Boolean);
const key = `event-${index}`;
return (
<li key={key} className="events-timeline-event">
{ item.title && <span className="event-title">{item.title}</span> }
<button style={style} className={classes} onClick={onClick} />
</li>
);
});
}
getEventStyle(pointIndex) {
const { currentIndex } = this.state;
const { color, emptyColor } = this.props;
const style = { backgroundColor: emptyColor };
if (pointIndex <= currentIndex) {
style.backgroundColor = color;
}
return style;
}
getLineStyle() {
return { backgroundColor: this.props.emptyColor };
}
getFilledLineStyle() {
const right = `${this.state.right}%`;
return {
backgroundColor: this.props.color,
right
};
}
render() {
const lineStyle = this.getLineStyle();
const filledLineStyle = this.getFilledLineStyle();
return (
<div className="events-timeline-component">
<ul className="events-timeline-container">
<span className="events-timeline-line" style={lineStyle} />
<span className="events-timeline-line events-timeline-filled" style={filledLineStyle} />
{ this.mapItems() }
</ul>
</div>
);
}
}
EventsTimeline.propTypes = {
color: PropTypes.string,
currentIndex: PropTypes.number,
emptyColor: PropTypes.string,
events: PropTypes.arrayOf(PropTypes.shape({ title: PropTypes.string })).isRequired,
onClick: PropTypes.func.isRequired
};
EventsTimeline.defaultProps = {
color: '#5151ff',
currentIndex: 0,
emptyColor: '#ffffff'
};
export default EventsTimeline;
|
src/views/NotFoundView/NotFoundView.js | seriallos/hubot-stats-web | import React from 'react';
import { Link } from 'react-router';
export class NotFoundView extends React.Component {
render () {
return (
<div className='container text-center'>
<h1>This is a demo 404 page!</h1>
<hr />
<Link to='/'>Back To Home View</Link>
</div>
);
}
}
export default NotFoundView;
|
node_modules/react-bootstrap/es/Button.js | mohammed52/door-quote-automator | import _Object$values from 'babel-runtime/core-js/object/values';
import _objectWithoutProperties from 'babel-runtime/helpers/objectWithoutProperties';
import _extends from 'babel-runtime/helpers/extends';
import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn';
import _inherits from 'babel-runtime/helpers/inherits';
import classNames from 'classnames';
import React from 'react';
import PropTypes from 'prop-types';
import elementType from 'prop-types-extra/lib/elementType';
import { bsClass, bsSizes, bsStyles, getClassSet, prefix, splitBsProps } from './utils/bootstrapUtils';
import { Size, State, Style } from './utils/StyleConfig';
import SafeAnchor from './SafeAnchor';
var propTypes = {
active: PropTypes.bool,
disabled: PropTypes.bool,
block: PropTypes.bool,
onClick: PropTypes.func,
componentClass: elementType,
href: PropTypes.string,
/**
* Defines HTML button type attribute
* @defaultValue 'button'
*/
type: PropTypes.oneOf(['button', 'reset', 'submit'])
};
var defaultProps = {
active: false,
block: false,
disabled: false
};
var Button = function (_React$Component) {
_inherits(Button, _React$Component);
function Button() {
_classCallCheck(this, Button);
return _possibleConstructorReturn(this, _React$Component.apply(this, arguments));
}
Button.prototype.renderAnchor = function renderAnchor(elementProps, className) {
return React.createElement(SafeAnchor, _extends({}, elementProps, {
className: classNames(className, elementProps.disabled && 'disabled')
}));
};
Button.prototype.renderButton = function renderButton(_ref, className) {
var componentClass = _ref.componentClass,
elementProps = _objectWithoutProperties(_ref, ['componentClass']);
var Component = componentClass || 'button';
return React.createElement(Component, _extends({}, elementProps, {
type: elementProps.type || 'button',
className: className
}));
};
Button.prototype.render = function render() {
var _extends2;
var _props = this.props,
active = _props.active,
block = _props.block,
className = _props.className,
props = _objectWithoutProperties(_props, ['active', 'block', 'className']);
var _splitBsProps = splitBsProps(props),
bsProps = _splitBsProps[0],
elementProps = _splitBsProps[1];
var classes = _extends({}, getClassSet(bsProps), (_extends2 = {
active: active
}, _extends2[prefix(bsProps, 'block')] = block, _extends2));
var fullClassName = classNames(className, classes);
if (elementProps.href) {
return this.renderAnchor(elementProps, fullClassName);
}
return this.renderButton(elementProps, fullClassName);
};
return Button;
}(React.Component);
Button.propTypes = propTypes;
Button.defaultProps = defaultProps;
export default bsClass('btn', bsSizes([Size.LARGE, Size.SMALL, Size.XSMALL], bsStyles([].concat(_Object$values(State), [Style.DEFAULT, Style.PRIMARY, Style.LINK]), Style.DEFAULT, Button))); |
app/client/src/routes/createEvent/index.js | uprisecampaigns/uprise-app | import React from 'react';
import CreateAction from 'scenes/CreateAction';
import Layout from 'components/Layout';
import organizeCampaignPaths from 'routes/organizeCampaignPaths';
export default organizeCampaignPaths({
path: '/organize/:slug/create-event',
component: campaign => (
<Layout>
<CreateAction campaignId={campaign.id} type="event" />
</Layout>
),
});
|
app/javascript/mastodon/features/home_timeline/index.js | dunn/mastodon | import React from 'react';
import { connect } from 'react-redux';
import { expandHomeTimeline } from '../../actions/timelines';
import PropTypes from 'prop-types';
import StatusListContainer from '../ui/containers/status_list_container';
import Column from '../../components/column';
import ColumnHeader from '../../components/column_header';
import { addColumn, removeColumn, moveColumn } from '../../actions/columns';
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
import ColumnSettingsContainer from './containers/column_settings_container';
import { Link } from 'react-router-dom';
import { fetchAnnouncements, toggleShowAnnouncements } from 'mastodon/actions/announcements';
import AnnouncementsContainer from 'mastodon/features/getting_started/containers/announcements_container';
import classNames from 'classnames';
import IconWithBadge from 'mastodon/components/icon_with_badge';
const messages = defineMessages({
title: { id: 'column.home', defaultMessage: 'Home' },
show_announcements: { id: 'home.show_announcements', defaultMessage: 'Show announcements' },
hide_announcements: { id: 'home.hide_announcements', defaultMessage: 'Hide announcements' },
});
const mapStateToProps = state => ({
hasUnread: state.getIn(['timelines', 'home', 'unread']) > 0,
isPartial: state.getIn(['timelines', 'home', 'isPartial']),
hasAnnouncements: !state.getIn(['announcements', 'items']).isEmpty(),
unreadAnnouncements: state.getIn(['announcements', 'items']).count(item => !item.get('read')),
showAnnouncements: state.getIn(['announcements', 'show']),
});
export default @connect(mapStateToProps)
@injectIntl
class HomeTimeline extends React.PureComponent {
static propTypes = {
dispatch: PropTypes.func.isRequired,
shouldUpdateScroll: PropTypes.func,
intl: PropTypes.object.isRequired,
hasUnread: PropTypes.bool,
isPartial: PropTypes.bool,
columnId: PropTypes.string,
multiColumn: PropTypes.bool,
hasAnnouncements: PropTypes.bool,
unreadAnnouncements: PropTypes.number,
showAnnouncements: PropTypes.bool,
};
handlePin = () => {
const { columnId, dispatch } = this.props;
if (columnId) {
dispatch(removeColumn(columnId));
} else {
dispatch(addColumn('HOME', {}));
}
}
handleMove = (dir) => {
const { columnId, dispatch } = this.props;
dispatch(moveColumn(columnId, dir));
}
handleHeaderClick = () => {
this.column.scrollTop();
}
setRef = c => {
this.column = c;
}
handleLoadMore = maxId => {
this.props.dispatch(expandHomeTimeline({ maxId }));
}
componentDidMount () {
this.props.dispatch(fetchAnnouncements());
this._checkIfReloadNeeded(false, this.props.isPartial);
}
componentDidUpdate (prevProps) {
this._checkIfReloadNeeded(prevProps.isPartial, this.props.isPartial);
}
componentWillUnmount () {
this._stopPolling();
}
_checkIfReloadNeeded (wasPartial, isPartial) {
const { dispatch } = this.props;
if (wasPartial === isPartial) {
return;
} else if (!wasPartial && isPartial) {
this.polling = setInterval(() => {
dispatch(expandHomeTimeline());
}, 3000);
} else if (wasPartial && !isPartial) {
this._stopPolling();
}
}
_stopPolling () {
if (this.polling) {
clearInterval(this.polling);
this.polling = null;
}
}
handleToggleAnnouncementsClick = (e) => {
e.stopPropagation();
this.props.dispatch(toggleShowAnnouncements());
}
render () {
const { intl, shouldUpdateScroll, hasUnread, columnId, multiColumn, hasAnnouncements, unreadAnnouncements, showAnnouncements } = this.props;
const pinned = !!columnId;
let announcementsButton = null;
if (hasAnnouncements) {
announcementsButton = (
<button
className={classNames('column-header__button', { 'active': showAnnouncements })}
title={intl.formatMessage(showAnnouncements ? messages.hide_announcements : messages.show_announcements)}
aria-label={intl.formatMessage(showAnnouncements ? messages.hide_announcements : messages.show_announcements)}
aria-pressed={showAnnouncements ? 'true' : 'false'}
onClick={this.handleToggleAnnouncementsClick}
>
<IconWithBadge id='bullhorn' count={unreadAnnouncements} />
</button>
);
}
return (
<Column bindToDocument={!multiColumn} ref={this.setRef} label={intl.formatMessage(messages.title)}>
<ColumnHeader
icon='home'
active={hasUnread}
title={intl.formatMessage(messages.title)}
onPin={this.handlePin}
onMove={this.handleMove}
onClick={this.handleHeaderClick}
pinned={pinned}
multiColumn={multiColumn}
extraButton={announcementsButton}
appendContent={hasAnnouncements && showAnnouncements && <AnnouncementsContainer />}
>
<ColumnSettingsContainer />
</ColumnHeader>
<StatusListContainer
trackScroll={!pinned}
scrollKey={`home_timeline-${columnId}`}
onLoadMore={this.handleLoadMore}
timelineId='home'
emptyMessage={<FormattedMessage id='empty_column.home' defaultMessage='Your home timeline is empty! Visit {public} or use search to get started and meet other users.' values={{ public: <Link to='/timelines/public'><FormattedMessage id='empty_column.home.public_timeline' defaultMessage='the public timeline' /></Link> }} />}
shouldUpdateScroll={shouldUpdateScroll}
bindToDocument={!multiColumn}
/>
</Column>
);
}
}
|
jenkins-design-language/src/js/components/material-ui/svg-icons/hardware/speaker.js | alvarolobato/blueocean-plugin | import React from 'react';
import SvgIcon from '../../SvgIcon';
const HardwareSpeaker = (props) => (
<SvgIcon {...props}>
<path d="M17 2H7c-1.1 0-2 .9-2 2v16c0 1.1.9 1.99 2 1.99L17 22c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm-5 2c1.1 0 2 .9 2 2s-.9 2-2 2c-1.11 0-2-.9-2-2s.89-2 2-2zm0 16c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5zm0-8c-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3-1.34-3-3-3z"/>
</SvgIcon>
);
HardwareSpeaker.displayName = 'HardwareSpeaker';
HardwareSpeaker.muiName = 'SvgIcon';
export default HardwareSpeaker;
|
app/components/Chunk.js | kenwilcox/fil | import _ from 'underscore-contrib';
import React from 'react';
import classNames from 'classnames';
import {parseOrFallback} from 'helpers';
class List extends React.Component {
render() {
let block = "console__chunk--list",
output = this.props.chunk;
let classes = classNames(block, {
"console__chunk--set": this.props.isSet
});
return (
<ul className={classes}>
{output.map((item, i) => (
<li className={block + "__item"} key={i}>
<Chunk className={block + "__val"} chunk={item} />
{i < output.length -1 && (
<span className={block + "__separator"}>,</span>
)}
</li>
))}
{!output.length && (
<li className={block + "__item--empty"}></li>
)}
</ul>
);
}
}
class Dict extends React.Component {
render () {
let block = "console__chunk--dict",
output = this.props.chunk;
return (
<table className={block}>
{_.keys(output).map(key => (
<tr key={key} className={block + "__item"}>
<td className={block + "__key"}>{key}:</td>
<td className={block + "__val"}>
<Chunk chunk={output[key]} />
</td>
</tr>
))}
{!_.keys(output).length && (
<tr>
<td className={block + "__item--empty"}></td>
</tr>
)}
</table>
);
}
}
class Chunk extends React.Component {
parse(output) {
return parseOrFallback(output, _ => output);
}
render() {
var output = this.parse(this.props.chunk),
block = "console__chunk",
isString = _.isString(output);
if (_.isArray(output)) {
return <List chunk={output} isSet={this.props.isSet} />;
}
if (_.isObject(output)) {
return <Dict chunk={output} />;
}
if (isString && this.isSet()) {
return <Chunk isSet={true}
chunk={this.setToIterable(output)} />;
}
if (isString && this.isTuple()) {
return <Chunk className={block + "--tuple"}
chunk={this.tupleToIterable(output)} />;
}
let classes = classNames({
[this.props.className || block]: true,
[block + "--builtin"]: isString && this.isBuiltin(),
[block + "--instance"]: isString && this.isInstance(),
[block + "--integer"]: this.isInteger(),
[block + "--float"]: this.isFloat()
});
return (
<span className={classes}>
{output}
</span>
);
}
isSet() {
let chunk = this.props.chunk,
tokens = chunk.slice(0, 4) + chunk.slice(-1);
return tokens == 'set()';
}
isTuple() {
let chunk = this.props.chunk,
tokens = chunk[0] + chunk.slice(-1);
return tokens == '()';
}
isInstance() {
let chunk = this.props.chunk,
tokens = chunk[0] + chunk.slice(-1);
return tokens == '<>';
}
isBuiltin() {
let builtins = ['None', 'True', 'False', 'Infinity'];
return builtins.indexOf(this.props.chunk) > -1;
}
isInteger() {
return Number.isInteger(this.props.chunk);
}
isFloat() {
return !isNaN(parseFloat(this.props.chunk));
}
setToIterable(output) {
return output.slice(4, -1);
}
tupleToIterable(output) {
return `[${output.slice(1, -1)}]`;
}
}
export default Chunk; |
node_modules/react-bootstrap/es/ButtonToolbar.js | ivanhristov92/bookingCalendar | import _extends from 'babel-runtime/helpers/extends';
import _objectWithoutProperties from 'babel-runtime/helpers/objectWithoutProperties';
import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn';
import _inherits from 'babel-runtime/helpers/inherits';
import classNames from 'classnames';
import React from 'react';
import Button from './Button';
import { bsClass, bsSizes, getClassSet, splitBsProps } from './utils/bootstrapUtils';
var ButtonToolbar = function (_React$Component) {
_inherits(ButtonToolbar, _React$Component);
function ButtonToolbar() {
_classCallCheck(this, ButtonToolbar);
return _possibleConstructorReturn(this, _React$Component.apply(this, arguments));
}
ButtonToolbar.prototype.render = function render() {
var _props = this.props,
className = _props.className,
props = _objectWithoutProperties(_props, ['className']);
var _splitBsProps = splitBsProps(props),
bsProps = _splitBsProps[0],
elementProps = _splitBsProps[1];
var classes = getClassSet(bsProps);
return React.createElement('div', _extends({}, elementProps, {
role: 'toolbar',
className: classNames(className, classes)
}));
};
return ButtonToolbar;
}(React.Component);
export default bsClass('btn-toolbar', bsSizes(Button.SIZES, ButtonToolbar)); |
src/Editor/ContentSource.js | skystebnicki/chamel | import React, { Component } from 'react';
import PropTypes from 'prop-types';
import ReactDOM from 'react-dom';
import ThemeService from '../styles/ChamelThemeService';
import EditorToolbar from './EditorToolbar';
import Codemirror from 'react-codemirror';
import 'codemirror/mode/jsx/jsx';
import 'codemirror/lib/codemirror.css';
/**
* Contains codemirror and the toolbar for viewing source
*/
class ContentSource extends Component {
/**
* Set accepted properties
*/
static propTypes = {
/**
* The callback function used when user changes the content of the editor
*
* @type {function}
*/
onChange: PropTypes.func,
/**
* The callback function used when user looses the focus of the editor
*
* @type {function}
*/
onBlur: PropTypes.func,
/**
* The initial value of the content editor
*
* @type {string}
*/
value: PropTypes.string,
/**
* Handles the toggling of content view
*
* @type {function}
*/
onContentViewToggle: PropTypes.func,
};
/**
* An alternate theme may be passed down by a provider
*/
static contextTypes = {
chamelTheme: PropTypes.object,
};
/**
* Class constructor
*
* @param {Object} props Properties to send to the render function
*/
constructor(props) {
// Call parent constructor
super(props);
this.state = {
value: this.props.value,
};
}
/**
* Handle when the editor has changed
*
* @param {string} value The value of the editor
* @private
*/
_onChange = value => {
if (this.props.onChange) {
this.props.onChange(value);
}
this.setState({ value });
};
/**
* Handles the toggling of content view
*
* @param {int} contentView The content view we are switching to
* @private
*/
_handleContentViewToggle = contentView => {
if (this.props.onContentViewToggle) {
this.props.onContentViewToggle(contentView, this.state.value);
}
};
render() {
// Determine which theme to use
let theme =
this.context.chamelTheme && this.context.chamelTheme.editor
? this.context.chamelTheme.editor
: ThemeService.defaultTheme.editor;
let options = {
lineNumbers: true,
};
return (
<div className={theme.richTextContainer}>
<EditorToolbar
contentViewType={this.props.contentViewType}
onContentViewToggle={this._handleContentViewToggle}
/>
<Codemirror value={this.state.value} onChange={this._onChange} options={options} />
</div>
);
}
}
export default ContentSource;
|
frontend/src/components/common/snackbarContainer.js | unicef/un-partner-portal | import React from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import Snackbar from 'material-ui/Snackbar';
import { errorToBeCleared } from '../../reducers/errorReducer';
import { selectAllErrorsMapped } from '../../store';
const SnackbarContainer = (props) => {
const { errors, children, clearError } = props;
return (
<div>
{children}
{errors.map((error, index) => (
<Snackbar
key={`snackbar_${error.id}_${index}`}
anchorOrigin={{
vertical: 'bottom',
horizontal: 'left',
}}
open
message={error.userMessage}
autoHideDuration={4e3 * ((errors.length - index))}
onClose={() => { clearError(error.id); }}
/>))}
</div>
);
};
SnackbarContainer.propTypes = {
children: PropTypes.node,
errors: PropTypes.array,
clearError: PropTypes.func,
};
const mapStateToProps = state => ({
errors: selectAllErrorsMapped(state),
});
const mapDispatchToProps = dispatch => ({
clearError: id => dispatch(errorToBeCleared(id)),
});
export default connect(
mapStateToProps,
mapDispatchToProps,
)(SnackbarContainer);
|
src/components/Main.js | southbeanZ/gallery-by-react | require('normalize.css/normalize.css');
require('styles/App.scss');
import React from 'react';
import ReactDOM from 'react-dom'
// 获取照片数据,并进行url预处理
let imageDatas = require('json!../data/imageDatas.json');
imageDatas = (function(imageDatasArr){
for(var i = 0, len = imageDatasArr.length; i < len; i++) {
var singleImageData = imageDatasArr[i];
singleImageData.imageURL = require('../images/' + singleImageData.fileName);
imageDatasArr[i] = singleImageData;
}
return imageDatasArr;
})(imageDatas);
// 获取区间随机值
function getRandomNum(min, max) {
return Math.floor(Math.random() * (max - min) + min);
}
// 获取0-30°的正负旋转值
function get30RandomDeg() {
return (Math.random() > 0.5 ? '' : '-') + Math.floor(Math.random() * 30);
}
// 照片组件
class ImgFigure extends React.Component {
constructor(props) {
super(props);
this.handleClick = this.handleClick.bind(this);
}
//点击处理函数
handleClick(e) {
if(this.props.arrange.isCenter) {
this.props.inverse();
} else {
this.props.center();
}
e.stopPropagation();
e.preventDefault();
}
render() {
var styleObj = {};
if(this.props.arrange.pos) {
styleObj = this.props.arrange.pos;
}
if(this.props.arrange.rotate) {
(['WebkitTransform', 'MozTransform', 'msTransform', 'OTransform', 'transform']).forEach(function(value) {
styleObj[value] = 'rotate(' + this.props.arrange.rotate + 'deg)';
}.bind(this));
}
if(this.props.arrange.isCenter) {
styleObj['zIndex'] = 11;
}
var imgFigureClassName = 'img-figure';
imgFigureClassName += this.props.arrange.isInverse ? ' is-inverse' : '';
return (
<figure className={imgFigureClassName} style={styleObj} onClick={this.handleClick}>
<img src={this.props.data.imageURL} alt={this.props.data.fileName}/>
<figcaption>
<h2 className="img-title">{this.props.data.title}</h2>
</figcaption>
<div className="img-back" onClick={this.handleClick}>
<p>{this.props.data.desc}</p>
</div>
</figure>
);
}
}
// 控制条组件
class ControllerUnit extends React.Component {
constructor(props) {
super(props);
this.handleClick = this.handleClick.bind(this);
}
handleClick(e) {
if(this.props.arrange.isCenter) {
this.props.inverse();
} else {
this.props.center();
}
e.stopPropagation();
e.preventDefault();
}
render() {
var controllerUnitClassName = 'controller-unit';
if(this.props.arrange.isCenter) {
controllerUnitClassName += ' is-center';
if(this.props.arrange.isInverse) {
controllerUnitClassName += ' is-inverse';
}
}
return (
<span className={controllerUnitClassName} onClick={this.handleClick}></span>
);
}
}
class AppComponent extends React.Component {
constructor(props) {
super(props);
// 画廊舞台分区位置初始化
this.Constant = {
centerPos: { //中心图片位置点
left: 0,
top: 0
},
hPosRange: { // 水平方向左右分区取值范围
leftSecX: [0, 0], // 左分区
rightSecX: [0, 0], // 右分区
y: [0, 0]
},
vPosRange: { // 垂直方向上分区的取值范围
x: [0, 0],
topY: [0, 0]
}
};
this.state = {
imgsArrangeArr: [
// {
// pos: {
// left: '0',
// top: '0'
// },
// rotate: 0,
// isInverse: false,
// isCenter: false
// }
]
}
}
/**
* 居中图片
* @param {num} index 需居中的图片
* @return {Function}
*/
center(index) {
return function() {
this.rearrange(index);
}.bind(this);
}
/**
* 翻转图片
* @param index, 需执行翻转的图片index
* @return {Function}
*/
inverse(index) {
return function() {
var imgsArrangeArr = this.state.imgsArrangeArr;
imgsArrangeArr[index].isInverse = !imgsArrangeArr[index].isInverse;
this.setState({
imgsArrangeArr: imgsArrangeArr
});
}.bind(this);
}
// 重新布局所有图片
rearrange(centerIndex) {
var imgsArrangeArr = this.state.imgsArrangeArr,
Constant = this.Constant,
centerPos = Constant.centerPos,
hPosRange = Constant.hPosRange,
vPosRange = Constant.vPosRange,
hPosRangeLeftSecX = hPosRange.leftSecX,
hPosRangeRightSecX = hPosRange.rightSecX,
hPosRangeY = hPosRange.y,
vPosRangeTopY = vPosRange.topY,
vPosRangeX = vPosRange.x;
// 上分区图片, 0或1个
var imgsArrangeTopArr = [],
topImgNum = Math.floor(Math.random() * 2),
topImgSpliceIndex = 0;
// 居中图片的处理
var imgsArrangeCenterArr = imgsArrangeArr.splice(centerIndex, 1);
imgsArrangeCenterArr[0] = {
pos: centerPos,
rotate: 0,
isCenter: true
}
//上分区图片的处理
topImgSpliceIndex = Math.floor(Math.random() * (imgsArrangeArr.length - topImgNum));
imgsArrangeTopArr = imgsArrangeArr.splice(topImgSpliceIndex, topImgNum);
imgsArrangeTopArr.forEach(function(value, index) {
imgsArrangeTopArr[index] = {
pos: {
left: getRandomNum(vPosRangeX[0], vPosRangeX[1]),
top: getRandomNum(vPosRangeTopY[0], vPosRangeTopY[1])
},
rotate: get30RandomDeg(),
isCenter: false
}
});
//左右分区图片的处理
for(var i = 0, len = imgsArrangeArr.length, mid = len / 2; i < len; i ++) {
var hPosRangeLORX = null;
if(i < mid) {
hPosRangeLORX = hPosRangeLeftSecX;
} else {
hPosRangeLORX = hPosRangeRightSecX;
}
imgsArrangeArr[i] = {
pos: {
left: getRandomNum(hPosRangeLORX[0], hPosRangeLORX[1]),
top: getRandomNum(hPosRangeY[0], hPosRangeY[1])
},
rotate: get30RandomDeg(),
isCenter: false
}
}
// 将之前取出的图片信息插回原序列
if(imgsArrangeTopArr && imgsArrangeTopArr[0]) {
imgsArrangeArr.splice(topImgSpliceIndex, 0, imgsArrangeTopArr[0]);
}
imgsArrangeArr.splice(centerIndex, 0, imgsArrangeCenterArr[0]);
this.setState({
imgsArrangeArr : imgsArrangeArr
});
}
// 组件加载完成后,为每张图片计算相应位置
componentDidMount() {
//获取舞台大小
var stageDOM = ReactDOM.findDOMNode(this.refs.stage),
stageW = stageDOM.scrollWidth,
stageH = stageDOM.scrollHeight,
halfStageW = Math.floor(stageW / 2),
halfStageH = Math.floor(stageH / 2);
//获取imgFigure大小
var imgFigureDOM = ReactDOM.findDOMNode(this.refs.imgFgure0),
imgW = imgFigureDOM.scrollWidth,
imgH = imgFigureDOM.scrollHeight,
halfImgW = Math.floor(imgW / 2),
halfImgH = Math.floor(imgH / 2);
//计算中心图片位置
this.Constant.centerPos.left = halfStageW - halfImgW;
this.Constant.centerPos.top = halfStageH - halfImgH;
//计算左右分区位置范围
this.Constant.hPosRange.leftSecX[0] = -halfImgW;
this.Constant.hPosRange.leftSecX[1] = halfStageW - halfImgW * 3;
this.Constant.hPosRange.rightSecX[0] = halfStageW + halfImgW;
this.Constant.hPosRange.rightSecX[1] = stageW - halfImgW;
this.Constant.hPosRange.y[0] = -halfImgH;
this.Constant.hPosRange.y[1] = stageH - halfImgH;
//计算上分区位置范围
this.Constant.vPosRange.x[0] = halfStageW - imgW;
this.Constant.vPosRange.x[1] = halfStageW;
this.Constant.vPosRange.topY[0] = -halfImgH;
this.Constant.vPosRange.topY[1] = halfStageH - halfImgH * 3;
this.rearrange(0);
}
render() {
var imgFigures =[],
controllerUnits = [];
imageDatas.forEach(function(value, index) {
if(! this.state.imgsArrangeArr[index]) {
// 为每个图片初始化位置到左上角
this.state.imgsArrangeArr[index] = {
pos: {
left: 0,
top: 0
},
rotate: 0,
isInverse: false,
isCenter: false
};
}
imgFigures.push(<ImgFigure key={index} data={value} ref={'imgFgure' + index} arrange={this.state.imgsArrangeArr[index]} inverse={this.inverse(index)} center={this.center(index)}/>);
controllerUnits.push(<ControllerUnit key={index} arrange={this.state.imgsArrangeArr[index]} inverse={this.inverse(index)} center={this.center(index)}/>)
}.bind(this));
return (
<section className="stage" ref="stage">
<section className="img-sec">
{imgFigures}
</section>
<nav className="controller-nav">
{controllerUnits}
</nav>
</section>
);
}
}
AppComponent.defaultProps = {
};
export default AppComponent;
|
src/FormGroup.js | omerts/react-bootstrap | import React from 'react';
import classNames from 'classnames';
class FormGroup extends React.Component {
render() {
let classes = {
'form-group': !this.props.standalone,
'form-group-lg': !this.props.standalone && this.props.bsSize === 'large',
'form-group-sm': !this.props.standalone && this.props.bsSize === 'small',
'has-feedback': this.props.hasFeedback,
'has-success': this.props.bsStyle === 'success',
'has-warning': this.props.bsStyle === 'warning',
'has-error': this.props.bsStyle === 'error'
};
return (
<div className={classNames(classes, this.props.groupClassName)}>
{this.props.children}
</div>
);
}
}
FormGroup.defaultProps = {
standalone: false
};
FormGroup.propTypes = {
standalone: React.PropTypes.bool,
hasFeedback: React.PropTypes.bool,
bsSize (props) {
if (props.standalone && props.bsSize !== undefined) {
return new Error('bsSize will not be used when `standalone` is set.');
}
return React.PropTypes.oneOf(['small', 'medium', 'large'])
.apply(null, arguments);
},
bsStyle: React.PropTypes.oneOf(['success', 'warning', 'error']),
groupClassName: React.PropTypes.string
};
export default FormGroup;
|
cmd/elwinator/src/components/Back.js | 13scoobie/choices | import React from 'react';
import { browserHistory } from 'react-router';
const Back = props =>
<a className="nav-link" onClick={e => {
e.preventDefault(); browserHistory.goBack();
}}>Back</a>;
export default Back
|
packages/react-vis/src/plot/highlight.js | uber/react-vis | import React from 'react';
import PropTypes from 'prop-types';
import AbstractSeries from './series/abstract-series';
import {getAttributeScale} from 'utils/scales-utils';
import {getCombinedClassName} from 'utils/styling-utils';
function getLocs(evt) {
const xLoc = evt.type === 'touchstart' ? evt.pageX : evt.offsetX;
const yLoc = evt.type === 'touchstart' ? evt.pageY : evt.offsetY;
return {xLoc, yLoc};
}
class Highlight extends AbstractSeries {
state = {
dragging: false,
brushArea: {top: 0, right: 0, bottom: 0, left: 0},
brushing: false,
startLocX: 0,
startLocY: 0,
dragArea: null
};
_getDrawArea(xLoc, yLoc) {
const {startLocX, startLocY} = this.state;
const {
enableX,
enableY,
highlightWidth,
highlightHeight,
innerWidth,
innerHeight,
marginLeft,
marginRight,
marginBottom,
marginTop
} = this.props;
const plotHeight = innerHeight + marginTop + marginBottom;
const plotWidth = innerWidth + marginLeft + marginRight;
const touchWidth = highlightWidth || plotWidth;
const touchHeight = highlightHeight || plotHeight;
return {
bottom: enableY ? Math.max(startLocY, yLoc) : touchHeight,
right: enableX ? Math.max(startLocX, xLoc) : touchWidth,
left: enableX ? Math.min(xLoc, startLocX) : 0,
top: enableY ? Math.min(yLoc, startLocY) : 0
};
}
_getDragArea(xLoc, yLoc) {
const {enableX, enableY} = this.props;
const {startLocX, startLocY, dragArea} = this.state;
return {
bottom: dragArea.bottom + (enableY ? yLoc - startLocY : 0),
left: dragArea.left + (enableX ? xLoc - startLocX : 0),
right: dragArea.right + (enableX ? xLoc - startLocX : 0),
top: dragArea.top + (enableY ? yLoc - startLocY : 0)
};
}
_clickedOutsideDrag(xLoc, yLoc) {
const {enableX, enableY} = this.props;
const {
dragArea,
brushArea: {left, right, top, bottom}
} = this.state;
const clickedOutsideDragX = dragArea && (xLoc < left || xLoc > right);
const clickedOutsideDragY = dragArea && (yLoc < top || yLoc > bottom);
if (enableX && enableY) {
return clickedOutsideDragX || clickedOutsideDragY;
}
if (enableX) {
return clickedOutsideDragX;
}
if (enableY) {
return clickedOutsideDragY;
}
return true;
}
_convertAreaToCoordinates(brushArea) {
// NOTE only continuous scales are supported for brushing/getting coordinates back
const {enableX, enableY, marginLeft, marginTop} = this.props;
const xScale = getAttributeScale(this.props, 'x');
const yScale = getAttributeScale(this.props, 'y');
// Ensure that users wishes are being respected about which scales are evaluated
// this is specifically enabled to ensure brushing on mixed categorical and linear
// charts will run as expected
if (enableX && enableY) {
return {
bottom: yScale.invert(brushArea.bottom),
left: xScale.invert(brushArea.left - marginLeft),
right: xScale.invert(brushArea.right - marginLeft),
top: yScale.invert(brushArea.top)
};
}
if (enableY) {
return {
bottom: yScale.invert(brushArea.bottom - marginTop),
top: yScale.invert(brushArea.top - marginTop)
};
}
if (enableX) {
return {
left: xScale.invert(brushArea.left - marginLeft),
right: xScale.invert(brushArea.right - marginLeft)
};
}
return {};
}
startBrushing(e) {
const {onBrushStart, onDragStart, drag} = this.props;
const {dragArea} = this.state;
const {xLoc, yLoc} = getLocs(e.nativeEvent);
const startArea = (dragging, resetDrag) => {
const emptyBrush = {
bottom: yLoc,
left: xLoc,
right: xLoc,
top: yLoc
};
this.setState({
dragging,
brushArea: dragArea && !resetDrag ? dragArea : emptyBrush,
brushing: !dragging,
startLocX: xLoc,
startLocY: yLoc
});
};
const clickedOutsideDrag = this._clickedOutsideDrag(xLoc, yLoc);
if ((drag && !dragArea) || !drag || clickedOutsideDrag) {
startArea(false, clickedOutsideDrag);
if (onBrushStart) {
onBrushStart(e);
}
return;
}
if (drag && dragArea) {
startArea(true, clickedOutsideDrag);
if (onDragStart) {
onDragStart(e);
}
}
}
stopBrushing() {
const {brushing, dragging, brushArea} = this.state;
// Quickly short-circuit if the user isn't brushing in our component
if (!brushing && !dragging) {
return;
}
const {onBrushEnd, onDragEnd, drag} = this.props;
const noHorizontal = Math.abs(brushArea.right - brushArea.left) < 5;
const noVertical = Math.abs(brushArea.top - brushArea.bottom) < 5;
// Invoke the callback with null if the selected area was < 5px
const isNulled = noVertical || noHorizontal;
// Clear the draw area
this.setState({
brushing: false,
dragging: false,
brushArea: drag ? brushArea : {top: 0, right: 0, bottom: 0, left: 0},
startLocX: 0,
startLocY: 0,
dragArea: drag && !isNulled && brushArea
});
if (brushing && onBrushEnd) {
onBrushEnd(!isNulled ? this._convertAreaToCoordinates(brushArea) : null);
}
if (drag && onDragEnd) {
onDragEnd(!isNulled ? this._convertAreaToCoordinates(brushArea) : null);
}
}
onBrush(e) {
const {onBrush, onDrag, drag} = this.props;
const {brushing, dragging} = this.state;
const {xLoc, yLoc} = getLocs(e.nativeEvent);
if (brushing) {
const brushArea = this._getDrawArea(xLoc, yLoc);
this.setState({brushArea});
if (onBrush) {
onBrush(this._convertAreaToCoordinates(brushArea));
}
}
if (drag && dragging) {
const brushArea = this._getDragArea(xLoc, yLoc);
this.setState({brushArea});
if (onDrag) {
onDrag(this._convertAreaToCoordinates(brushArea));
}
}
}
render() {
const {
color,
className,
highlightHeight,
highlightWidth,
highlightX,
highlightY,
innerWidth,
innerHeight,
marginLeft,
marginRight,
marginTop,
marginBottom,
opacity
} = this.props;
const {
brushArea: {left, right, top, bottom}
} = this.state;
let leftPos = 0;
if (highlightX) {
const xScale = getAttributeScale(this.props, 'x');
leftPos = xScale(highlightX);
}
let topPos = 0;
if (highlightY) {
const yScale = getAttributeScale(this.props, 'y');
topPos = yScale(highlightY);
}
const plotWidth = marginLeft + marginRight + innerWidth;
const plotHeight = marginTop + marginBottom + innerHeight;
const touchWidth = highlightWidth || plotWidth;
const touchHeight = highlightHeight || plotHeight;
return (
<g
transform={`translate(${leftPos}, ${topPos})`}
className={getCombinedClassName(className, 'rv-highlight-container')}
>
<rect
className="rv-mouse-target"
fill="black"
opacity="0"
x="0"
y="0"
width={Math.max(touchWidth, 0)}
height={Math.max(touchHeight, 0)}
onMouseDown={e => this.startBrushing(e)}
onMouseMove={e => this.onBrush(e)}
onMouseUp={e => this.stopBrushing(e)}
onMouseLeave={e => this.stopBrushing(e)}
// preventDefault() so that mouse event emulation does not happen
onTouchEnd={e => {
e.preventDefault();
this.stopBrushing(e);
}}
onTouchCancel={e => {
e.preventDefault();
this.stopBrushing(e);
}}
onContextMenu={e => e.preventDefault()}
onContextMenuCapture={e => e.preventDefault()}
/>
<rect
className="rv-highlight"
pointerEvents="none"
opacity={opacity}
fill={color}
x={left}
y={top}
width={Math.min(Math.max(0, right - left), touchWidth)}
height={Math.min(Math.max(0, bottom - top), touchHeight)}
/>
</g>
);
}
}
Highlight.displayName = 'HighlightOverlay';
Highlight.defaultProps = {
color: 'rgb(77, 182, 172)',
className: '',
enableX: true,
enableY: true,
opacity: 0.3
};
Highlight.propTypes = {
...AbstractSeries.propTypes,
enableX: PropTypes.bool,
enableY: PropTypes.bool,
highlightHeight: PropTypes.number,
highlightWidth: PropTypes.number,
highlightX: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
highlightY: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
onBrushStart: PropTypes.func,
onDragStart: PropTypes.func,
onBrush: PropTypes.func,
onDrag: PropTypes.func,
onBrushEnd: PropTypes.func,
onDragEnd: PropTypes.func
};
export default Highlight;
|
src/svg-icons/image/exposure-neg-2.js | IsenrichO/mui-with-arrows | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let ImageExposureNeg2 = (props) => (
<SvgIcon {...props}>
<path d="M15.05 16.29l2.86-3.07c.38-.39.72-.79 1.04-1.18.32-.39.59-.78.82-1.17.23-.39.41-.78.54-1.17s.19-.79.19-1.18c0-.53-.09-1.02-.27-1.46-.18-.44-.44-.81-.78-1.11-.34-.31-.77-.54-1.26-.71-.51-.16-1.08-.24-1.72-.24-.69 0-1.31.11-1.85.32-.54.21-1 .51-1.36.88-.37.37-.65.8-.84 1.3-.18.47-.27.97-.28 1.5h2.14c.01-.31.05-.6.13-.87.09-.29.23-.54.4-.75.18-.21.41-.37.68-.49.27-.12.6-.18.96-.18.31 0 .58.05.81.15.23.1.43.25.59.43.16.18.28.4.37.65.08.25.13.52.13.81 0 .22-.03.43-.08.65-.06.22-.15.45-.29.7-.14.25-.32.53-.56.83-.23.3-.52.65-.88 1.03l-4.17 4.55V18H21v-1.71h-5.95zM2 11v2h8v-2H2z"/>
</SvgIcon>
);
ImageExposureNeg2 = pure(ImageExposureNeg2);
ImageExposureNeg2.displayName = 'ImageExposureNeg2';
ImageExposureNeg2.muiName = 'SvgIcon';
export default ImageExposureNeg2;
|
app/components/Showcase/Item.js | juanda99/arasaac-frontend | /**
*
* Item
*
*/
import React from 'react'
import PropTypes from 'prop-types'
import muiThemeable from 'material-ui/styles/muiThemeable'
import { Link } from 'react-router'
import Paper from 'material-ui/Paper'
import Image from 'components/Image'
import H3 from 'components/H3'
import { grey200 } from 'material-ui/styles/colors'
import FullWidthSection from 'components/FullWidthSection'
class Item extends React.PureComponent { // eslint-disable-line react/prefer-stateless-function
static propTypes = {
title: PropTypes.object.isRequired,
route: PropTypes.string.isRequired,
image: PropTypes.string.isRequired,
muiTheme: PropTypes.object.isRequired,
}
constructor(props) {
super(props)
this.state = { zDepth: 1 }
}
handleMouseEnter = () => {
this.setState({
zDepth: 4
})
}
handleMouseLeave = () => {
this.setState({
zDepth: 1
})
}
render() {
const { title, route, image } = this.props
// if extern route we use an anchor tag
const externalLink = route.includes('http')
const children =
<Paper
zDepth={this.state.zDepth}
onMouseEnter={this.handleMouseEnter}
onMouseLeave={this.handleMouseLeave}
>
<FullWidthSection color={this.props.muiTheme.palette.primary1Color} style={{ paddingBottom: 0, paddingTop: 0 }}>
<H3 style={{ color: 'white' }} >{title}</H3>
</FullWidthSection>
<Image src={image} alt={title} style={{ padding: 20, width: '100%', margin: 0 }} />
</Paper >
return (
<div style={{ margin: '30px' }}>
{
externalLink ? (
<a href={route} target='_blank'>
{children}
</a>
) : (
<Link to={route}>
{children}
</Link >
)
}
</div>
)
}
}
export default muiThemeable()(Item)
|
react/product/src/components/FilterableProductTable.js | kobeCan/practices | import '../css/index.css';
import React from 'react';
import SearchBar from './SearchBar';
import ProductTable from './ProductTable';
class FilterableProductTable extends React.Component {
constructor (props) {
super(props);
this.state = {
isStockOnly: false,
filterText: ''
};
}
handleCheckboxClick = (e) => {
this.setState({
isStockOnly: e.target.checked
})
}
handleInputChange = (e) => {
this.setState({
filterText: e.target.value
});
}
render () {
const { products } = this.props;
const { isStockOnly, filterText } = this.state;
return <div className="product">
<SearchBar
onCbClick={this.handleCheckboxClick}
onInputChange = { this.handleInputChange }/>
<ProductTable
products={products}
filterText={ filterText }
isStockOnly={ isStockOnly }/>
</div>
}
}
export default FilterableProductTable |
app/static/src/diagnostic/TestDiagnosisList.js | SnowBeaver/Vision | import React from 'react';
import Accordion from 'react-bootstrap/lib/Accordion';
import Panel from 'react-bootstrap/lib/Panel';
import {Link} from 'react-router';
import Table from 'react-bootstrap/lib/Table';
import {NotificationContainer, NotificationManager} from 'react-notifications';
import {DATETIME_FORMAT} from './appConstants.js';
var TestDiagnosis = React.createClass({
getInitialState: function () {
return {
items: [],
isVisible: true
};
},
render: function () {
var item = this.props.data;
var diagnosis = item.diagnosis;
return (
<tr>
<td>{item.date_created ? moment(item.date_created).utcOffset(0).format(DATETIME_FORMAT) : ""}</td>
<td>{diagnosis ? diagnosis.code : ""}</td>
<td>
<span title={diagnosis ? diagnosis.name : ""}>
{diagnosis && diagnosis.name ? diagnosis.name.substring(0, 100) : ""}
</span>
</td>
<td>
<span title={diagnosis ? diagnosis.description : ""}>
{diagnosis && diagnosis.description ? diagnosis.description.substring(0, 100) : ""}
</span>
</td>
<td>
<span title={item.diagnosis_notes}>
{item.diagnosis_notes ? item.diagnosis_notes.substring(0, 100) : ""}
</span>
</td>
<td>{item.user ? item.user.name: ""}</td>
<td>
<a href="javascript:void(0)"
className="btn btn-primary btn-xs">
<span className="glyphicon glyphicon-pencil"> </span>
</a>
<a href="javascript:void(0)"
className="btn btn-danger btn-xs">
<span className="glyphicon glyphicon-trash"> </span>
</a>
</td>
</tr>
);
}
});
var GroupedDiagnosisList = React.createClass({
getInitialState: function () {
return {
items: [],
isVisible: true,
accordionOpen: false
};
},
handleChange: function (event, index, value) {
this.setState({
value: event.target.value
})
},
edit: function () {
this.props.editTestForm(this.props.data.id);
},
_changeAccordionState: function (state) {
this.setState({accordionOpen: state});
},
render: function () {
var diagnosis = [];
var testTypeId = this.props.testTypeId;
var panelClass = "pull-right glyphicon glyphicon-chevron-" + (this.state.accordionOpen ? "up" : "down");
for (var i = 0; i < this.props.data.length; i++) {
var item = this.props.data[i];
diagnosis.push(<TestDiagnosis key={item.id}
data={item}
reloadList={this.props.reloadList}/>)
}
return (
<Accordion>
<Panel header={<h3>{this.props.header}<span className={panelClass}> </span></h3>}
key={"diagnosis" + testTypeId}
eventKey={"diagnosis" + testTypeId}
onEnter={() => this._changeAccordionState(true)}
onExit={() => this._changeAccordionState(false)}>
<Table responsive hover id="testDiagnosis">
<thead>
<tr>
<th className="col-md-2">Created on</th>
<th className="col-md-1">Code</th>
<th className="col-md-2">Name</th>
<th className="col-md-2">Diagnosis Description</th>
<th className="col-md-2">Test Diagnosis Description</th>
<th className="col-md-2">Created by</th>
<th className="col-md-1">Actions</th>
</tr>
</thead>
<tbody>
{diagnosis}
</tbody>
</Table>
</Panel>
</Accordion>
);
}
});
var TestDiagnosisList = React.createClass({
getInitialState: function () {
return {
diagnosis: [],
isVisible: true,
accordionOpen: false
};
},
handleChange: function (event, index, value) {
this.setState({
value: event.target.value
})
},
componentWillReceiveProps: function (nextProps) {
var testResultId = nextProps.testResultId;
if (testResultId && testResultId != this.props.testResultId) {
this._updateList(testResultId);
}
},
_updateList: function (testResultId) {
var urlParams = 'test_result_id=' + testResultId;
var url = '/api/v1.0/test_diagnosis/?' + urlParams;
this.serverRequest = $.authorizedGet(url,
function (result) {
this.setState({
diagnosis: result['result']
});
}.bind(this), 'json');
},
componentWillUnmount: function () {
if (this.serverRequest) {
this.serverRequest.abort();
}
},
reloadList: function (testResultId) {
this._updateList(testResultId);
},
_changeAccordionState: function (state) {
this.setState({accordionOpen: state});
},
render: function () {
var diagnosisGroups = [];
var diagnosis = [];
var panelClass = "pull-right glyphicon glyphicon-chevron-" + (this.state.accordionOpen ? "up" : "down");
for (var i = 0; i < this.state.diagnosis.length; i++) {
var item = this.state.diagnosis[i];
if (item.test_type_id) {
if (!diagnosisGroups[item.test_type_id]) {
diagnosisGroups[item.test_type_id] = [];
}
diagnosisGroups[item.test_type_id].push(item);
}
}
for (var i in diagnosisGroups) {
diagnosis.push(<GroupedDiagnosisList key={i}
testTypeId={i}
data={diagnosisGroups[i]}
reloadList={this.props.reloadList}
header={diagnosisGroups[i][0].test_type.name}/>)
}
return (
<div>
<div className="row">
<Accordion >
<Panel header={<h3>Diagnosis<span className={panelClass}> </span></h3>}
key="diagnosisBlock"
eventKey="diagnosisBlock"
onEnter={() => this._changeAccordionState(true)}
onExit={() => this._changeAccordionState(false)}>
{diagnosis}
</Panel>
</Accordion>
</div>
</div>
);
}
});
export default TestDiagnosisList; |
src/containers/App.js | HackDFW/hackdfw-game-frontend | import React from 'react';
import {Link} from 'react-router';
import '../styles/core.scss';
export default class CoreLayout extends React.Component {
render () {
const {dispatch} = this.props;
return (
<div>
{this.props.children}
</div>
);
}
}
|
icon-builder/tpl/SvgIcon.js | gobadiah/material-ui | import React from 'react';
import PureRenderMixin from 'react-addons-pure-render-mixin';
import SvgIcon from '{{{ muiRequireStmt }}}';
const {{className}} = React.createClass({
mixins: [PureRenderMixin],
render() {
return (
<SvgIcon {...this.props}>
{{{paths}}}
</SvgIcon>
);
}
});
export default {{className}};
|
assets/jqwidgets/demos/react/app/chart/bublechart/app.js | juannelisalde/holter | import React from 'react';
import ReactDOM from 'react-dom';
import JqxChart from '../../../jqwidgets-react/react_jqxchart.js';
import JqxDropDownList from '../../../jqwidgets-react/react_jqxdropdownlist.js';
class App extends React.Component {
componentDidMount() {
this.refs.dropDownSerie1Symbol.on('change', (event) => {
let value = event.args.item.value;
this.refs.myChart.seriesGroups()[0].series[0].symbolType = value;
this.refs.myChart.update();
});
this.refs.dropDownSerie2Symbol.on('change', (event) => {
let value = event.args.item.value;
this.refs.myChart.seriesGroups()[0].series[1].symbolType = value;
this.refs.myChart.update();
});
}
render() {
let sampleData = [
{ City: 'New York', SalesQ1: 310500, SalesQ2: 210500, YoYGrowthQ1: 1.05, YoYGrowthQ2: 1.25 },
{ City: 'London', SalesQ1: 120000, SalesQ2: 169000, YoYGrowthQ1: 1.15, YoYGrowthQ2: 0.95 },
{ City: 'Paris', SalesQ1: 205000, SalesQ2: 275500, YoYGrowthQ1: 1.45, YoYGrowthQ2: 1.15 },
{ City: 'Tokyo', SalesQ1: 187000, SalesQ2: 130100, YoYGrowthQ1: 0.45, YoYGrowthQ2: 0.55 },
{ City: 'Berlin', SalesQ1: 187000, SalesQ2: 113000, YoYGrowthQ1: 1.65, YoYGrowthQ2: 1.05 },
{ City: 'San Francisco', SalesQ1: 142000, SalesQ2: 102000, YoYGrowthQ1: 0.75, YoYGrowthQ2: 0.15 },
{ City: 'Chicago', SalesQ1: 171000, SalesQ2: 124000, YoYGrowthQ1: 0.75, YoYGrowthQ2: 0.65 }
];
let padding = { left: 5, top: 5, right: 5, bottom: 5 };
let titlePadding = { left: 90, top: 0, right: 0, bottom: 10 };
let xAxis =
{
dataField: 'City',
valuesOnTicks: false
};
let valueAxis =
{
unitInterval: 50000,
minValue: 50000,
maxValue: 350000,
title: { text: 'Sales ($)<br>' },
labels: {
formatSettings: { prefix: '$', thousandsSeparator: ',' },
horizontalAlignment: 'right'
}
};
let seriesGroups =
[
{
type: 'bubble',
series: [
{ dataField: 'SalesQ1', radiusDataField: 'YoYGrowthQ1', minRadius: 10, maxRadius: 30, displayText: 'Sales in Q1' },
{ dataField: 'SalesQ2', radiusDataField: 'YoYGrowthQ2', minRadius: 10, maxRadius: 30, displayText: 'Sales in Q2' }
]
}
];
let symbolsList = ['circle', 'diamond', 'square', 'triangle_up', 'triangle_down', 'triangle_left', 'triangle_right'];
return (
<div>
<JqxChart ref='myChart' style={{ width: 850, height: 500 }}
title={'Sales by City in Q1 and Q2, and YoY sales growth'} description={'(the size of the circles represents relative YoY growth)'}
showLegend={true} enableAnimations={true} padding={padding}
titlePadding={titlePadding} source={sampleData} xAxis={xAxis}
valueAxis={valueAxis} colorScheme={'scheme04'} seriesGroups={seriesGroups}
/>
<table style={{ width: 550 }}>
<tbody>
<tr>
<td>
<p>Select Serie 1 Symbol:</p>
<JqxDropDownList ref='dropDownSerie1Symbol'
width={200} height={25} selectedIndex={0}
dropDownHeight={100} source={symbolsList}
/>
</td>
<td>
<p>Select Serie 2 Symbol:</p>
<JqxDropDownList ref='dropDownSerie2Symbol'
width={200} height={25} selectedIndex={0}
dropDownHeight={100} source={symbolsList}
/>
</td>
</tr>
</tbody>
</table>
</div>
)
}
}
ReactDOM.render(<App />, document.getElementById('app'));
|
admin/client/App/screens/Item/components/FooterBar.js | trentmillar/keystone | import React from 'react';
import blacklist from 'blacklist';
import assign from 'object-assign';
var FooterBar = React.createClass({
propTypes: {
style: React.PropTypes.object,
},
getDefaultProps () {
return {
style: {},
};
},
getInitialState () {
return {
position: 'relative',
width: 'auto',
height: 'auto',
top: 0,
};
},
componentDidMount () {
// Bail in IE8 because React doesn't support the onScroll event in that browser
// Conveniently (!) IE8 doesn't have window.getComputedStyle which we also use here
if (!window.getComputedStyle) return;
var footer = this.refs.footer;
this.windowSize = this.getWindowSize();
var footerStyle = window.getComputedStyle(footer);
this.footerSize = {
x: footer.offsetWidth,
y: footer.offsetHeight + parseInt(footerStyle.marginTop || '0'),
};
window.addEventListener('scroll', this.recalcPosition, false);
window.addEventListener('resize', this.recalcPosition, false);
this.recalcPosition();
},
componentWillUnmount () {
window.removeEventListener('scroll', this.recalcPosition, false);
window.removeEventListener('resize', this.recalcPosition, false);
},
getWindowSize () {
return {
x: window.innerWidth,
y: window.innerHeight,
};
},
recalcPosition () {
var wrapper = this.refs.wrapper;
this.footerSize.x = wrapper.offsetWidth;
var offsetTop = 0;
var offsetEl = wrapper;
while (offsetEl) {
offsetTop += offsetEl.offsetTop;
offsetEl = offsetEl.offsetParent;
}
var maxY = offsetTop + this.footerSize.y;
var viewY = window.scrollY + window.innerHeight;
var newSize = this.getWindowSize();
var sizeChanged = (newSize.x !== this.windowSize.x || newSize.y !== this.windowSize.y);
this.windowSize = newSize;
var newState = {
width: this.footerSize.x,
height: this.footerSize.y,
};
if (viewY > maxY && (sizeChanged || this.mode !== 'inline')) {
this.mode = 'inline';
newState.top = 0;
newState.position = 'absolute';
this.setState(newState);
} else if (viewY <= maxY && (sizeChanged || this.mode !== 'fixed')) {
this.mode = 'fixed';
newState.top = window.innerHeight - this.footerSize.y;
newState.position = 'fixed';
this.setState(newState);
}
},
render () {
var wrapperStyle = {
height: this.state.height,
marginTop: 60,
position: 'relative',
};
var footerProps = blacklist(this.props, 'children', 'style');
var footerStyle = assign({}, this.props.style, {
position: this.state.position,
top: this.state.top,
width: this.state.width,
height: this.state.height,
});
return (
<div ref="wrapper" style={wrapperStyle}>
<div ref="footer" style={footerStyle} {...footerProps}>{this.props.children}</div>
</div>
);
},
});
module.exports = FooterBar;
|
packages/plutarch/tpls/dva-project/src/router.js | Alfred-sg/plutarch | import React from 'react'
import PropTypes from 'prop-types'
import { Switch, Route, Redirect, routerRedux } from 'dva/router'
import dynamic from 'dva/dynamic'
import App from 'routes/app'
const { ConnectedRouter } = routerRedux
const Routers = function ({ history, app }) {
const routes = [
{
path: '/demo',
models: () => [import('./models/demo')],
component: () => import('./routes/demo'),
}
]
return (
<ConnectedRouter history={history}>
<App>
<Switch>
<Route exact path="/" render={() => (<Redirect to="/demo" />)} />
{
routes.map(({ path, ...dynamics }, key) => (
<Route key={key}
exact
path={path}
component={dynamic({
app,
...dynamics,
})}
/>
))
}
</Switch>
</App>
</ConnectedRouter>
)
}
Routers.propTypes = {
history: PropTypes.object,
app: PropTypes.object,
}
export default Routers |
examples/js/advance/edit-type-table.js | neelvadgama-hailo/react-bootstrap-table | /* eslint max-len: 0 */
import React from 'react';
import { BootstrapTable, TableHeaderColumn } from 'react-bootstrap-table';
const jobs = [];
const jobTypes = [ 'A', 'B', 'C', 'D' ];
function addJobs(quantity) {
const startId = jobs.length;
for (let i = 0; i < quantity; i++) {
const id = startId + i;
jobs.push({
id: id,
name: 'Item name ' + id,
type: 'B',
active: i % 2 === 0 ? 'Y' : 'N',
datetime: '200' + i + '-12-28T14:57:00'
});
}
}
addJobs(5);
const cellEditProp = {
mode: 'click',
blurToSave: true
};
export default class EditTypeTable extends React.Component {
render() {
return (
<BootstrapTable data={ jobs } cellEdit={ cellEditProp }>
<TableHeaderColumn dataField='id' isKey={ true }>Job ID</TableHeaderColumn>
<TableHeaderColumn dataField='name' editable={ { type: 'textarea' } }>Job Name</TableHeaderColumn>
<TableHeaderColumn dataField='type' editable={ { type: 'select', options: { values: jobTypes } } }>Job Type</TableHeaderColumn>
<TableHeaderColumn dataField='active' editable={ { type: 'checkbox', options: { values: 'Y:N' } } }>Active</TableHeaderColumn>
<TableHeaderColumn dataField='datetime' editable={ { type: 'datetime' } }>Date Time</TableHeaderColumn>
</BootstrapTable>
);
}
}
|
packages/reactor-kitchensink/src/examples/Charts/3DColumn/3DGrouped/3DGrouped.js | markbrocato/extjs-reactor | import React, { Component } from 'react';
import { Container } from '@extjs/ext-react';
import { Cartesian } from '@extjs/ext-react-charts';
import ChartToolbar from '../../ChartToolbar';
export default class Grouped extends Component {
store = Ext.create('Ext.data.Store', {
fields: ['quarter', '2013', '2014'],
data: [
{ quarter: 'Q1', 2013: 42000, 2014: 68000},
{ quarter: 'Q2', 2013: 50000, 2014: 85000},
{ quarter: 'Q3', 2013: 53000, 2014: 72000},
{ quarter: 'Q4', 2013: 63000, 2014: 89000}
]
})
onAxisLabelRender = (axis, label, layoutContext) => {
// Custom renderer overrides the native axis label renderer.
// Since we don't want to do anything fancy with the value
// ourselves except adding a thousands separator, but at the same time
// don't want to loose the formatting done by the native renderer,
// we let the native renderer process the value first.
const value = layoutContext.renderer(label) / 1000;
return value === 0 ? '$0' : Ext.util.Format.number(value, '$0K');
}
render() {
return (
<Container padding={!Ext.os.is.Phone && 10} layout="fit">
<ChartToolbar downloadChartRef={this.refs.chart}/>
<Cartesian
shadow
ref="chart"
store={this.store}
theme="Muted"
insetPadding="70 40 0 10"
interactions="itemhighlight"
animation={{ duration: 200 }}
legend={{ type: 'sprite' }}
captions={{
title: {
text: 'Sales in Last Two Years'
},
subtitle: {
text: 'Quarter-wise comparison',
}
}}
axes={[{
type: 'numeric3d',
position: 'left',
fields: ['2013', '2014'],
grid: true,
title: 'Sales in USD',
renderer: this.onAxisLabelRender
}, {
type: 'category3d',
position: 'bottom',
fields: 'quarter',
title: 'Quarter',
grid: true
}]}
series={[{
type: 'bar3d',
stacked: false,
title: ['Previous Year', 'Current Year'],
xField: 'quarter',
yField: ['2013', '2014'],
label: {
field: ['2013', '2014'],
display: 'insideEnd',
renderer: value => Ext.util.Format.number(value / 1000, '$0K')
},
highlight: true
}]}
/>
</Container>
)
}
} |
example/components/events.js | boromisp/react-leaflet | import React, { Component } from 'react';
import { Map, TileLayer, Marker, Popup } from '../../src';
export default class EventsExample extends Component {
constructor() {
super();
this.state = {
hasLocation: false,
latlng: {
lat: 51.505,
lng: -0.09,
},
};
}
handleClick() {
this.refs.map.leafletElement.locate();
}
handleLocationFound(e) {
this.setState({
hasLocation: true,
latlng: e.latlng,
});
}
render() {
const marker = this.state.hasLocation
? <Marker position={this.state.latlng}>
<Popup>
<span>You are here</span>
</Popup>
</Marker>
: null;
return (
<Map
center={this.state.latlng}
length={4}
onClick={::this.handleClick}
onLocationfound={::this.handleLocationFound}
ref='map'
zoom={13}>
<TileLayer
attribution='© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
url='http://{s}.tile.osm.org/{z}/{x}/{y}.png'
/>
{marker}
</Map>
);
}
}
|
stories/Tooltip_New/Core/ExampleTheme.js | skyiea/wix-style-react | import React from 'react';
import {Tooltip} from 'wix-style-react';
import styles from './Example.scss';
export default () =>
<div>
<Tooltip active placement="right" alignment="center" content="Dark Theme" showTrigger="custom" hideTrigger="custom" theme="dark">
<div className={styles.box}>Dark Theme</div>
</Tooltip>
<br/>
<Tooltip active placement="right" alignment="center" content="Error Theme" showTrigger="custom" hideTrigger="custom" theme="error">
<div className={styles.box}>Error Theme</div>
</Tooltip>
</div>;
|
packages/material-ui-icons/src/MicNone.js | dsslimshaddy/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from 'material-ui/SvgIcon';
let MicNone = props =>
<SvgIcon {...props}>
<path d="M12 14c1.66 0 2.99-1.34 2.99-3L15 5c0-1.66-1.34-3-3-3S9 3.34 9 5v6c0 1.66 1.34 3 3 3zm-1.2-9.1c0-.66.54-1.2 1.2-1.2.66 0 1.2.54 1.2 1.2l-.01 6.2c0 .66-.53 1.2-1.19 1.2-.66 0-1.2-.54-1.2-1.2V4.9zm6.5 6.1c0 3-2.54 5.1-5.3 5.1S6.7 14 6.7 11H5c0 3.41 2.72 6.23 6 6.72V21h2v-3.28c3.28-.48 6-3.3 6-6.72h-1.7z" />
</SvgIcon>;
MicNone = pure(MicNone);
MicNone.muiName = 'SvgIcon';
export default MicNone;
|
front/app/app/rh-components/rh-Accordion.js | nudoru/React-Starter-2-app | import React from 'react';
import AnimateHeight from 'react-animate-height';
import PropTypes from 'prop-types';
import { is } from 'ramda';
const isString = (str) => is(String, str);
/**
* The title prop can either be a string or another components (single line of text)
*/
class Accordion extends React.Component {
constructor (props) {
super(props);
this.state = {active: props.active};
}
componentWillReceiveProps (nextProps) {
if (nextProps.active !== this.props.active) {
this.setState({active: nextProps.active});
}
}
_onTitleClick () {
this.setState({active: !this.state.active});
}
render () {
let contentHeight = this.state.active ? 'auto' : 0,
icon = this.state.active ? 'chevron-down' : 'chevron-right',
title = isString(this.props.title) ?
<h1>{this.props.title}</h1> : this.props.title,
clsName = 'rh-accordion ' + this.props.className;
return (<section className={clsName}>
<div className="rh-panel-header"
onClick={this._onTitleClick.bind(this)}>
<div className="rh-panel-header-icon"><i className={'fa fa-' + icon}/>
</div>
<div className="rh-panel-header-label">
{title}
</div>
</div>
<AnimateHeight
duration={250}
height={contentHeight}
contentClassName={'rh-panel-content'}>
{this.state.active ? this.props.children : <div/>}
</AnimateHeight>
</section>);
}
}
Accordion.defaultProps = {
title : 'Accordion Title',
active : false,
className: ''
};
Accordion.propTypes = {
title : PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
active : PropTypes.bool,
className: PropTypes.string
};
export default Accordion;
export const AccordionVGroup = ({children}) => <div
className="rh-accordion-vgroup">{children}</div>; |
node_modules/react-router/es6/Redirect.js | aimanaiman/supernomadfriendsquad | import React from 'react';
import invariant from 'invariant';
import { createRouteFromReactElement as _createRouteFromReactElement } from './RouteUtils';
import { formatPattern } from './PatternUtils';
import { falsy } from './InternalPropTypes';
var _React$PropTypes = React.PropTypes;
var string = _React$PropTypes.string;
var object = _React$PropTypes.object;
/**
* A <Redirect> is used to declare another URL path a client should
* be sent to when they request a given URL.
*
* Redirects are placed alongside routes in the route configuration
* and are traversed in the same manner.
*/
var Redirect = React.createClass({
displayName: 'Redirect',
statics: {
createRouteFromReactElement: function createRouteFromReactElement(element) {
var route = _createRouteFromReactElement(element);
if (route.from) route.path = route.from;
route.onEnter = function (nextState, replace) {
var location = nextState.location;
var params = nextState.params;
var pathname = void 0;
if (route.to.charAt(0) === '/') {
pathname = formatPattern(route.to, params);
} else if (!route.to) {
pathname = location.pathname;
} else {
var routeIndex = nextState.routes.indexOf(route);
var parentPattern = Redirect.getRoutePattern(nextState.routes, routeIndex - 1);
var pattern = parentPattern.replace(/\/*$/, '/') + route.to;
pathname = formatPattern(pattern, params);
}
replace({
pathname: pathname,
query: route.query || location.query,
state: route.state || location.state
});
};
return route;
},
getRoutePattern: function getRoutePattern(routes, routeIndex) {
var parentPattern = '';
for (var i = routeIndex; i >= 0; i--) {
var route = routes[i];
var pattern = route.path || '';
parentPattern = pattern.replace(/\/*$/, '/') + parentPattern;
if (pattern.indexOf('/') === 0) break;
}
return '/' + parentPattern;
}
},
propTypes: {
path: string,
from: string, // Alias for path
to: string.isRequired,
query: object,
state: object,
onEnter: falsy,
children: falsy
},
/* istanbul ignore next: sanity check */
render: function render() {
!false ? process.env.NODE_ENV !== 'production' ? invariant(false, '<Redirect> elements are for router configuration only and should not be rendered') : invariant(false) : void 0;
}
});
export default Redirect; |
src/svg-icons/maps/navigation.js | w01fgang/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let MapsNavigation = (props) => (
<SvgIcon {...props}>
<path d="M12 2L4.5 20.29l.71.71L12 18l6.79 3 .71-.71z"/>
</SvgIcon>
);
MapsNavigation = pure(MapsNavigation);
MapsNavigation.displayName = 'MapsNavigation';
MapsNavigation.muiName = 'SvgIcon';
export default MapsNavigation;
|
src/Parser/Priest/Holy/Modules/Items/XanshiCloak.js | hasseboulen/WoWAnalyzer | import React from 'react';
import ITEMS from 'common/ITEMS';
import SPELLS from 'common/SPELLS';
import Analyzer from 'Parser/Core/Analyzer';
import Combatants from 'Parser/Core/Modules/Combatants';
import ItemHealingDone from 'Main/ItemHealingDone';
import ItemManaGained from 'Main/ItemManaGained';
class XanshiCloak extends Analyzer {
static dependencies = {
combatants: Combatants,
};
_xanshiActive = false;
healing = 0;
overhealing = 0;
absorbed = 0;
manaSaved = 0;
casts = [];
on_initialized() {
this.active = this.combatants.selected.hasBack(ITEMS.XANSHI_CLOAK.id);
}
on_byPlayer_removebuff(event) {
const spellId = event.ability.guid;
if (spellId !== SPELLS.XANSHI_CLOAK_BUFF.id) {
return;
}
this._xanshiActive = false;
}
on_byPlayer_applybuff(event) {
const spellId = event.ability.guid;
if (spellId !== SPELLS.XANSHI_CLOAK_BUFF.id) {
return;
}
this._xanshiActive = true;
}
on_byPlayer_heal(event) {
if (!this._xanshiActive) { return; }
this.healing += event.amount || 0;
this.overhealing += event.overheal || 0;
this.absorbed += event.absorbed || 0;
}
on_byPlayer_cast(event) {
if (!this._xanshiActive) { return; }
this.manaSaved += event.rawManaCost || 0;
this.casts.push(event.ability.guid);
}
item() {
return {
item: ITEMS.XANSHI_CLOAK,
result: (
<dfn data-tip="Value of spells cast during the cloak's buff. Does not assume all healing after cloak ends would be a result of the cloak.">
<ItemHealingDone amount={this.healing} /><br />
<ItemManaGained amount={this.manaSaved} />
</dfn>
),
};
}
}
export default XanshiCloak;
|
local-cli/templates/HelloWorld/index.ios.js | cpunion/react-native | /**
* Sample React Native App
* https://github.com/facebook/react-native
* @flow
*/
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
Text,
View
} from 'react-native';
export default class HelloWorld extends Component {
render() {
return (
<View style={styles.container}>
<Text style={styles.welcome}>
Welcome to React Native!
</Text>
<Text style={styles.instructions}>
To get started, edit index.ios.js
</Text>
<Text style={styles.instructions}>
Press Cmd+R to reload,{'\n'}
Cmd+D or shake for dev menu
</Text>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
welcome: {
fontSize: 20,
textAlign: 'center',
margin: 10,
},
instructions: {
textAlign: 'center',
color: '#333333',
marginBottom: 5,
},
});
AppRegistry.registerComponent('HelloWorld', () => HelloWorld);
|
templates/re-start/src/App.js | react-everywhere/re-start | import React from 'react';
import {Provider} from "react-redux";
import EntryScreen from './screens/EntryScreen';
import store from "./utilities/storage/store";
import Routing, {Router} from './utilities/routing/index';
const Route = Routing.Route;
class App extends React.Component {
render() {
return (
<Provider store={store}>
<Router>
<Route path='/' component={EntryScreen}/>
</Router>
</Provider>
);
}
}
export default App;
|
components/circle/index.js | ElemeFE/react-amap | // @flow
import React from 'react'
import withPropsReactive from '../utils/withPropsReactive'
import log from '../utils/log'
import { toLnglat } from '../utils/common'
/*
* props
* {
* __map__ 父级组件传过来的地图实例
* }
*/
const configurableProps = [
'center',
'radius',
'draggable',
'extData',
/* 原生的接口中并没有这些对象,这是本组件的扩展 */
'visible',
'style'
]
const allProps = configurableProps.concat([
'zIndex',
'bubble'
])
type CircleProps = {
__map__: Object,
__ele__: HTMLElement,
center?: LngLat,
onInstanceCreated?: Function,
radius: number,
draggable?: boolean,
extData: any,
visible?: boolean,
style?: Object,
zIndex?: number,
bubble: boolean,
events?: Object,
children: any,
}
class Circle extends React.Component<CircleProps, {loaded: boolean}> {
props: CircleProps
map: Object
element: HTMLElement
mapCircle: Object
setterMap: Object
converterMap: Object
constructor(props: CircleProps) {
super(props)
if (typeof window !== 'undefined') {
if (!props.__map__) {
log.warning('MAP_INSTANCE_REQUIRED')
} else {
const self = this
this.setterMap = {
visible(val) {
if (self.mapCircle) {
if (val) {
self.mapCircle.show()
} else {
self.mapCircle.hide()
}
}
},
style(val) {
self.mapCircle && self.mapCircle.setOptions(val)
}
}
this.converterMap = {
center: toLnglat
}
this.state = {
loaded: false
}
this.map = props.__map__
this.element = this.map.getContainer()
this.createInstance(props).then(() => {
this.setState({
loaded: true
})
this.props.onInstanceCreated && this.props.onInstanceCreated()
})
}
}
}
get instance() {
return this.mapCircle
}
createInstance(props: CircleProps) {
const options = this.buildCreateOptions(props)
options.map = this.map
this.mapCircle = new window.AMap.Circle(options)
return Promise.resolve(this.mapCircle)
}
buildCreateOptions(props: CircleProps) {
const options = {}
allProps.forEach((key) => {
if (key in props) {
if (key === 'style' && (props.style !== undefined)) {
const styleItem = Object.keys(props.style)
styleItem.forEach((item) => {
// $FlowFixMe
options[item] = props.style[item]
})
} else {
options[key] = this.getSetterValue(key, props)
}
}
})
return options
}
getSetterValue(key: string, props: CircleProps) {
if (key in this.converterMap) {
return this.converterMap[key](props[key])
}
return props[key]
}
renderEditor(children: any) {
if (!children) {
return null
}
if (React.Children.count(children) !== 1) {
return null
}
return React.cloneElement(React.Children.only(children), {
__circle__: this.mapCircle,
__map__: this.map,
__ele__: this.element
})
}
render() {
return this.state.loaded ? (this.renderEditor(this.props.children)) : null
}
}
export default withPropsReactive(Circle)
|
packages/web/src/components/shared/ListenSvg.js | appbaseio/reactivesearch | import React from 'react';
import { Global, css } from '@emotion/core';
const ListenSvg = props => (
<React.Fragment>
<Global
styles={css`
@-webkit-keyframes kf_el_6WKby7wXqV_an_qqO-rxbNc {
0% {
opacity: 0;
}
13.89% {
opacity: 1;
}
100% {
opacity: 1;
}
}
@keyframes kf_el_6WKby7wXqV_an_qqO-rxbNc {
0% {
opacity: 0;
}
13.89% {
opacity: 1;
}
100% {
opacity: 1;
}
}
@-webkit-keyframes kf_el_Wi-my975tM_an_XhXP1epXB {
0% {
opacity: 0;
}
27.78% {
opacity: 1;
}
100% {
opacity: 1;
}
}
@keyframes kf_el_Wi-my975tM_an_XhXP1epXB {
0% {
opacity: 0;
}
27.78% {
opacity: 1;
}
100% {
opacity: 1;
}
}
@-webkit-keyframes kf_el_DkfFFTaFxy8_an_T2XxzvIaA {
0% {
opacity: 0;
}
41.67% {
opacity: 1;
}
100% {
opacity: 1;
}
}
@keyframes kf_el_DkfFFTaFxy8_an_T2XxzvIaA {
0% {
opacity: 0;
}
41.67% {
opacity: 1;
}
100% {
opacity: 1;
}
}
@-webkit-keyframes kf_el_34IgwiMB5rf_an_TPom3H2LI {
0% {
opacity: 0;
}
55.56% {
opacity: 1;
}
100% {
opacity: 1;
}
}
@keyframes kf_el_34IgwiMB5rf_an_TPom3H2LI {
0% {
opacity: 0;
}
55.56% {
opacity: 1;
}
100% {
opacity: 1;
}
}
@-webkit-keyframes kf_el_DeebuCsPTGA_an_aYTRBE7Na {
0% {
opacity: 0;
}
69.44% {
opacity: 1;
}
100% {
opacity: 1;
}
}
@keyframes kf_el_DeebuCsPTGA_an_aYTRBE7Na {
0% {
opacity: 0;
}
69.44% {
opacity: 1;
}
100% {
opacity: 1;
}
}
@-webkit-keyframes kf_el_ZOjjrPTvyrv_an_l_BjBNzXw {
0% {
opacity: 0;
}
83.33% {
opacity: 1;
}
100% {
opacity: 1;
}
}
@keyframes kf_el_ZOjjrPTvyrv_an_l_BjBNzXw {
0% {
opacity: 0;
}
83.33% {
opacity: 1;
}
100% {
opacity: 1;
}
}
@-webkit-keyframes kf_el_2FATegVmf0K_an_wLg4ofuFx {
0% {
opacity: 0;
}
97.22% {
opacity: 1;
}
100% {
opacity: 1;
}
}
@keyframes kf_el_2FATegVmf0K_an_wLg4ofuFx {
0% {
opacity: 0;
}
97.22% {
opacity: 1;
}
100% {
opacity: 1;
}
}
#el_hiibMG0x- * {
-webkit-animation-duration: 1.2s;
animation-duration: 1.2s;
-webkit-animation-iteration-count: infinite;
animation-iteration-count: infinite;
-webkit-animation-timing-function: cubic-bezier(0, 0, 1, 1);
animation-timing-function: cubic-bezier(0, 0, 1, 1);
}
#el_QJeJ_2CDw5 {
stroke: none;
stroke-width: 1;
fill: none;
}
#el_UYYCfubTRf {
-webkit-transform: translate(163px, 123px);
transform: translate(163px, 123px);
}
#el_uzZNtK32Zi {
fill: #d8d8d8;
}
#el_EYKQ2N9Kgy {
fill: #d8d8d8;
}
#el_6SDP2LAgKC {
-webkit-transform: translate(37.846924px, 0px);
transform: translate(37.846924px, 0px);
}
#el_-Vm65Ltfy7 {
fill: #2196f3;
}
#el_q04iZcSim4 {
fill: #d8d8d8;
}
#el_6WKby7wXqV {
-webkit-transform: translate(37.846924px, 0px);
transform: translate(37.846924px, 0px);
-webkit-animation-fill-mode: backwards;
animation-fill-mode: backwards;
opacity: 0;
-webkit-animation-name: kf_el_6WKby7wXqV_an_qqO-rxbNc;
animation-name: kf_el_6WKby7wXqV_an_qqO-rxbNc;
-webkit-animation-timing-function: cubic-bezier(0.42, 0, 1, 1);
animation-timing-function: cubic-bezier(0.42, 0, 1, 1);
}
#el_9bggsfQOtU {
fill: #2196f3;
}
#el_NKxqi9eIym {
fill: #d8d8d8;
}
#el_Wi-my975tM {
-webkit-transform: translate(37.846924px, 0px);
transform: translate(37.846924px, 0px);
-webkit-animation-fill-mode: backwards;
animation-fill-mode: backwards;
opacity: 0;
-webkit-animation-name: kf_el_Wi-my975tM_an_XhXP1epXB;
animation-name: kf_el_Wi-my975tM_an_XhXP1epXB;
-webkit-animation-timing-function: cubic-bezier(0.42, 0, 1, 1);
animation-timing-function: cubic-bezier(0.42, 0, 1, 1);
}
#el_zclQ34fvf7 {
fill: #2196f3;
}
#el_1OsvRT8HkeZ {
fill: #d8d8d8;
}
#el_DkfFFTaFxy8 {
-webkit-transform: translate(37.846924px, 0px);
transform: translate(37.846924px, 0px);
-webkit-animation-fill-mode: backwards;
animation-fill-mode: backwards;
opacity: 0;
-webkit-animation-name: kf_el_DkfFFTaFxy8_an_T2XxzvIaA;
animation-name: kf_el_DkfFFTaFxy8_an_T2XxzvIaA;
-webkit-animation-timing-function: cubic-bezier(0.42, 0, 1, 1);
animation-timing-function: cubic-bezier(0.42, 0, 1, 1);
}
#el_aa9sjx4H0vA {
fill: #2196f3;
}
#el_tea114vWg0J {
fill: #d8d8d8;
}
#el_34IgwiMB5rf {
-webkit-transform: translate(37.846924px, 0px);
transform: translate(37.846924px, 0px);
-webkit-animation-fill-mode: backwards;
animation-fill-mode: backwards;
opacity: 0;
-webkit-animation-name: kf_el_34IgwiMB5rf_an_TPom3H2LI;
animation-name: kf_el_34IgwiMB5rf_an_TPom3H2LI;
-webkit-animation-timing-function: cubic-bezier(0.42, 0, 1, 1);
animation-timing-function: cubic-bezier(0.42, 0, 1, 1);
}
#el_z5u6RAFhx7d {
fill: #2196f3;
}
#el_7nfuWmA5Uhy {
fill: #d8d8d8;
}
#el_DeebuCsPTGA {
-webkit-transform: translate(37.846924px, 0px);
transform: translate(37.846924px, 0px);
-webkit-animation-fill-mode: backwards;
animation-fill-mode: backwards;
opacity: 0;
-webkit-animation-name: kf_el_DeebuCsPTGA_an_aYTRBE7Na;
animation-name: kf_el_DeebuCsPTGA_an_aYTRBE7Na;
-webkit-animation-timing-function: cubic-bezier(0.42, 0, 1, 1);
animation-timing-function: cubic-bezier(0.42, 0, 1, 1);
}
#el__ZcqlS20zcw {
fill: #2196f3;
}
#el_8DnEQnD7VWV {
fill: #d8d8d8;
}
#el_ZOjjrPTvyrv {
-webkit-transform: translate(37.846924px, 0px);
transform: translate(37.846924px, 0px);
-webkit-animation-fill-mode: backwards;
animation-fill-mode: backwards;
opacity: 0;
-webkit-animation-name: kf_el_ZOjjrPTvyrv_an_l_BjBNzXw;
animation-name: kf_el_ZOjjrPTvyrv_an_l_BjBNzXw;
-webkit-animation-timing-function: cubic-bezier(0.42, 0, 1, 1);
animation-timing-function: cubic-bezier(0.42, 0, 1, 1);
}
#el_FYYKCI_u24e {
fill: #2196f3;
}
#el_XZty4MnTp5Y {
fill: #d8d8d8;
}
#el_2FATegVmf0K {
-webkit-transform: translate(37.846924px, 0px);
transform: translate(37.846924px, 0px);
-webkit-animation-fill-mode: backwards;
animation-fill-mode: backwards;
opacity: 0;
-webkit-animation-name: kf_el_2FATegVmf0K_an_wLg4ofuFx;
animation-name: kf_el_2FATegVmf0K_an_wLg4ofuFx;
-webkit-animation-timing-function: cubic-bezier(0.42, 0, 1, 1);
animation-timing-function: cubic-bezier(0.42, 0, 1, 1);
}
#el_RMT1KUfbdF8 {
fill: #2196f3;
}
#el_RgLcovvFiO1 {
fill: #d8d8d8;
}
`}
/>
<svg
viewBox="0 0 480 480"
xmlns="http://www.w3.org/2000/svg"
xmlnsXlink="http://www.w3.org/1999/xlink"
id="el_hiibMG0x-"
width={28}
height={29}
{...props}
style={{ transform: 'scale(1.5)' }}
>
<defs>
<path
d="M38.779092,147.789474 C60.0824253,147.789474 77.279092,131.286316 77.279092,110.842105 L77.279092,36.9473684 C77.279092,16.5031579 60.0824253,0 38.779092,0 C17.4757586,0 0.279091964,16.5031579 0.279091964,36.9473684 L0.279091964,110.842105 C0.279091964,131.286316 17.4757586,147.789474 38.779092,147.789474 Z"
id="path-1"
/>
<path
d="M38.779092,147.789474 C60.0824253,147.789474 77.279092,131.286316 77.279092,110.842105 L77.279092,36.9473684 C77.279092,16.5031579 60.0824253,0 38.779092,0 C17.4757586,0 0.279091964,16.5031579 0.279091964,36.9473684 L0.279091964,110.842105 C0.279091964,131.286316 17.4757586,147.789474 38.779092,147.789474 Z"
id="path-3"
/>
<path
d="M38.779092,147.789474 C60.0824253,147.789474 77.279092,131.286316 77.279092,110.842105 L77.279092,36.9473684 C77.279092,16.5031579 60.0824253,0 38.779092,0 C17.4757586,0 0.279091964,16.5031579 0.279091964,36.9473684 L0.279091964,110.842105 C0.279091964,131.286316 17.4757586,147.789474 38.779092,147.789474 Z"
id="path-5"
/>
<path
d="M38.779092,147.789474 C60.0824253,147.789474 77.279092,131.286316 77.279092,110.842105 L77.279092,36.9473684 C77.279092,16.5031579 60.0824253,0 38.779092,0 C17.4757586,0 0.279091964,16.5031579 0.279091964,36.9473684 L0.279091964,110.842105 C0.279091964,131.286316 17.4757586,147.789474 38.779092,147.789474 Z"
id="path-7"
/>
<path
d="M38.779092,147.789474 C60.0824253,147.789474 77.279092,131.286316 77.279092,110.842105 L77.279092,36.9473684 C77.279092,16.5031579 60.0824253,0 38.779092,0 C17.4757586,0 0.279091964,16.5031579 0.279091964,36.9473684 L0.279091964,110.842105 C0.279091964,131.286316 17.4757586,147.789474 38.779092,147.789474 Z"
id="path-9"
/>
<path
d="M38.779092,147.789474 C60.0824253,147.789474 77.279092,131.286316 77.279092,110.842105 L77.279092,36.9473684 C77.279092,16.5031579 60.0824253,0 38.779092,0 C17.4757586,0 0.279091964,16.5031579 0.279091964,36.9473684 L0.279091964,110.842105 C0.279091964,131.286316 17.4757586,147.789474 38.779092,147.789474 Z"
id="path-11"
/>
<path
d="M38.779092,147.789474 C60.0824253,147.789474 77.279092,131.286316 77.279092,110.842105 L77.279092,36.9473684 C77.279092,16.5031579 60.0824253,0 38.779092,0 C17.4757586,0 0.279091964,16.5031579 0.279091964,36.9473684 L0.279091964,110.842105 C0.279091964,131.286316 17.4757586,147.789474 38.779092,147.789474 Z"
id="path-13"
/>
<path
d="M38.779092,147.789474 C60.0824253,147.789474 77.279092,131.286316 77.279092,110.842105 L77.279092,36.9473684 C77.279092,16.5031579 60.0824253,0 38.779092,0 C17.4757586,0 0.279091964,16.5031579 0.279091964,36.9473684 L0.279091964,110.842105 C0.279091964,131.286316 17.4757586,147.789474 38.779092,147.789474 Z"
id="path-15"
/>
</defs>
<g id="el_QJeJ_2CDw5" fillRule="evenodd">
<g id="el_UYYCfubTRf">
<path
d="M142.731204,111 C137.280427,111 132.719573,114.852 131.82965,120.095 C127.268796,145.24 104.464526,164.5 76.9881611,164.5 C49.5117965,164.5 26.7075263,145.24 22.1466723,120.095 C21.2567496,114.852 16.6958955,111 11.2451187,111 C4.45945784,111 -0.880078594,116.778 0.121084488,123.198 C5.57186127,155.298 32.2695435,180.443 65.8641269,185.044 L65.8641269,207.3 C65.8641269,213.185 70.8699423,218 76.9881611,218 C83.10638,218 88.1121954,213.185 88.1121954,207.3 L88.1121954,185.044 C121.706779,180.443 148.404461,155.298 153.855238,123.198 C154.967641,116.778 149.516864,111 142.731204,111 Z"
id="el_uzZNtK32Zi"
fillRule="nonzero"
style={{ fill: '#2196F3' }}
/>
<path
d="M76.9864699,147.789474 C98.090352,147.789474 115.126016,131.286316 115.126016,110.842105 L115.126016,36.9473684 C115.126016,16.5031579 98.090352,0 76.9864699,0 C55.8825877,0 38.8469239,16.5031579 38.8469239,36.9473684 L38.8469239,110.842105 C38.8469239,131.286316 55.8825877,147.789474 76.9864699,147.789474 Z"
id="el_EYKQ2N9Kgy"
fillRule="nonzero"
/>
<g id="el_6SDP2LAgKC">
<mask id="mask-2" fill="#fff">
<use xlinkHref="#path-1" />
</mask>
<path
d="M38.779092,147.789474 C60.0824253,147.789474 77.279092,131.286316 77.279092,110.842105 L77.279092,36.9473684 C77.279092,16.5031579 60.0824253,0 38.779092,0 C17.4757586,0 0.279091964,16.5031579 0.279091964,36.9473684 L0.279091964,110.842105 C0.279091964,131.286316 17.4757586,147.789474 38.779092,147.789474 Z"
id="el_-Vm65Ltfy7"
fillRule="nonzero"
mask="url(#mask-2)"
/>
<rect
id="el_q04iZcSim4"
mask="url(#mask-2)"
x="0.279"
width="77"
height="130"
/>
</g>
<g id="el_6WKby7wXqV">
<mask id="mask-4" fill="#fff">
<use xlinkHref="#path-3" />
</mask>
<path
d="M38.779092,147.789474 C60.0824253,147.789474 77.279092,131.286316 77.279092,110.842105 L77.279092,36.9473684 C77.279092,16.5031579 60.0824253,0 38.779092,0 C17.4757586,0 0.279091964,16.5031579 0.279091964,36.9473684 L0.279091964,110.842105 C0.279091964,131.286316 17.4757586,147.789474 38.779092,147.789474 Z"
id="el_9bggsfQOtU"
fillRule="nonzero"
mask="url(#mask-4)"
/>
<rect
id="el_NKxqi9eIym"
mask="url(#mask-4)"
x="0.279"
width="77"
height="115"
/>
</g>
<g id="el_Wi-my975tM">
<mask id="mask-6" fill="#fff">
<use xlinkHref="#path-5" />
</mask>
<path
d="M38.779092,147.789474 C60.0824253,147.789474 77.279092,131.286316 77.279092,110.842105 L77.279092,36.9473684 C77.279092,16.5031579 60.0824253,0 38.779092,0 C17.4757586,0 0.279091964,16.5031579 0.279091964,36.9473684 L0.279091964,110.842105 C0.279091964,131.286316 17.4757586,147.789474 38.779092,147.789474 Z"
id="el_zclQ34fvf7"
fillRule="nonzero"
mask="url(#mask-6)"
/>
<rect
id="el_1OsvRT8HkeZ"
mask="url(#mask-6)"
x="0.279"
width="77"
height="100"
/>
</g>
<g id="el_DkfFFTaFxy8">
<mask id="mask-8" fill="#fff">
<use xlinkHref="#path-7" />
</mask>
<path
d="M38.779092,147.789474 C60.0824253,147.789474 77.279092,131.286316 77.279092,110.842105 L77.279092,36.9473684 C77.279092,16.5031579 60.0824253,0 38.779092,0 C17.4757586,0 0.279091964,16.5031579 0.279091964,36.9473684 L0.279091964,110.842105 C0.279091964,131.286316 17.4757586,147.789474 38.779092,147.789474 Z"
id="el_aa9sjx4H0vA"
fillRule="nonzero"
mask="url(#mask-8)"
/>
<rect
id="el_tea114vWg0J"
mask="url(#mask-8)"
x="0.279"
width="77"
height="85"
/>
</g>
<g id="el_34IgwiMB5rf">
<mask id="mask-10" fill="#fff">
<use xlinkHref="#path-9" />
</mask>
<path
d="M38.779092,147.789474 C60.0824253,147.789474 77.279092,131.286316 77.279092,110.842105 L77.279092,36.9473684 C77.279092,16.5031579 60.0824253,0 38.779092,0 C17.4757586,0 0.279091964,16.5031579 0.279091964,36.9473684 L0.279091964,110.842105 C0.279091964,131.286316 17.4757586,147.789474 38.779092,147.789474 Z"
id="el_z5u6RAFhx7d"
fillRule="nonzero"
mask="url(#mask-10)"
/>
<rect
id="el_7nfuWmA5Uhy"
mask="url(#mask-10)"
x="0.279"
width="77"
height="70"
/>
</g>
<g id="el_DeebuCsPTGA">
<mask id="mask-12" fill="#fff">
<use xlinkHref="#path-11" />
</mask>
<path
d="M38.779092,147.789474 C60.0824253,147.789474 77.279092,131.286316 77.279092,110.842105 L77.279092,36.9473684 C77.279092,16.5031579 60.0824253,0 38.779092,0 C17.4757586,0 0.279091964,16.5031579 0.279091964,36.9473684 L0.279091964,110.842105 C0.279091964,131.286316 17.4757586,147.789474 38.779092,147.789474 Z"
id="el__ZcqlS20zcw"
fillRule="nonzero"
mask="url(#mask-12)"
/>
<rect
id="el_8DnEQnD7VWV"
mask="url(#mask-12)"
x="0.279"
width="77"
height="55"
/>
</g>
<g id="el_ZOjjrPTvyrv">
<mask id="mask-14" fill="#fff">
<use xlinkHref="#path-13" />
</mask>
<path
d="M38.779092,147.789474 C60.0824253,147.789474 77.279092,131.286316 77.279092,110.842105 L77.279092,36.9473684 C77.279092,16.5031579 60.0824253,0 38.779092,0 C17.4757586,0 0.279091964,16.5031579 0.279091964,36.9473684 L0.279091964,110.842105 C0.279091964,131.286316 17.4757586,147.789474 38.779092,147.789474 Z"
id="el_FYYKCI_u24e"
fillRule="nonzero"
mask="url(#mask-14)"
/>
<rect
id="el_XZty4MnTp5Y"
mask="url(#mask-14)"
x="0.279"
width="77"
height="40"
/>
</g>
<g id="el_2FATegVmf0K">
<mask id="mask-16" fill="#fff">
<use xlinkHref="#path-15" />
</mask>
<path
d="M38.779092,147.789474 C60.0824253,147.789474 77.279092,131.286316 77.279092,110.842105 L77.279092,36.9473684 C77.279092,16.5031579 60.0824253,0 38.779092,0 C17.4757586,0 0.279091964,16.5031579 0.279091964,36.9473684 L0.279091964,110.842105 C0.279091964,131.286316 17.4757586,147.789474 38.779092,147.789474 Z"
id="el_RMT1KUfbdF8"
fillRule="nonzero"
mask="url(#mask-16)"
/>
<rect
id="el_RgLcovvFiO1"
mask="url(#mask-16)"
x="0.279"
width="77"
height="25"
/>
</g>
</g>
</g>
</svg>
</React.Fragment>
);
export default ListenSvg;
|
stories/Pill.js | propertybase/react-lds | import React from 'react';
import { storiesOf } from '@storybook/react';
import { action } from '@storybook/addon-actions';
import { text, boolean } from '@storybook/addon-knobs';
import { Pill, PillContainer, Avatar, Icon } from '../src';
const stories = storiesOf('Pill', module);
const portrait = (<Avatar alt="Image" src="assets/images/avatar2.jpg" circle title="avatar title" />);
const icon = (<Icon div sprite="standard" icon="account" title="description of icon" />);
stories
.add('Default', () => (
<Pill
bare={boolean('Bare', false)}
url={text('URL', '#canBeEmptyForUnlinkedPill')}
label={text('Label', 'Pill Label')}
title={text('Title', 'Full pill label verbiage mirrored here')}
onClose={action()}
/>
))
.add('Truncated', () => (
<div style={{ width: '220px' }}>
<Pill
bare={boolean('Bare', false)}
url={text('URL', '#canBeEmptyForUnlinkedPill')}
label={text('Label', 'Pill Label is very long and very boring')}
title={text('Title', 'Full pill label verbiage mirrored here')}
onClose={action()}
/>
</div>
))
.add('With Portrait', () => (
<Pill
bare={boolean('Bare', false)}
url={text('URL', '#canBeEmptyForUnlinkedPill')}
label={text('Label', 'Pill Label')}
title={text('Title', 'Full pill label verbiage mirrored here')}
onClose={action()}
portrait={portrait}
/>
))
.add('With Icon', () => (
<Pill
bare={boolean('Bare', false)}
url={text('URL', '#canBeEmptyForUnlinkedPill')}
label={text('Label', 'Pill Label')}
title={text('Title', 'Full pill label verbiage mirrored here')}
onClose={action()}
icon={icon}
/>
))
.add('Without close Button', () => (
<Pill
bare={boolean('Bare', false)}
url={text('URL', '#canBeEmptyForUnlinkedPill')}
label={text('Label', 'Pill Label')}
title={text('Title', 'Full pill label verbiage mirrored here')}
/>
))
.add('With Container', () => (
<PillContainer>
<Pill
onClick={action('clicked')}
url="#lightningOut"
icon={icon}
label="test"
title="test"
/>
</PillContainer>
));
|
src/Index.js | gfors/react-firebase3-auth-router | import React from 'react';
import ReactDOM from 'react-dom';
import { Auth, DatabaseRef } from './config/firebaseConfig.js';
import { Public, Private } from './config/routes';
const Loading = React.createClass({
render() {
return(
<div>
<h2>Loading</h2>
</div>
);
}
});
const App = React.createClass ({
getInitialState: function(){
return {
auth: null
}
},
componentWillMount() {
Auth.onAuthStateChanged( (user) => {
this.setState({
auth: (user) ? true : false
})
})
},
render() {
let Routes;
switch (this.state.auth) {
case true:
Routes = <Private />
break;
case false:
Routes = <Public />;
break;
default:
Routes = <Loading />;
break;
}
return (
<div>
{ Routes }
</div>
);
}
});
ReactDOM.render(<App/> , document.getElementById('content')); |
src/icons/GradientIcon.js | kiloe/ui | import React from 'react';
import Icon from '../Icon';
export default class GradientIcon extends Icon {
getSVG(){return <svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 48 48"><path d="M22 18h4v4h-4zm-4 4h4v4h-4zm8 0h4v4h-4zm4-4h4v4h-4zm-16 0h4v4h-4zM38 6H10c-2.2 0-4 1.8-4 4v28c0 2.2 1.8 4 4 4h28c2.2 0 4-1.8 4-4V10c0-2.2-1.8-4-4-4zM18 36h-4v-4h4v4zm8 0h-4v-4h4v4zm8 0h-4v-4h4v4zm4-14h-4v4h4v4h-4v-4h-4v4h-4v-4h-4v4h-4v-4h-4v4h-4v-4h4v-4h-4V10h28v12z"/></svg>;}
}; |
src/widgets/Flag.js | Sekhmet/busy | import React from 'react';
import franc from 'franc';
import striptags from 'striptags';
import Remarkable from 'remarkable';
import { Link } from 'react-router';
import './Flag.scss';
import { getCountryCode } from '../helpers/languages';
const remarkable = new Remarkable({ html: true });
export default ({ title, body, className }) => {
const language = franc(`${title} ${striptags(remarkable.render(body))}`);
const textLength = (`${title} ${striptags(remarkable.render(body))}`).length;
if (!(language !== 'eng' && language !== 'sco' && textLength > 255)) {
return null;
}
return (
<span className={className}>
<Link to={`/hot/${getCountryCode(language)}`}>
<img className="Flag" alt={language} src={`/img/flag/${getCountryCode(language)}.svg`} />
</Link>
</span>
);
};
|
actor-apps/app-web/src/app/components/sidebar/RecentSectionItem.react.js | fengchenlianlian/actor-platform | import React from 'react';
import classNames from 'classnames';
import DialogActionCreators from 'actions/DialogActionCreators';
import DialogStore from 'stores/DialogStore';
import AvatarItem from 'components/common/AvatarItem.react';
class RecentSectionItem extends React.Component {
static propTypes = {
dialog: React.PropTypes.object.isRequired
};
constructor(props) {
super(props);
}
onClick = () => {
DialogActionCreators.selectDialogPeer(this.props.dialog.peer.peer);
}
render() {
const dialog = this.props.dialog,
selectedDialogPeer = DialogStore.getSelectedDialogPeer();
let isActive = false,
title;
if (selectedDialogPeer) {
isActive = (dialog.peer.peer.id === selectedDialogPeer.id);
}
if (dialog.counter > 0) {
const counter = <span className="counter">{dialog.counter}</span>;
const name = <span className="col-xs title">{dialog.peer.title}</span>;
title = [name, counter];
} else {
title = <span className="col-xs title">{dialog.peer.title}</span>;
}
let recentClassName = classNames('sidebar__list__item', 'row', {
'sidebar__list__item--active': isActive,
'sidebar__list__item--unread': dialog.counter > 0
});
return (
<li className={recentClassName} onClick={this.onClick}>
<AvatarItem image={dialog.peer.avatar}
placeholder={dialog.peer.placeholder}
size="tiny"
title={dialog.peer.title}/>
{title}
</li>
);
}
}
export default RecentSectionItem;
|
client/src/modules/Transcript.js | showmethewei/tuna-io | import React from 'react';
class Transcript extends React.Component {
constructor(props) {
super(props);
this.renderTranscriptAsParagraph = this.renderTranscriptAsParagraph.bind(this);
}
// Render the transcript paragraph-style
renderTranscriptAsParagraph() {
return (
this.props.transcript.map(pair => pair.Token).reduce((firstword, secondword) => `${firstword} ${secondword}`)
);
}
render() {
return (
<div>
{
this.renderTranscriptAsParagraph()
}
</div>
);
}
}
export default Transcript;
|
src/components/droppable.js | brijeshb42/kattappa | import React from 'react';
class Droppable extends React.Component {
constructor(props) {
super(props);
this.state = {
className: ''
};
this.fileEL = null;
this.droppable = null;
this.getClassName = this.getClassName.bind(this);
this.onDragEnter = this.onDragEnter.bind(this);
this.onDragOver = this.onDragOver.bind(this);
this.onDragLeave = this.onDragLeave.bind(this);
this.onClick = this.onClick.bind(this);
this.onDrop = this.onDrop.bind(this);
}
getClassName() {
return 'katap-droppable '+(this.props.className || this.state.className);
}
onDragEnter(e) {
e.preventDefault();
e.stopPropagation();
this.setState({
className: 'katap-drop-active'
});
}
componentDidMount() {
this.droppable.focus();
}
onDragOver(e) {
e.preventDefault();
e.stopPropagation();
e.dataTransfer.dropEffect = 'copy';
if (this.props.onDragOver) {
this.props.onDragOver(e);
}
}
onDragLeave(e) {
this.setState({
className: ''
});
if (this.props.onDragLeave) {
this.props.onDragLeave(e);
}
}
onClick() {
var fileInput = this.fileEL;
fileInput.value = null;
fileInput.click();
}
onDrop(e) {
e.preventDefault();
var files;
if(e.dataTransfer) {
files = e.dataTransfer.files;
} else if(e.target) {
files = e.target.files;
}
var maxFiles = (this.props.multiple) ? files.length : 1;
for (var i = 0; i < maxFiles; i++) {
files[i].preview = URL.createObjectURL(files[i]);
}
if(this.props.onDrop) {
files = Array.prototype.slice.call(files, 0, maxFiles);
this.props.onDrop(files);
}
}
render() {
return (
<div
ref={(node) => {this.droppable=node}}
style={{height: 100}}
className={this.getClassName()}
onDragEnter={this.onDragEnter}
onDragOver={this.onDragOver}
onDragLeave={this.onDragLeave}
onClick={this.onClick}
onDrop={this.onDrop} >
<input
ref={(node) => {this.fileEL=node}}
type="file"
style={{display: 'none'}}
multiple={this.props.multiple}
onChange={this.onDrop} />
{this.props.children}
</div>
);
}
}
Droppable.defaultProps = {
supportClick: true,
multiple: false
};
export default Droppable;
|
app/index.js | robogroves/ebp | import React from 'react';
import { render } from 'react-dom';
import { Provider } from 'react-redux';
import { Router, hashHistory } from 'react-router';
import { syncHistoryWithStore } from 'react-router-redux';
import routes from './routes';
import configureStore from './store/configureStore';
import './css/app.global.css';
const store = configureStore();
const history = syncHistoryWithStore(hashHistory, store);
render(
<Provider store={store}>
<Router history={history} routes={routes} />
</Provider>,
document.getElementById('root')
);
|
src/packages/intro/src/index.js | MikkCZ/pontoon-tools | import React from 'react';
import ReactDOM from 'react-dom';
import { Options } from 'Commons/src/Options';
import { RemoteLinks } from 'Commons/src/RemoteLinks';
import { TourPage } from './TourPage';
import toolbarButtonImage from './static/img/toolbar-button.png';
import notificationsImage from './static/img/desktop-notification.svg';
import pageActionImage from './static/img/page-action.png';
import contextButtonsImage from './static/img/context-buttons.png';
import settingsImage from './static/img/settings.png';
import feedbackImage from './static/img/2-Lions.png';
import 'Commons/static/css/pontoon.css';
import './index.css';
if (!browser) { // eslint-disable-line no-use-before-define
var browser = require('webextension-polyfill'); // eslint-disable-line no-var, no-inner-declarations
}
const title = 'Welcome to Pontoon Add-on';
document.title = title;
export default Options.create().then(async (options) => {
const remoteLinks = new RemoteLinks();
const tiles = [];
tiles.push({
title: 'Pontoon button',
image: toolbarButtonImage,
text: (
<React.Fragment>
Pontoon icon in the toolbar offers <strong>quick access to notifications</strong> and your localization team progress.
</React.Fragment>
),
button: {
text: 'See the Pontoon button',
onClick: () => browser.browserAction.openPopup(),
},
});
tiles.push({
title: 'System notifications',
image: notificationsImage,
text: 'Pontoon Add-on can bring notifications directly into your system. Try it!',
button: {
text: 'Preview system notifications',
onClick: () => {
options.set('show_notifications', true);
browser.notifications.create({
type: 'basic',
iconUrl: browser.runtime.getURL('packages/commons/static/img/pontoon-logo.svg'),
title: 'Notification from Pontoon',
message: 'Similar notifications will appear if there is something new in Pontoon. You can click them to open related project in Pontoon.',
});
},
},
});
if (browser.pageAction !== undefined) {
tiles.push({
title: 'Address bar button',
image: pageActionImage,
text: (
<React.Fragment>
So called <em>page action</em> is a button in the address bar, that lets you <strong>open in Pontoon the project</strong>, which is related to the current page.
</React.Fragment>
),
button: {
text: 'Try it on mozilla.org',
onClick: () => browser.tabs.create({url: 'https://www.mozilla.org/'}),
},
});
}
tiles.push({
title: 'Context buttons',
image: contextButtonsImage,
text: (
<React.Fragment>
<strong>Look up strings in Pontoon</strong> or <strong>report bugs</strong> on localizer version of Mozilla website. Just select the text and click the context button.
</React.Fragment>
),
button: {
text: 'Try it on mozilla.org',
onClick: () => browser.tabs.create({url: 'https://www.mozilla.org/'}),
},
});
tiles.push({
title: 'Add-on settings',
image: settingsImage,
text: (
<React.Fragment>
Pontoon button, notifications, ... all these features are <strong>configurable</strong>.
</React.Fragment>
),
button: {
text: 'Open Pontoon Add-on settings',
onClick: () => browser.runtime.openOptionsPage(),
},
});
tiles.push({
title: 'Feedback and more',
image: feedbackImage,
text: (
<React.Fragment>
This add-on won't exist and improve without you - Mozilla localizers. Please <strong>share your feedback</strong> and feel free to request new features.
</React.Fragment>
),
button: {
text: 'Check the wiki',
onClick: () => browser.tabs.create({url: remoteLinks.getPontoonAddonWikiUrl()}),
},
});
return ReactDOM.render(
<TourPage
title={title}
tiles={tiles}
/>,
document.getElementById('root') || document.createElement('div')
);
});
|
src/components/difference-bar-series.js | ronlobo/building-os-charts | import React from 'react';
import d3 from 'd3';
import classNames from 'classnames';
import Series from 'components/series';
import DifferenceBar from 'components/difference-bar';
import getBarHeight from 'decorators/get-bar-height';
import getBarWidth from 'decorators/get-bar-width';
import getBarY from 'decorators/get-bar-y';
import getHigherOrLower from 'decorators/get-higher-or-lower';
import isActive from 'decorators/is-active';
@getBarHeight
@getBarWidth
@getBarY
@getHigherOrLower
@isActive
export default class DifferenceBarSeries extends Series {
static propTypes = {
barSpacing: React.PropTypes.number.isRequired,
className: React.PropTypes.string,
data: React.PropTypes.arrayOf(React.PropTypes.array).isRequired,
dispatcher: React.PropTypes.object.isRequired,
height: React.PropTypes.number.isRequired,
id: React.PropTypes.string.isRequired,
interactive: React.PropTypes.bool.isRequired,
scaleY: React.PropTypes.func.isRequired,
style: React.PropTypes.object,
tickWidth: React.PropTypes.number.isRequired,
width: React.PropTypes.number.isRequired,
zeroY: React.PropTypes.number.isRequired,
}
static defaultProps = {
barSpacing: 2,
className: '',
data: [[], []],
dispatcher: d3.dispatch(),
height: 0,
id: '',
interactive: true,
scaleY: Function,
style: {},
tickWidth: 0,
width: 0,
zeroY: 0,
}
state = {
activeDatum: {},
activeIndex: -1,
}
getBarFillHeight(differenceDatum, scale, y) {
if (differenceDatum && differenceDatum.hasOwnProperty('value')) {
return Math.round(scale(differenceDatum.value) - y);
}
return 0;
}
getBarProps(props, state, datum, index) {
const differenceData = props.data[1];
const differenceDatum = differenceData[index];
const differenceValue = differenceDatum ? differenceDatum.value : 0;
const active = this.isActive(
state.activeIndex, index);
const className = this.getHigherOrLower(
datum.value, differenceValue);
const height = this.getBarHeight(
props.zeroY,
props.scaleY,
datum.value);
const width = this.getBarWidth(
props.tickWidth,
props.barSpacing);
const x = this.getBarX(
props.tickWidth,
index);
const y = this.getBarY(
datum.value,
props.zeroY,
height);
const fillHeight = this.getBarFillHeight(
differenceDatum, props.scaleY, y);
return {
active: active,
className: className,
fillHeight: fillHeight,
height: height,
width: width,
x: x,
y: y,
};
}
getBarX(tickWidth, index) {
return Math.floor(tickWidth * index);
}
render() {
return (
<g
className={classNames(
'difference-bar-series',
this.props.className
)}
style={this.props.style}>
{this.props.data.map((datum, index) => {
const barProps = this.getBarProps(
this.props,
this.state,
datum,
index);
return (
<DifferenceBar
active={barProps.active}
className={barProps.className}
fillHeight={barProps.fillHeight}
height={barProps.height}
index={index}
key={index}
style={this.props.style}
width={barProps.width}
x={barProps.x}
y={barProps.y} />
);
})}
</g>
);
}
}
|
node_modules/@expo/vector-icons/website/src/App.js | RahulDesai92/PHR | import React, { Component } from 'react';
import './App.css';
import _ from 'lodash';
const IconFamilies = {
Entypo: require('react-native-vector-icons/glyphmaps/Entypo.json'),
EvilIcons: require('react-native-vector-icons/glyphmaps/EvilIcons.json'),
FontAwesome: require('react-native-vector-icons/glyphmaps/FontAwesome.json'),
Foundation: require('react-native-vector-icons/glyphmaps/Foundation.json'),
Ionicons: require('react-native-vector-icons/glyphmaps/Ionicons.json'),
MaterialIcons: require('react-native-vector-icons/glyphmaps/MaterialIcons.json'),
MaterialCommunityIcons: require('react-native-vector-icons/glyphmaps/MaterialCommunityIcons.json'),
SimpleLineIcons: require('react-native-vector-icons/glyphmaps/SimpleLineIcons.json'),
Octicons: require('react-native-vector-icons/glyphmaps/Octicons.json'),
Zocial: require('react-native-vector-icons/glyphmaps/Zocial.json'),
};
class Icon extends Component {
render() {
return (
<span style={{ fontFamily: this.props.family }} {...this.props}>
{String.fromCharCode(IconFamilies[this.props.family][this.props.name])}
</span>
);
}
}
const HeaderBar = props => {
return (
<div className="Header-Container">
<div className="Header-Content">
<h1 className="Header-Title">@expo/vector-icons directory</h1>
</div>
</div>
);
};
class SearchBar extends Component {
render() {
return (
<div className="Search-Container">
<div className="Search-Content">
<form onSubmit={this._onSubmit.bind(this)}>
<Icon family="FontAwesome" name="search" className="Search-Icon" />
<input
ref={input => (this._input = input)}
placeholder="Search for an icon"
type="text"
className="Search-Input"
/>
</form>
</div>
</div>
);
}
_onSubmit(e) {
e.preventDefault();
this.props.onSubmit(this._input.value);
}
}
class App extends Component {
constructor(props) {
super(props);
this.state = {
matches: [],
};
}
componentDidMount() {
this._onSubmit('');
}
render() {
return (
<div className="App">
<HeaderBar />
<SearchBar onSubmit={this._onSubmit.bind(this)} />
<div className="Container">
{this.state.matches.map(this._renderMatch.bind(this))}
</div>
</div>
);
}
// {Object.keys(IconFamilies).map(familyName => this._renderFamily(familyName))}
_renderFamily(familyName) {
return (
<div>
{Object.keys(IconFamilies[familyName]).map(iconName =>
<Icon
key={iconName + familyName}
family={familyName}
name={iconName}
/>
)}
</div>
);
}
_onSubmit(text) {
const lcText = text.toLowerCase();
let matches = [];
_.forEach(IconFamilies, (icons, family) => {
let names = Object.keys(icons);
let results = names.filter(
name => name.toLowerCase().indexOf(lcText) >= 0
);
if (results.length) {
matches = [...matches, { family, names: results }];
}
});
this.setState({ matches });
}
_renderMatch(match) {
let { family, names } = match;
return (
<div className="Result-Row" key={family}>
<h2 className="Result-Title">
{family}
</h2>
<div className="Result-List">
{names.map(name => this._renderIcon(family, name))}
</div>
</div>
);
}
_renderIcon(family, name) {
return (
<div className="Result-Icon-Container" key={name}>
<Icon family={family} name={name} className="Result-Icon" />
<h4 className="Result-Icon-Name">
{name}
</h4>
</div>
);
}
}
export default App;
|
src/Dropdown/Dropdown.js | Pearson-Higher-Ed/compounds | import React, { Component } from 'react';
import ReactDOM from 'react-dom';
import PropTypes from 'prop-types';
import Button from '../Button';
import Icon from '../Icon';
import './Dropdown.scss';
export default class Dropdown extends Component {
static propTypes = {
mobileTitle: PropTypes.string,
type: PropTypes.string.isRequired,
label: PropTypes.string.isRequired,
id: PropTypes.string.isRequired,
changeHandler: PropTypes.func,
btnImage: PropTypes.string,
btnImageHeight: PropTypes.string,
scrollable: PropTypes.bool,
btnImageWidth: PropTypes.string
};
constructor(props) {
super(props)
this.focusedItem = 0;
this.state = {
open: false,
selectedItem: '',
selectedItemDOM: '',
buttonFocus: true,
btnImage: props.btnImage
};
this.toggleDropdown = this.toggleDropdown.bind(this);
this.handleKeyDown = this.handleKeyDown.bind(this);
this.itemSelected = this.itemSelected.bind(this);
this.clickListener = this.clickListener.bind(this);
this.getSelectedIndex = this.getSelectedIndex.bind(this);
}
placement(dropdown) {
const anchor = dropdown.children[0];
const element = dropdown.children[1];
// get window geometry - this is how jQuery does it
const elementRect = element.getBoundingClientRect();
const anchorRect = anchor.getBoundingClientRect();
// then we are past the right side and need to right justify
const touch_right = window.innerWidth < elementRect.right;
// we need to push up
const touch_bottom = elementRect.bottom > window.innerHeight;
if (touch_bottom) {
// 4 because of margins
element.style.top = `-${(elementRect.height + 4)}px`;
}
if (touch_right) {
element.style.left = `-${elementRect.width - anchorRect.width}px`;
}
}
resetPlacement(dropdown) {
const element = dropdown.children[1];
element.style.left = null;
element.style.top = null;
}
toggleDropdown() {
this.setState({ open: !this.state.open }, () => {
this.list.children[0].children[0].focus();
if (this.state.open) {
this.placement(ReactDOM.findDOMNode(this));
} else {
this.resetPlacement(ReactDOM.findDOMNode(this));
this.focusedItem = 0;
}
});
};
handleKeyDown(event) {
if (this.state.open) {
if (event.which === 27) {
// escape
return this.setState({ open: false });
}
if (event.which === 38) {
// up
event.preventDefault();
while (this.focusedItem > 0) {
this.focusedItem--;
if (this.list.children[this.focusedItem].attributes.role.value !== 'separator') {
break;
}
}
this.list.children[this.focusedItem].children[0].focus();
}
if (event.which === 40) {
// down
event.preventDefault();
while (this.focusedItem < this.list.children.length-1) {
this.focusedItem++;
if (this.list.children[this.focusedItem].attributes.role.value !== 'separator') {
break;
}
}
this.list.children[this.focusedItem].children[0].focus();
}
if (event.which === 9) {
// tab
this.setState({
open: false
});
}
if (event.which >= 65 && event.which <= 90) {
// a through z pressed
const alphaArray = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'];
let searchIndex = this.focusedItem;
while (searchIndex >= 0 && searchIndex < this.list.children.length-1) {
searchIndex++;
if (this.list.children[searchIndex].attributes['data-item'].nodeValue.toLowerCase().indexOf(alphaArray[event.which-65]) === 0) {
this.focusedItem = searchIndex;
break;
}
if (searchIndex === this.focusedItem) {
break;
}
if (searchIndex === this.list.children.length-1) {
searchIndex = 0;
}
}
this.list.children[this.focusedItem].children[0].focus();
}
}
}
getParentLiSelected(dom) {
if (dom.nodeName !== 'LI') {
return this.getParentLiSelected(dom.parentElement);
}
return dom;
}
itemSelected(e) {
const selectedListItem = this.getParentLiSelected(e.target);
if (selectedListItem.dataset.item !== 'divider') {
this.props.changeHandler ? this.props.changeHandler(selectedListItem.dataset) : null;
this.setState({
open: false,
selectedItem: selectedListItem.dataset.item,
selectedItemDOM: selectedListItem
});
this.container.children[0].focus();
}
}
insertAnchor() {
let buttonClass='pe-icon--btn dropdown-activator';
let btnIcon=false;
let buttonLabel = (
<div>
{this.props.label} <Icon name="dropdown-open-sm-18">{this.props.label}</Icon>
</div>
);
switch (this.props.type) {
case 'button':
buttonClass='pe-btn__primary dropdown-activator';
break;
case 'icon':
btnIcon = true;
buttonClass = 'dropdown-activator pe-icon--btn';
buttonLabel = (
<Icon name="dropdown-open-sm-24">{this.props.label}</Icon>
);
break;
case 'image':
let imgPad = '0';
if (this.props.btnImageHeight < 18) {
imgPad = Math.floor((18 - this.props.btnImageHeight)/2);
}
btnIcon = true;
buttonClass= 'pe-icon--btn dropdown-activator dropdown-image';
buttonLabel = (
<div>
<img src={this.props.btnImage} height={this.props.btnImageHeight} width={this.props.btnImageWidth}
style={{marginTop: imgPad + 'px'}} alt=""/>
<Icon name="dropdown-open-sm-18">{this.props.label}</Icon>
</div>
);
break;
// if not one of the types go to text
default:
case 'text':
buttonClass = 'pe-icon--btn dropdown-activator';
break;
}
return (
<Button
className={buttonClass}
type="button"
aria-expanded={this.state.open}
aria-controls={`${this.props.id.replace(' ', '_')}-dropdown`}
aria-haspopup="true"
btnIcon={btnIcon}
focus={this.state.buttonFocus}
onClick={this.toggleDropdown}
>
{buttonLabel}
</Button>
);
}
addMobileHeader() {
if (window.screen.width < 480) {
return (
<li data-item="divider">
<div className="mobile-title">
<h1 className="pe-page-title pe-page-title--small">
{this.props.mobileTitle}
<span className="icon-fix">
<Icon name="remove-lg-18"></Icon>
</span>
</h1>
</div>
</li>
);
}
}
clickListener(e) {
const currentElement = e.target;
if (!this.container.contains(currentElement)) {
this.setState({open: false});
}
}
getSelectedIndex() {
let selectedIndex = -1;
if (this.props.children) {
for (let i = 0; i < this.props.children.length; i++) {
const { props = {} } = this.props.children[i] || {};
if (props.selected) {
selectedIndex = i;
break;
}
}
}
return selectedIndex;
}
componentDidMount() {
const selectedIndex = this.getSelectedIndex();
document.addEventListener('click', this.clickListener);
if (selectedIndex >= 0 && this.props.children) {
this.setState({
selectedItemDOM: document.getElementById(this.props.id + '-' + this.props.children[selectedIndex].props.selectValue)
});
}
}
componentDidUpdate() {
if (this.state.selectedItemDOM && typeof this.state.selectedItemDOM.scrollIntoView === 'function' && this.props.scrollable) {
// delay necessary so allow the list to appear before trying to scroll into view
setTimeout(() => {
this.state.selectedItemDOM.scrollIntoView(true);
}, 1);
}
}
componentWillUnmount() {
document.removeEventListener('click', this.clickListener);
}
render() {
return (
<div className="dropdown-container" ref={(dom) => { this.container = dom; }}>
{this.insertAnchor()}
<ul
role="menu"
id={`${this.props.id.replace(' ', '_')}-dropdown`}
ref={(parent) => { this.list = parent; }}
className={this.state.open ? '' : 'dropdown-menu'}
onClick={this.itemSelected}
onKeyDown={this.handleKeyDown}>
{this.addMobileHeader()}
{this.props.children}
</ul>
</div>
)
}
};
|
docs/app/Examples/collections/Menu/index.js | clemensw/stardust | import React from 'react'
import Content from './Content'
import Types from './Types'
import States from './States'
import Variations from './Variations'
const MenuExamples = () => {
return (
<div>
<Types />
<Content />
<States />
<Variations />
</div>
)
}
export default MenuExamples
|
app/components/Home.js | erichardson30/jarvis-electron | import React, { Component } from 'react';
import styles from './Home.css';
import axios from 'axios';
import jarvis from 'file!../jarvis-bkrd.png';
import RaisedButton from 'material-ui/lib/raised-button';
import Modal from 'react-modal';
import VisitorModal from './VisitorModal';
import NotifyModal from './NotifyModal';
import Motion from '../sensors/motion';
import * as Camera from '../sensors/camera';
import io from 'socket.io-client';
export default class Home extends Component {
constructor(props) {
super(props);
this.socket = io(`http://jarviscsg.herokuapp.com:80`);
this.state = {
visitors: [],
modalIsOpen: false,
employeeName: null,
notifyModalOpen: false
}
}
componentDidMount() {
this.setState({synth: window.speechSynthesis}, () => {
this.setState({voices: this.state.synth.getVoices()});
});
this.socket.on('knock-knock', (event) => {
this.knock(event);
})
this.socket.on('speak', (event) => {
this.speak(event.message, event.voice);
})
}
knock = (event) => {
event.seeFront = true;
Camera.takePicture(event);
}
speak = (message, voice) => {
let jarvisVoice = 'UK English Male';
if(voice && voice.toLowerCase() == 'friday') {
jarvisVoice = 'UK English Female';
}
responsiveVoice.speak(message, jarvisVoice, {rate: 0.8});
}
closeModal = () => {
this.setState({ modalIsOpen: false});
}
closeNotifyModal = () => {
this.setState({ notifyModalOpen: false });
}
forceCloseNotifyModal = () => {
setTimeout(this.closeNotifyModal(), 5000);
}
checkIn = () => {
console.debug("GUEST CHECKED IN " + new Date());
let self = this;
axios.get('http://jarviscsg-api.herokuapp.com/api/schedules/now?officeLocation=RDU').then(function(response) {
if (response.data.length > 0) {
self.setState({
visitors: response.data,
modalIsOpen: true
});
} else {
self.notifyGroup();
}
});
}
notifyGroup = () => {
console.debug("ABOUT TO TAKE PICTURE " + new Date());
let data = {
firstName: 'Cardinal - RDU',
channel: 'C44F3SSDD',
expecting: 'A visitor',
date: new Date(),
checkedIn : true,
checkedInDate : new Date()
};
Camera.takePicture(data);
console.debug("NOTIFYING GROUP " + new Date());
this.setState({ employeeName: 'someone', notifyModalOpen: true });
responsiveVoice.speak("Thank you I will let someone know you are here.", "UK English Male", {rate: 0.8});
this.closeModal();
}
notifyEmployee = (data) => {
Camera.takePicture(data);
this.setState({ employeeName: data.firstName, notifyModalOpen: true });
responsiveVoice.speak("Thank you. I will let " + data.firstName + "know you are here.", "UK English Male", {rate: 0.8});
this.closeModal();
}
render() {
return (
<div>
<div className={styles.container}>
<img src="./img/Cardinal.png" alt="Cardinal" className={styles.logo} />
<RaisedButton
backgroundColor="#207aa4"
className={styles.button}
style={style.button}
label="Check In"
labelColor="#FFF"
labelStyle={style.label}
onClick={this.checkIn}
/>
<VisitorModal
open={this.state.modalIsOpen}
close = {this.closeModal}
visitors = {this.state.visitors}
notifyEmployee = {this.notifyEmployee}
notifyGroup = {this.notifyGroup} />
<NotifyModal
open={this.state.notifyModalOpen}
closeModal={this.closeNotifyModal}
forceClose={this.forceCloseNotifyModal}
employeeName = {this.state.employeeName}
timeout = {5000} />
</div>
</div>
);
}
}
const style = {
button : {
display: 'block',
height: '200px',
width: '90%',
bottom: '2%',
position: 'fixed',
marginLeft: '5%',
borderRadius: '20px'
},
label : {
fontSize: '90px'
},
}
|
app/components/Text/LastConverted.js | jmsstudio/CurrencyConverter | import React from 'react';
import PropTypes from 'prop-types';
import { Text } from 'react-native';
import moment from 'moment';
import styles from './styles';
function LastConverted({ base, quote, conversionRate, date }) {
return (
<Text style={styles.smallText}>
1 {base} = {conversionRate} {quote} as of {moment(date).format('MMMM D, YYYY')}
</Text>
);
}
LastConverted.propTypes = {
date: PropTypes.object,
base: PropTypes.string,
quote: PropTypes.string,
conversionRate: PropTypes.number,
};
export default LastConverted;
|
re-grid/src/header/columns-row.js | NourEldin275/reGrid | /**
* Created by nour on 8/25/17.
*/
import React, { Component } from 'react';
class HeaderRow extends Component{
render(){
const columns = this.props.columns;
const sortHandler = this.props.onSort;
const columnConfig = columns.map((column) =>
<td key={column.id.toString()}>
{column.label}
<span
name={column.id}
className="sort-direction-toggle glyphicon glyphicon-sort"
aria-hidden="true"
onClick={sortHandler}></span>
</td>
);
return(
<tr>{columnConfig}</tr>
);
}
}
export default HeaderRow; |
tests/Rules-isEmail-spec.js | yesmeck/formsy-react | import React from 'react';
import TestUtils from 'react-addons-test-utils';
import Formsy from './..';
import { InputFactory } from './utils/TestInput';
const TestInput = InputFactory({
render() {
return <input value={this.getValue()} readOnly/>;
}
});
const TestForm = React.createClass({
render() {
return (
<Formsy.Form>
<TestInput name="foo" validations="isEmail" value={this.props.inputValue}/>
</Formsy.Form>
);
}
});
export default {
'should pass with a default value': function (test) {
const form = TestUtils.renderIntoDocument(<TestForm/>);
const inputComponent = TestUtils.findRenderedComponentWithType(form, TestInput);
test.equal(inputComponent.isValid(), true);
test.done();
},
'should fail with "foo"': function (test) {
const form = TestUtils.renderIntoDocument(<TestForm inputValue="foo"/>);
const inputComponent = TestUtils.findRenderedComponentWithType(form, TestInput);
test.equal(inputComponent.isValid(), false);
test.done();
},
'should pass with "foo@foo.com"': function (test) {
const form = TestUtils.renderIntoDocument(<TestForm inputValue="foo@foo.com"/>);
const inputComponent = TestUtils.findRenderedComponentWithType(form, TestInput);
test.equal(inputComponent.isValid(), true);
test.done();
},
'should pass with an undefined': function (test) {
const form = TestUtils.renderIntoDocument(<TestForm inputValue={undefined}/>);
const inputComponent = TestUtils.findRenderedComponentWithType(form, TestInput);
test.equal(inputComponent.isValid(), true);
test.done();
},
'should pass with a null': function (test) {
const form = TestUtils.renderIntoDocument(<TestForm inputValue={null}/>);
const inputComponent = TestUtils.findRenderedComponentWithType(form, TestInput);
test.equal(inputComponent.isValid(), true);
test.done();
},
'should pass with an empty string': function (test) {
const form = TestUtils.renderIntoDocument(<TestForm inputValue={''}/>);
const inputComponent = TestUtils.findRenderedComponentWithType(form, TestInput);
test.equal(inputComponent.isValid(), true);
test.done();
},
'should fail with a number': function (test) {
const form = TestUtils.renderIntoDocument(<TestForm inputValue={42}/>);
const inputComponent = TestUtils.findRenderedComponentWithType(form, TestInput);
test.equal(inputComponent.isValid(), false);
test.done();
}
};
|
node_modules/react-icons/md/vibration.js | bairrada97/festival |
import React from 'react'
import Icon from 'react-icon-base'
const MdVibration = props => (
<Icon viewBox="0 0 40 40" {...props}>
<g><path d="m26.6 31.6v-23.2h-13.2v23.2h13.2z m0.9-26.6c1.4 0 2.5 1.1 2.5 2.5v25c0 1.4-1.1 2.5-2.5 2.5h-15c-1.4 0-2.5-1.1-2.5-2.5v-25c0-1.4 1.1-2.5 2.5-2.5h15z m4.1 23.4v-16.8h3.4v16.8h-3.4z m5-13.4h3.4v10h-3.4v-10z m-31.6 13.4v-16.8h3.4v16.8h-3.4z m-5-3.4v-10h3.4v10h-3.4z"/></g>
</Icon>
)
export default MdVibration
|
app/components/IntroduceModal/index.js | Princess310/antd-demo | /**
*
* IntroduceModal
*
*/
import React from 'react';
import ReactDOM from 'react-dom';
import styled from 'styled-components';
import pallete from 'styles/colors';
import Mask from 'components/Mask';
const ContentWrapper = styled.div`
padding: 0.32rem 0.6rem;
`;
function introduceModal(...args) {
const bgImg = args[0];
const onClose = args[1];
let div = document.createElement('div');
document.body.appendChild(div);
function close() {
onClose && onClose();
ReactDOM.unmountComponentAtNode(div);
if (div && div.parentNode) {
div.parentNode.removeChild(div);
}
}
ReactDOM.render(
<Mask onClick={close}>
<div style={{ backgroundColor: pallete.white, borderRadius: '0.08rem' }}>
<ContentWrapper>
<header style={{ fontSize: '0.3rem', textAlign: 'center' }}>转介绍</header>
<section style={{ marginTop: '0.32rem', fontSize: '0.22rem', color: '#848b9f' }}>推荐商家给他人,也会让您认识更多生意伙伴哦~</section>
</ContentWrapper>
</div>
</Mask>, div,
);
return {
close,
};
}
export default introduceModal;
|
src/svg-icons/action/zoom-out.js | pancho111203/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let ActionZoomOut = (props) => (
<SvgIcon {...props}>
<path d="M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14zM7 9h5v1H7z"/>
</SvgIcon>
);
ActionZoomOut = pure(ActionZoomOut);
ActionZoomOut.displayName = 'ActionZoomOut';
ActionZoomOut.muiName = 'SvgIcon';
export default ActionZoomOut;
|
src/NavItem.js | aparticka/react-bootstrap | import React from 'react';
import classNames from 'classnames';
import BootstrapMixin from './BootstrapMixin';
import SafeAnchor from './SafeAnchor';
const NavItem = React.createClass({
mixins: [BootstrapMixin],
propTypes: {
linkId: React.PropTypes.string,
onSelect: React.PropTypes.func,
active: React.PropTypes.bool,
disabled: React.PropTypes.bool,
href: React.PropTypes.string,
role: React.PropTypes.string,
title: React.PropTypes.node,
eventKey: React.PropTypes.any,
target: React.PropTypes.string,
'aria-controls': React.PropTypes.string
},
getDefaultProps() {
return {
active: false,
disabled: false
};
},
render() {
let {
role,
linkId,
disabled,
active,
href,
title,
target,
children,
'aria-controls': ariaControls,
...props } = this.props;
let classes = {
active,
disabled
};
let linkProps = {
role,
href,
title,
target,
id: linkId,
onClick: this.handleClick
};
if (!role && href === '#') {
linkProps.role = 'button';
}
return (
<li {...props} role='presentation' className={classNames(props.className, classes)}>
<SafeAnchor {...linkProps} aria-selected={active} aria-controls={ariaControls}>
{ children }
</SafeAnchor>
</li>
);
},
handleClick(e) {
if (this.props.onSelect) {
e.preventDefault();
if (!this.props.disabled) {
this.props.onSelect(this.props.eventKey, this.props.href, this.props.target);
}
}
}
});
export default NavItem;
|
app/components/LoadingIndicator/index.js | gihrig/react-boilerplate-logic | import React from 'react';
import Circle from './Circle';
import Wrapper from './Wrapper';
const LoadingIndicator = () => (
<Wrapper>
<Circle />
<Circle rotate={30} delay={-1.1} />
<Circle rotate={60} delay={-1} />
<Circle rotate={90} delay={-0.9} />
<Circle rotate={120} delay={-0.8} />
<Circle rotate={150} delay={-0.7} />
<Circle rotate={180} delay={-0.6} />
<Circle rotate={210} delay={-0.5} />
<Circle rotate={240} delay={-0.4} />
<Circle rotate={270} delay={-0.3} />
<Circle rotate={300} delay={-0.2} />
<Circle rotate={330} delay={-0.1} />
</Wrapper>
);
export default LoadingIndicator;
|
app/components/Logs-UI.js | L-A/Little-Jekyll | import React, { Component } from 'react';
import TitleBar from './Title-bar';
import LogsList from './Logs-list';
import Dispatcher from '../utils/front-end-dispatcher';
var LogsUI = React.createClass({
getInitialState: function() {
return {};
},
render: function() {
return (
<div className="logs-root">
<TitleBar />
<LogsList />
</div>
);
}
});
// I keep forgetting to export. So here's a reminder.
module.exports = LogsUI;
|
modules/gui/src/app/home/map/progress.js | openforis/sepal | import {compose} from 'compose'
import {selectFrom} from 'stateUtils'
import {withRecipe} from '../body/process/recipeContext'
import React from 'react'
import styles from './progress.module.css'
const mapRecipeToProps = recipe => ({
working: !!Object.keys(selectFrom(recipe, 'ui.mapOperations') || {}).length
})
const _Progress = ({working}) =>
<div className={[styles.progress, working ? styles.active : null].join(' ')}/>
export const Progress = compose(
_Progress,
withRecipe(mapRecipeToProps)
)
export const setActive = (id, recipeActionBuilder) =>
recipeActionBuilder('SET_MAP_OPERATION', id)
.set(['ui.mapOperations', id], true)
.dispatch()
export const setComplete = (id, recipeActionBuilder) =>
recipeActionBuilder('COMPLETE_MAP_OPERATION', id)
.del(['ui.mapOperations', id])
.dispatch()
Progress.propTypes = {}
|
app/jsx/webzip_export/components/ExportInProgress.js | djbender/canvas-lms | /*
* Copyright (C) 2016 - present Instructure, Inc.
*
* This file is part of Canvas.
*
* Canvas is free software: you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License as published by the Free
* Software Foundation, version 3 of the License.
*
* Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import React from 'react'
import PropTypes from 'prop-types'
import ApiProgressBar from '../../shared/ApiProgressBar'
import I18n from 'i18n!webzip_exports'
class ExportInProgress extends React.Component {
static propTypes = {
webzip: PropTypes.shape({
progressId: PropTypes.string.isRequired
}),
loadExports: PropTypes.func.isRequired
}
constructor(props) {
super(props)
this.state = {completed: false}
}
onComplete = () => {
this.setState({completed: true})
this.props.loadExports(this.props.webzip.progressId)
}
render() {
if (!this.props.webzip || this.state.completed) {
return null
}
return (
<div className="webzipexport__inprogress">
<span>{I18n.t('Processing')}</span>
<p>{I18n.t('this may take a bit...')}</p>
<ApiProgressBar
progress_id={this.props.webzip.progressId}
onComplete={this.onComplete}
key={this.props.webzip.progressId}
/>
<p>
{I18n.t(`The download process has started. This
can take awhile for large courses. You can leave the
page and you'll get a notification when the download
is complete.`)}
</p>
<hr />
</div>
)
}
}
export default ExportInProgress
|
src/svg-icons/editor/format-align-center.js | rhaedes/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let EditorFormatAlignCenter = (props) => (
<SvgIcon {...props}>
<path d="M7 15v2h10v-2H7zm-4 6h18v-2H3v2zm0-8h18v-2H3v2zm4-6v2h10V7H7zM3 3v2h18V3H3z"/>
</SvgIcon>
);
EditorFormatAlignCenter = pure(EditorFormatAlignCenter);
EditorFormatAlignCenter.displayName = 'EditorFormatAlignCenter';
export default EditorFormatAlignCenter;
|
docs/src/app/components/pages/components/Card/Page.js | hwo411/material-ui | import React from 'react';
import Title from 'react-title-component';
import CodeExample from '../../../CodeExample';
import PropTypeDescription from '../../../PropTypeDescription';
import MarkdownElement from '../../../MarkdownElement';
import cardReadmeText from './README';
import cardExampleWithAvatarCode from '!raw!./ExampleWithAvatar';
import CardExampleWithAvatar from './ExampleWithAvatar';
import cardExampleExpandableCode from '!raw!./ExampleExpandable';
import CardExampleExpandable from './ExampleExpandable';
import cardExampleControlledCode from '!raw!./ExampleControlled';
import CardExampleControlled from './ExampleControlled';
import cardCode from '!raw!material-ui/Card/Card';
import cardActionsCode from '!raw!material-ui/Card/CardActions';
import cardHeaderCode from '!raw!material-ui/Card/CardHeader';
import cardMediaCode from '!raw!material-ui/Card/CardMedia';
import cardTextCode from '!raw!material-ui/Card/CardText';
import cardTitleCode from '!raw!material-ui/Card/CardTitle';
const descriptions = {
avatar: 'A `Card` containing each of the card components: `CardHeader` (with avatar), `CardMedia` (with overlay), ' +
'`CardTitle`, `CardText` & `CardActions`.',
simple: 'An expandable `Card` with `CardHeader`, `CardText` and `CardActions`. ' +
'Use the icon to expand the card.',
controlled: 'A controlled expandable `Card`. Use the icon, the toggle or the ' +
'buttons to control the expanded state of the card.',
};
const CardPage = () => (
<div>
<Title render={(previousTitle) => `Card - ${previousTitle}`} />
<MarkdownElement text={cardReadmeText} />
<CodeExample
title="Card components example"
description={descriptions.avatar}
code={cardExampleWithAvatarCode}
>
<CardExampleWithAvatar />
</CodeExample>
<CodeExample
title="Expandable example"
description={descriptions.simple}
code={cardExampleExpandableCode}
>
<CardExampleExpandable />
</CodeExample>
<CodeExample
title="Controlled example"
description={descriptions.controlled}
code={cardExampleControlledCode}
>
<CardExampleControlled />
</CodeExample>
<PropTypeDescription code={cardCode} header="### Card properties" />
<PropTypeDescription code={cardActionsCode} header="### CardActions properties" />
<PropTypeDescription code={cardHeaderCode} header="### CardHeader properties" />
<PropTypeDescription code={cardMediaCode} header="### CardMedia properties" />
<PropTypeDescription code={cardTextCode} header="### CardText properties" />
<PropTypeDescription code={cardTitleCode} header="### CardTitle properties" />
</div>
);
export default CardPage;
|
src/components/World/index.js | colinmeinke/css-modules-universal-example | import React from 'react';
import styles from './styles.css';
const World = () => <h1 className={ styles.world }>World</h1>;
export default World;
|
src/client/Story.js | JiLiZART/tmfeed-menu | import React from 'react'
import moment from 'moment';
import 'moment/locale/ru.js';
export default class Story extends React.Component {
markAsRead() {
this.props.onMarkAsRead(this.props.story.id);
}
openUrl(url) {
this.props.onUrlClick(url);
}
handleExternalUrlOnClick(e) {
e.preventDefault();
this.openUrl(this.props.story.url);
}
handleUrlClick(e) {
e.preventDefault();
this.markAsRead();
this.openUrl(this.props.story.url);
}
render() {
var story = this.props.story;
var storyState;
if (story.hasRead) {
storyState = 'story story_status_read'
} else {
storyState = 'story'
}
/**
{
id: 19538,
time_published: '2015-09-18T19:19:46+03:00',
url: 'http://megamozg.ru/post/19538/',
title: 'Финтехкомпании могут уровнять в правах и обязанностях с банками',
score: null,
comments_count: 0,
reading_count: 669,
favorites_count: 2,
site: 'megamozg'
}
*/
let timeAgo = moment(story.time_published).fromNow();
return (
<div className={storyState}>
<h4 className='story__title'
onClick={this.handleUrlClick.bind(this)}>{story.title}</h4>
<div className='story__meta'>
<span className={'story__meta-icon site-icon site-icon--' + story.site}></span>
<span className='story__meta-item story__comments'
onClick={this.handleExternalUrlOnClick.bind(this)}>
<span>комментарии: </span>
<b>{story.comments_count}</b>
</span>
<span className='story__meta-item story__views'>
<span>просмотры: </span>
<b>{story.reading_count}</b>
</span>
<span className='story__meta-item story__favs'>
<span>в избранном: </span>
<b>{story.favorites_count}</b>
</span>
<span className='story__meta-item story__date'
onClick={this.handleExternalUrlOnClick.bind(this)}>{timeAgo}</span>
</div>
</div>
)
}
}
Story.propTypes = {
onUrlClick: React.PropTypes.func.isRequired,
onMarkAsRead: React.PropTypes.func.isRequired,
story: React.PropTypes.object.isRequired
};
|
frontend/src/Album/Edit/EditAlbumModal.js | lidarr/Lidarr | import PropTypes from 'prop-types';
import React from 'react';
import Modal from 'Components/Modal/Modal';
import EditAlbumModalContentConnector from './EditAlbumModalContentConnector';
function EditAlbumModal({ isOpen, onModalClose, ...otherProps }) {
return (
<Modal
isOpen={isOpen}
onModalClose={onModalClose}
>
<EditAlbumModalContentConnector
{...otherProps}
onModalClose={onModalClose}
/>
</Modal>
);
}
EditAlbumModal.propTypes = {
isOpen: PropTypes.bool.isRequired,
onModalClose: PropTypes.func.isRequired
};
export default EditAlbumModal;
|
public/js/components/admin/settings/NewAdminmodal.react.js | rajikaimal/Coupley | /**
* Created by Isuru 1 on 30/01/2016.
*/
import React from 'react';
import Dialog from 'material-ui/lib/dialog';
import FlatButton from 'material-ui/lib/flat-button';
import RaisedButton from 'material-ui/lib/raised-button';
import TextField from 'material-ui/lib/text-field';
import snack from './snackbar.react';
import Snackbar from 'material-ui/lib/snackbar';
import CardTitle from 'material-ui/lib/card/card-title';
import Card from 'material-ui/lib/card/card';
import CardActions from 'material-ui/lib/card/card-actions';
import Paper from 'material-ui/lib/paper';
import CardText from 'material-ui/lib/card/card-text';
import DropDownMenu from 'material-ui/lib/DropDownMenu';
import MenuItem from 'material-ui/lib/menus/menu-item';
import GridList from 'material-ui/lib/grid-list/grid-list';
import GridTile from 'material-ui/lib/grid-list/grid-tile';
import Table from 'material-ui/lib/table/table';
import TableRow from 'material-ui/lib/table/table-row';
import TableRowColumn from 'material-ui/lib/table/table-row-column';
import TableBody from 'material-ui/lib/table/table-body';
import Colors from 'material-ui/lib/styles/colors';
import RegisterActions from '../../../actions/admin/AdminRegisterActions';
const tilesData = [
{
img: '../../../../img/Add_users_plus_group_people_friends.png',
title: 'New Administrator',
},
];
const style = {
width: 300,
height:50,
fontSize: '20px',
color:'white',
};
const tileElements = tilesData.map(tile => <GridTile
key={tile.img}
title={<FlatButton label={tile.title} secondary={true} style={style} linkButton={true} />}
><img src={tile.img} /></GridTile>);
const gridListStyle = { width: 600, height: 220, overflowY: 'auto' };
const customContentStyle = {
width: '100%',
};
const err = { color: 'red' };
const registerStyle = {
marginTop: 50,
marginLeft: 500,
};
const styles = {
button: {
margin: 12,
},
errorStyle: {
color: Colors.pink500,
},
};
const buttonStyle = {
marginTop: 25,
};
function validatefirstname(firstname) {
if (firstname.length >= 50) {
return {
error: '*Firstname is too long',
};
} else if (!/^\w+$/i.test(firstname)) {
return {
error: '*Only upper & lower case letters without accesents and spaces are allowed',
};
} else {
return true;
}
}
function validatelastname(lastname) {
if (firstname.length >= 50) {
return {
error: '*Lastname is too long',
};
} else if (!/^\w+$/i.test(lastname)) {
return {
error: '*Only upper & lower case letters without accesents and spaces are allowed',
};
} else {
return true;
}
}
function validatejobname(job) {
if (firstname.length >= 20) {
return {
error: '*Jobname is too long',
};
} else if (!/^\w+$/i.test(job)) {
return {
error: '*Only upper & lower case letters without accesents and spaces are allowed',
};
} else {
return true;
}
}
function validateEmail(email) {
let re = /\S+@\S+\.\S+/;
if (re.test(email)) {
return true;
} else {
return false;
}
}
function validatePassword(password) {
if (password.length < 6) {
return {
error: '*Password length must be 6 or more',
};
}
let re = /[0-9]/;
if (!re.test(password)) {
return {
error: '*Password must contain a number',
};
}
re = /[a-z]/;
if (!re.test(password)) {
return {
error: '*Password must contain a lowercase letter',
};
}
re = /[A-Z]/;
if (!re.test(password)) {
return {
error: '*Password must contain a uppercase letter',
};
} else {
return true;
}
}
function validateRePassword(Repassword, password) {
if (!(Repassword == password)) {
return {
error: '*Password Doesnt match',
};
} else {
return {
success: '*Password matches',
};
}
}
var Header = React.createClass({
getInitialState: function () {
return {
open: false,
opens: false,
};
},
handleOpen: function () {
this.setState({ open: true, opens: false });
},
handleClose: function () {
this.setState({ open: false });
},
handleTouchTap: function () {
this.setState({
opens: true,
});
},
handleBoth: function () {
if (this._handleRegisterClickEvent()) {
this.handleTouchTap();
this.handleClose();
}
},
reEnterPwd: function () {
let password = this.refs.password.getValue();
let RePass = this.refs.repassword.getValue();
if (validateRePassword(RePass, password).error) {
document.getElementById('repassword').innerHTML = validateRePassword(RePass, password).error;
document.getElementById('repassword').style.color = '#ff6666';
return false;
} else {
document.getElementById('repassword').innerHTML = validateRePassword(RePass, password).
success;
document.getElementById('repassword').style.color = '#66cc66';
return true;
}
},
_handleRegisterClickEvent: function () {
let firstname = this.refs.firstname.getValue();
let lastname = this.refs.lastname.getValue();
let job = this.refs.job.getValue();
let email = this.refs.email.getValue();
let password = this.refs.password.getValue();
let RePass = this.refs.repassword.getValue();
if (validatefirstname(firstname).error) {
document.getElementById('firstname').innerHTML = validatefirstname(firstname).error;
return false;
} else if (validatelastname(lastname).error) {
document.getElementById('lastname').innerHTML = validatelastname(lastname).error;
return false;
} else if (validatejobname(job).error) {
document.getElementById('job').innerHTML = validatejobname(job).error;
return false;
} else if (!validateEmail(email)) {
document.getElementById('email').innerHTML = '*Please enter a valid Email !';
return false;
} else if (validatePassword(password).error) {
document.getElementById('password').innerHTML = validatePassword(password).error;
return false;
}else if (validateRePassword(RePass, password).error) {
document.getElementById('repassword').innerHTML = validateRePassword(RePass, password).error;
document.getElementById('repassword').style.color = '#ff6666';
return false;
} else {
let credentials = {
firstname: firstname,
lastname: lastname,
job: job,
email: email,
password: password,
};
RegisterActions.checks(credentials);
console.log('Done calling !');
}
},
eleminateErrors:function () {
document.getElementById('firstname').innerHTML = ' ';
document.getElementById('job').innerHTML = ' ';
document.getElementById('password').innerHTML = ' ';
document.getElementById('lastname').innerHTML = ' ';
document.getElementById('email').innerHTML = ' ';
document.getElementById('repassword').innerHTML = ' ';
},
render: function () {
const actions = [
<FlatButton
label="Cancel"
secondary={true}
onTouchTap={this.handleClose}
/>,
<FlatButton
label="Submit"
primary={true}
keyboardFocused={true}
onTouchTap={this.handleBoth}
/>,
];
return (
<div className="" style={{ 'margin-left': '86%', top: '-218px', position: 'relative',
'min-height': '1px',
'padding-right': '15px',
'padding-left': '15px', }}>
<div className="">
<div>
<GridList
cellHeight={200}
style={gridListStyle}
onTouchTap={this.handleOpen}
>
{tileElements}
</GridList>
</div>
</div>
<Dialog
title="Add New Administrator"
actions={actions}
modal={false}
open={this.state.open}
onRequestClose={this.handleClose}
contentStyle={customContentStyle}
>
<div>
<div>
<div className="col-lg-12">
<Card>
<CardText onFocus={this.eleminateErrors}>
<div className="col-lg-6">
<TextField
hintText="Firstname" hintStyle={styles.errorStyle} fullwidth={true} ref="firstname"/>
<br />
<span id="firstname" style={err}> </span>
<br/>
<br/>
<TextField
hintText="Job Position" hintStyle={styles.errorStyle} fullwidth={true} ref="job"/>
<br />
<span id="job" style={err}> </span>
<br />
<br />
<snack/>
<TextField
type="password"
hintText="Password" ref="password" hintStyle={styles.errorStyle} fullwidth={true} onChange={this.reEnterPwd}/>
<br />
<span id="password" style={err}> </span>
<br />
<br />
</div>
<div className="col-lg-6">
<TextField
hintText="Lastname" hintStyle={styles.errorStyle} fullwidth={true} ref="lastname"/>
<br />
<span id="lastname" style={err}> </span>
<br />
<br />
<TextField
hintText="Email" hintStyle={styles.errorStyle} fullwidth={true} ref="email"/>
<br />
<span id="email" style={err}> </span>
<br />
<br />
<TextField
type="password"
hintText="ReEnter Password" ref="repassword" hintStyle={styles.errorStyle} fullwidth={true} onChange={this.reEnterPwd}/>
<br />
<span id="repassword"> </span>
<br />
<br />
</div>
</CardText>
<CardActions>
</CardActions>
</Card>
</div>
</div>
</div>
</Dialog>
<Snackbar
open={this.state.opens}
message="Successfully added a New Administrator to your system"
autoHideDuration={4000}
onRequestClose={this.handleRequestClose}
/>
</div>
);
},
});
export default Header;
|
src/components/ui/BackButton.js | N3TC4T/Nearby-Live | /**
* BackButton
*
<BackButton />
*
*/
import React from 'react';
import PropTypes from 'prop-types';
import {TouchableOpacity} from 'react-native';
import {Icon} from '@components/ui';
import {Actions} from 'react-native-router-flux';
/* Component ==================================================================== */
const BackButton = ({size, color}) => (
<TouchableOpacity onPress={Actions.pop}>
<Icon name='arrow-left' size={size} type='material-community' color={color} />
</TouchableOpacity>
);
BackButton.propTypes = {size: PropTypes.number, color: PropTypes.string};
BackButton.defaultProps = {size: 20, color: '#232F3A'};
BackButton.componentName = 'BackButton';
/* Export Component ==================================================================== */
export default BackButton;
|
clouseau-app/ui/src/index.js | commercehub-oss/clouseau | import React from 'react';
import ReactDOM from 'react-dom';
import url from 'url';
import Session from './Session';
import SessionList from './SessionList';
const query = url.parse(window.location.href, true).query;
if (query.sessionId) {
ReactDOM.render(
<Session sessionId={query.sessionId} forceRichView={query.forceRichView === 'true'} />,
document.getElementById('app')
);
} else {
ReactDOM.render(
<SessionList />,
document.getElementById('app')
);
}
|
frontend/src/containers/CollectionList/CollectionList.js | webrecorder/webrecorder | import React from 'react';
import { asyncConnect } from 'redux-connect';
import { batchActions } from 'redux-batched-actions';
import { saveDelay } from 'config';
import { addUserCollection, incrementCollCount } from 'store/modules/auth';
import { load as loadCollections, createCollection } from 'store/modules/collections';
import { edit } from 'store/modules/collection';
import { load as loadUser, edit as editUser, resetEditState } from 'store/modules/user';
import { sortCollsByAlpha } from 'store/selectors';
import CollectionListUI from 'components/collection/CollectionListUI';
const preloadCollections = [
{
promise: ({ match: { params: { user } }, store: { dispatch } }) => {
return dispatch(loadCollections(user));
}
},
{
promise: ({ match: { params }, store: { dispatch } }) => {
const { user } = params;
return dispatch(loadUser(user, false));
}
}
];
const mapStateToProps = ({ app }) => {
return {
auth: app.get('auth'),
collections: app.get('collections'),
edited: app.getIn(['user', 'edited']),
orderedCollections: app.getIn(['collections', 'loaded']) ? sortCollsByAlpha(app) : null,
user: app.get('user')
};
};
const mapDispatchToProps = (dispatch, { history }) => {
return {
createNewCollection: (user, collTitle, makePublic) => {
dispatch(createCollection(user, collTitle, makePublic))
.then((res) => {
if (res.hasOwnProperty('collection')) {
dispatch(batchActions([
incrementCollCount(1),
addUserCollection(res.collection)
]));
history.push(`/${user}/${res.collection.slug}/manage`);
}
}, () => {});
},
editCollection: (user, coll, data) => {
dispatch(edit(user, coll, data))
.then(res => dispatch(loadCollections(user)));
},
editUser: (user, data) => {
dispatch(editUser(user, data))
.then(res => setTimeout(() => dispatch(resetEditState()), saveDelay))
.then(() => dispatch(loadUser(user, false)));
}
};
};
export default asyncConnect(
preloadCollections,
mapStateToProps,
mapDispatchToProps
)(CollectionListUI);
|
src/DatePicker/components/Calendar.js | jmcriffey/react-ui | import React from 'react';
import {getClassName, chunk} from '../../utils';
class Calendar extends React.Component {
render() {
const className = getClassName(
'react-ui-date-picker-calendar',
this.props.calendarClassName
);
const subHeaderClassName = getClassName(
'react-ui-date-picker-calendar-sub-header',
this.props.calendarSubHeaderClassName
);
const bodyClassName = getClassName(
'react-ui-date-picker-calendar-body',
this.props.calendarBodyClassName
);
return (
<table
className={className}
onMouseDown={this.props.onCancelBlur}>
{this.renderHeader()}
<tr
className={subHeaderClassName}
onMouseDown={this.props.onCancelBlur}>
{this.renderSubHeader()}
</tr>
<tr
className={bodyClassName}
onMouseDown={this.props.onCancelBlur}>
{this.renderBody()}
</tr>
</table>
);
}
renderHeader() {
const headerClassName = getClassName(
'react-ui-date-picker-calendar-header',
this.props.calendarHeaderClassName
);
const previousClassName = getClassName(
'react-ui-date-picker-calendar-header-previous',
this.props.calendarHeaderPreviousClassName
);
const nextClassName = getClassName(
'react-ui-date-picker-calendar-header-next',
this.props.calendarHeaderNextClassName
);
return (
<tr
className={headerClassName}
onMouseDown={this.props.onCancelBlur}>
<td onClick={this.props.onPreviousClick}>
<span className={previousClassName}></span>
</td>
<td
colSpan={5}
onClick={this.props.onCancelBlur}
onMouseDown={this.props.onCancelBlur}>
{this.renderMonthSelector()}
{this.renderYearSelector()}
</td>
<td onClick={this.props.onNextClick}>
<span className={nextClassName}></span>
</td>
</tr>
);
}
renderMonthSelector() {
const date = this.props.selectedMonth;
const className = 'react-ui-date-picker-calendar-month-selector';
const monthOptions = this.props.monthNames.map((name, i) => (
<option key={i} value={i}>
{name}
</option>
));
return (
<select
className={className}
onBlur={this.props.onCancelBlur}
onChange={this.props.onChangeMonth}
onFocus={this.props.onCancelBlur}
onMouseDown={this.props.onCancelBlur}
onClick={this.props.onCancelBlur}
value={date.getMonth()}>
{monthOptions}
</select>
);
}
renderYearSelector() {
const date = this.props.selectedMonth;
const className = 'react-ui-date-picker-calendar-year-selector';
const yearOptions = this.getYears().map((year, i) => (
<option key={i} value={year}>
{year}
</option>
));
return (
<select
className={className}
onBlur={this.props.onCancelBlur}
onChange={this.props.onChangeYear}
onFocus={this.props.onCancelBlur}
onMouseDown={this.props.onCancelBlur}
onClick={this.props.onCancelBlur}
value={date.getFullYear()}>
{yearOptions}
</select>
);
}
renderSubHeader() {
return this.props.dayNames.map((name) => name[0]).map((name, i) => (
<td key={i}
onClick={this.props.onCancelBlur}
onMouseDown={this.props.onCancelBlur}>
{name}
</td>
));
}
renderBody() {
return chunk(this.getDates(), 7).map((week, i) => {
const days = week.map((day, j) => {
const disabled = this.isDateDisabled(day);
const value = this.props.value;
const today = this.props.today;
const currentDayClass = (
this.datesEqual(day, today) ?
'react-ui-date-picker-calendar-current-day' :
null
);
const disabledDayClass = (
disabled ?
'react-ui-date-picker-calendar-disabled-day' :
null
);
const selectedDayClass = (
value && this.datesEqual(day, value) ?
'react-ui-date-picker-calendar-selected-day' :
null
);
const selectedMonthClass = (
this.props.selectedMonth.getMonth() === day.getMonth() ?
'react-ui-date-picker-calendar-selected-month' :
null
);
const dayClassName = getClassName(
'react-ui-date-picker-calendar-day',
currentDayClass,
selectedMonthClass,
disabledDayClass,
selectedDayClass
);
return (
<td
className={dayClassName}
disabled={disabled}
key={j}
onClick={this.props.onDateClick.bind(null, day, disabled)}
onMouseDown={this.props.onCancelBlur}>
{day.getDate()}
</td>
);
});
return (
<tr
className="react-ui-date-picker-calendar-week"
key={i}>
{days}
</tr>
);
});
}
getDates() {
const startDate = this.getStartDate();
const dates = [startDate];
while (dates.length < 42) {
dates.push(this.addDays(dates[dates.length - 1], 1));
}
return dates;
}
datesEqual(a, b) {
return (
a.getDate() === b.getDate() &&
a.getMonth() === b.getMonth() &&
a.getFullYear() === b.getFullYear()
);
}
addDays(d, n) {
const date = new Date(d);
date.setDate(date.getDate() + n);
return date;
}
getStartDate() {
const date = new Date(
this.props.selectedMonth.getFullYear(),
this.props.selectedMonth.getMonth(),
1
);
while (date.getDay() !== 0) {
date.setDate(date.getDate() - 1);
}
return date;
}
getYears() {
const years = [this.props.minValue.getFullYear()];
const maxYear = this.props.maxValue.getFullYear();
while (years[years.length - 1] < maxYear) {
years.push(years[years.length - 1] + 1);
}
return years;
}
isDateDisabled(date) {
return (
this.props.isDateDisabled(date) ||
(this.props.maxValue && date > this.props.maxValue) ||
(this.props.minValue && date < this.props.minValue)
);
}
}
export default Calendar;
|
pkg/interface/groups/src/js/components/lib/share-sheet.js | ngzax/urbit | import React, { Component } from 'react';
import { Route, Link } from 'react-router-dom';
import { Sigil } from '../lib/icons/sigil';
import { uxToHex } from '../../lib/util';
import { ContactItem } from '/components/lib/contact-item';
export class ShareSheet extends Component {
render() {
const { props } = this;
let selectedClass = (props.selected) ? "bg-gray4" : "";
let hexColor = uxToHex(props.color);
return (
<div>
<p className="pt4 pb2 pl4 pr4 f8 gray2 f9">Group Identity</p>
<ContactItem
key={props.ship}
avatar={props.avatar}
ship={props.ship}
nickname={props.nickname}
color={props.color}
path={props.path}
selected={props.selected}
share={true} />
<p className="pt2 pb3 pl4 pr4 f9 white-d">
Your personal information is hidden to others in this group
by default.
</p>
<p className="pl4 pr4 f9 white-d">
Share whenever you are ready, or edit its contents for this group.
</p>
</div>
);
}
}
|
app/javascript/mastodon/components/status_list.js | kagucho/mastodon | import React from 'react';
import ImmutablePropTypes from 'react-immutable-proptypes';
import { ScrollContainer } from 'react-router-scroll';
import PropTypes from 'prop-types';
import StatusContainer from '../containers/status_container';
import LoadMore from './load_more';
import ImmutablePureComponent from 'react-immutable-pure-component';
import IntersectionObserverWrapper from '../features/ui/util/intersection_observer_wrapper';
import { debounce } from 'lodash';
export default class StatusList extends ImmutablePureComponent {
static propTypes = {
scrollKey: PropTypes.string.isRequired,
statusIds: ImmutablePropTypes.list.isRequired,
onScrollToBottom: PropTypes.func,
onScrollToTop: PropTypes.func,
onScroll: PropTypes.func,
trackScroll: PropTypes.bool,
shouldUpdateScroll: PropTypes.func,
isLoading: PropTypes.bool,
hasMore: PropTypes.bool,
prepend: PropTypes.node,
emptyMessage: PropTypes.node,
};
static defaultProps = {
trackScroll: true,
};
intersectionObserverWrapper = new IntersectionObserverWrapper();
handleScroll = debounce((e) => {
const { scrollTop, scrollHeight, clientHeight } = e.target;
const offset = scrollHeight - scrollTop - clientHeight;
this._oldScrollPosition = scrollHeight - scrollTop;
if (250 > offset && this.props.onScrollToBottom && !this.props.isLoading) {
this.props.onScrollToBottom();
} else if (scrollTop < 100 && this.props.onScrollToTop) {
this.props.onScrollToTop();
} else if (this.props.onScroll) {
this.props.onScroll();
}
}, 200, {
trailing: true,
});
componentDidMount () {
this.attachScrollListener();
this.attachIntersectionObserver();
}
componentDidUpdate (prevProps) {
// Reset the scroll position when a new toot comes in in order not to
// jerk the scrollbar around if you're already scrolled down the page.
if (prevProps.statusIds.size < this.props.statusIds.size &&
prevProps.statusIds.first() !== this.props.statusIds.first() &&
this._oldScrollPosition &&
this.node.scrollTop > 0) {
let newScrollTop = this.node.scrollHeight - this._oldScrollPosition;
if (this.node.scrollTop !== newScrollTop) {
this.node.scrollTop = newScrollTop;
}
}
}
componentWillUnmount () {
this.detachScrollListener();
this.detachIntersectionObserver();
}
attachIntersectionObserver () {
this.intersectionObserverWrapper.connect({
root: this.node,
rootMargin: '300% 0px',
});
}
detachIntersectionObserver () {
this.intersectionObserverWrapper.disconnect();
}
attachScrollListener () {
this.node.addEventListener('scroll', this.handleScroll);
}
detachScrollListener () {
this.node.removeEventListener('scroll', this.handleScroll);
}
setRef = (c) => {
this.node = c;
}
handleLoadMore = (e) => {
e.preventDefault();
this.props.onScrollToBottom();
}
render () {
const { statusIds, scrollKey, trackScroll, shouldUpdateScroll, isLoading, hasMore, prepend, emptyMessage } = this.props;
let loadMore = null;
let scrollableArea = null;
if (!isLoading && statusIds.size > 0 && hasMore) {
loadMore = <LoadMore onClick={this.handleLoadMore} />;
}
if (isLoading || statusIds.size > 0 || !emptyMessage) {
scrollableArea = (
<div className='scrollable' ref={this.setRef}>
<div className='status-list'>
{prepend}
{statusIds.map((statusId) => {
return <StatusContainer key={statusId} id={statusId} intersectionObserverWrapper={this.intersectionObserverWrapper} />;
})}
{loadMore}
</div>
</div>
);
} else {
scrollableArea = (
<div className='empty-column-indicator' ref={this.setRef}>
{emptyMessage}
</div>
);
}
if (trackScroll) {
return (
<ScrollContainer scrollKey={scrollKey} shouldUpdateScroll={shouldUpdateScroll}>
{scrollableArea}
</ScrollContainer>
);
} else {
return scrollableArea;
}
}
}
|
src/routes/home/index.js | jwhchambers/react-starter-kit | /**
* 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 from 'react';
import Home from './Home';
import fetch from '../../core/fetch';
export default {
path: '/',
async action() {
const resp = await fetch('/graphql', {
method: 'post',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify({
query: '{news{title,link,publishedDate,contentSnippet}}',
}),
credentials: 'include',
});
const { data } = await resp.json();
if (!data || !data.news) throw new Error('Failed to load the news feed.');
return {
title: 'React Starter Kit',
component: <Home news={data.news} />,
};
},
};
|
npm/node_modules/browser-sync/node_modules/bs-recipes/recipes/webpack.react-transform-hmr/app/js/main.js | ganyuling/nvm | 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/index.js | calvellido/reactjs-training | /* eslint-disable import/default */
import React from 'react';
import {render} from 'react-dom';
import { Provider } from 'react-redux';
import { Router, browserHistory } from 'react-router';
import routes from './routes';
import configureStore from './store/configureStore';
require('./favicon.ico'); // Tell webpack to load favicon.ico
import './styles/styles.scss'; // Yep, that's right. You can import SASS/CSS files too! Webpack will run the associated loader and plug this into the page.
import { syncHistoryWithStore } from 'react-router-redux';
const store = configureStore();
// Create an enhanced history that syncs navigation events with the store
const history = syncHistoryWithStore(browserHistory, store);
render(
<Provider store={store}>
<Router history={history} routes={routes} />
</Provider>, document.getElementById('app')
);
|
jekyll-strapi-tutorial/api/plugins/users-permissions/admin/src/components/HeaderNav/index.js | strapi/strapi-examples | /**
*
* HeaderNav
*
*/
import React from 'react';
import { FormattedMessage } from 'react-intl';
import { NavLink } from 'react-router-dom';
import { map } from 'lodash';
// Utils
import { darken } from 'utils/colors';
// Styles
import styles from './styles.scss';
const links = [
{
name: 'users-permissions.HeaderNav.link.roles',
to: '/plugins/users-permissions/roles',
},
{
name: 'users-permissions.HeaderNav.link.providers',
to: '/plugins/users-permissions/providers',
},
{
name: 'users-permissions.HeaderNav.link.emailTemplates',
to: '/plugins/users-permissions/email-templates',
},
{
name: 'users-permissions.HeaderNav.link.advancedSettings',
to: '/plugins/users-permissions/advanced',
},
];
function HeaderNav() {
let linkColor = '#F5F5F5';
return (
<div className={styles.headerContainer}>
{map(links, (link) => {
linkColor = darken(linkColor, 1.5);
return (
<NavLink key={link.name} className={styles.headerLink} style={{ backgroundColor: linkColor}} to={link.to} activeClassName={styles.linkActive}>
<div className={`${styles.linkText} text-center`}>
<FormattedMessage id={link.name} />
</div>
</NavLink>
);
})}
</div>
);
}
HeaderNav.propTypes = {};
export default HeaderNav;
|
src/containers/recipes/Card/CardView.js | npdat/Demo_React_Native | /**
* Recipe View Screen
* - The individual recipe screen
*
* React Native Starter App
* https://github.com/mcnamee/react-native-starter-app
*/
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import {
View,
StyleSheet,
TouchableOpacity,
} from 'react-native';
import { Icon } from 'react-native-elements';
// Consts and Libs
import { AppStyles } from '@theme/';
// Components
import { Card, Text } from '@ui/';
/* Styles ==================================================================== */
const styles = StyleSheet.create({
favourite: {
position: 'absolute',
top: -45,
right: 0,
},
});
/* Component ==================================================================== */
class RecipeCard extends Component {
static componentName = 'RecipeCard';
static propTypes = {
image: PropTypes.string.isRequired,
title: PropTypes.string.isRequired,
body: PropTypes.string.isRequired,
onPress: PropTypes.func,
onPressFavourite: PropTypes.func,
isFavourite: PropTypes.bool,
}
static defaultProps = {
onPress: null,
onPressFavourite: null,
isFavourite: null,
}
render = () => {
const { title, body, image, onPress, onPressFavourite, isFavourite } = this.props;
return (
<TouchableOpacity activeOpacity={0.8} onPress={onPress}>
<Card image={image && { uri: image }}>
<View style={[AppStyles.paddingBottomSml]}>
<Text h3>{title}</Text>
<Text>{body}</Text>
{!!onPressFavourite &&
<TouchableOpacity
activeOpacity={0.8}
onPress={onPressFavourite}
style={[styles.favourite]}
>
<Icon
raised
name={'star-border'}
color={isFavourite ? '#FFFFFF' : '#FDC12D'}
containerStyle={{
backgroundColor: isFavourite ? '#FDC12D' : '#FFFFFF',
}}
/>
</TouchableOpacity>
}
</View>
</Card>
</TouchableOpacity>
);
}
}
/* Export Component ==================================================================== */
export default RecipeCard;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.