path stringlengths 5 195 | repo_name stringlengths 5 79 | content stringlengths 25 1.01M |
|---|---|---|
src/index.js | justin0022/student-services-forms | 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';
import 'react-datepicker/dist/react-datepicker.css';
const store = configureStore();
const history = syncHistoryWithStore(browserHistory, store);
render(
<Provider store={store}>
<Router history={history} routes={routes} />
</Provider>, document.getElementById('app')
); |
src/components/App/index.js | LittleFurryBastards/webpack-react-redux | import './app.less';
import React from 'react';
import { Link } from 'react-router';
const App = ({ children }) => (
<section className="wrr-app">
<header className="wrr-app__header">
<h1><Link to="/">User Information</Link></h1>
</header>
{ children }
</section>
);
App.propTypes = {
children: React.PropTypes.element
};
export default App;
|
styleguide/sections/Icons.js | tomgatzgates/loggins | import React, { Component } from 'react';
import Section from '../components/Section';
import allIcons from 'components/Icon/icons.js';
import * as m from 'globals/modifiers.css';
import Icon from 'components/Icon/Icon';
export default class Icons extends Component {
render() {
delete allIcons.default;
const container = {
textAlign: 'center',
};
const outer = {
display: 'inline-block',
textAlign: 'center',
padding: '0.5em',
width: '10em',
};
const title = {
fontFamily: 'monospace',
};
const icon = {
display: 'block',
margin: '0 auto',
fontSize: '3em',
background: 'rgba(255,255,255,0.7)',
borderRadius: '2px',
};
return (
<Section name="Icons" href="https://github.com/PactCoffee/loggins/blob/master/styleguide%2Fsections%2FIcons.js">
<h2>Icon component</h2>
<p>
Use like: <code>{'<Icon name="heart" />'}</code> to produce: <Icon name="heart" />
</p>
<p>You can pass classnames in too to modify their look:
<br />
<Icon name="chevron" />
<Icon name="chevron" className={m.rotate90} />
<Icon name="chevron" className={m.rotate180} />
<Icon name="chevron" className={m.rotate270} />
</p>
<h2>All our icons</h2>
<div style={container}>
{Object.keys(allIcons).map(k =>
<div style={outer} key={k}>
<Icon style={icon} name={k} />
<span style={title}>{k}</span>
</div>
)}
</div>
</Section>
);
}
}
|
src/svg-icons/image/nature-people.js | hwo411/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let ImageNaturePeople = (props) => (
<SvgIcon {...props}>
<path d="M22.17 9.17c0-3.87-3.13-7-7-7s-7 3.13-7 7c0 3.47 2.52 6.34 5.83 6.89V20H6v-3h1v-4c0-.55-.45-1-1-1H3c-.55 0-1 .45-1 1v4h1v5h16v-2h-3v-3.88c3.47-.41 6.17-3.36 6.17-6.95zM4.5 11c.83 0 1.5-.67 1.5-1.5S5.33 8 4.5 8 3 8.67 3 9.5 3.67 11 4.5 11z"/>
</SvgIcon>
);
ImageNaturePeople = pure(ImageNaturePeople);
ImageNaturePeople.displayName = 'ImageNaturePeople';
ImageNaturePeople.muiName = 'SvgIcon';
export default ImageNaturePeople;
|
app/containers/NotFoundPage/index.js | ParkarDev/react-resume | /**
* NotFoundPage
*
* This is the page we show when the user visits a url that doesn't have a route
*/
import React from 'react';
import { connect } from 'react-redux';
import { routeActions } from 'react-router-redux';
import Button from 'Button';
import H1 from 'H1';
export function NotFound(props) {
return (
<article>
<H1>Page not found.</H1>
<Button
handleRoute={function redirect() {
props.changeRoute('/');
}}
>
Home
</Button>
</article>
);
}
// react-redux stuff
function mapDispatchToProps(dispatch) {
return {
changeRoute: (url) => dispatch(routeActions.push(url)),
};
}
// Wrap the component to inject dispatch and state into it
export default connect(null, mapDispatchToProps)(NotFound);
|
src/server/bootstrapApp.js | cle1994/personal-website | /* ==========================================================================
* ./src/server/bootstrapApp.js
*
* Bootstrap React/Redux server side
* ========================================================================== */
import tracer from 'tracer';
import React from 'react';
import { renderToString } from 'react-dom/server';
import { Provider } from 'react-redux';
import { RoutingContext } from 'react-router';
import Helmet from 'react-helmet';
import { fetchComponentData } from 'src/shared/api/utils/fetchComponentData';
import configureStore from 'src/shared/store/configureStore';
import renderHtml from 'src/server/renderHTML';
const logger = tracer.colorConsole();
export default function bootstrapApp(res, renderProps, state) {
const store = configureStore(state);
const InitialView = (
<Provider store={ store }>
<RoutingContext { ...renderProps } />
</Provider>
);
fetchComponentData(
store.dispatch,
renderProps.components,
renderProps.params
).then(() => {
const componentHTML = renderToString(InitialView);
const head = Helmet.rewind();
const initialState = store.getState();
const viewRendered = renderHtml(componentHTML, initialState, head);
res.status(200).end(viewRendered);
})
.catch(error => {
logger.error(error.toString());
res.end(renderHtml('', {}, 'Christian Le'));
});
};
|
components/date_picker/Calendar.js | showings/react-toolbox | import React, { Component } from 'react';
import PropTypes from 'prop-types';
import CssTransitionGroup from 'react-transition-group/CSSTransitionGroup';
import { range, getAnimationModule } from '../utils/utils';
import time from '../utils/time';
import CalendarMonth from './CalendarMonth';
const DIRECTION_STEPS = { left: -1, right: 1 };
const factory = (IconButton) => {
class Calendar extends Component {
static propTypes = {
disabledDates: PropTypes.arrayOf(PropTypes.instanceOf(Date)),
display: PropTypes.oneOf(['months', 'years']),
enabledDates: PropTypes.arrayOf(PropTypes.instanceOf(Date)),
handleSelect: PropTypes.func,
locale: PropTypes.oneOfType([
PropTypes.string,
PropTypes.object,
]),
maxDate: PropTypes.instanceOf(Date),
minDate: PropTypes.instanceOf(Date),
onChange: PropTypes.func,
selectedDate: PropTypes.instanceOf(Date),
sundayFirstDayOfWeek: PropTypes.bool,
theme: PropTypes.shape({
active: PropTypes.string,
calendar: PropTypes.string,
next: PropTypes.string,
prev: PropTypes.string,
years: PropTypes.string,
}),
};
static defaultProps = {
display: 'months',
selectedDate: new Date(),
};
state = {
viewDate: this.props.selectedDate,
};
componentWillMount() {
document.body.addEventListener('keydown', this.handleKeys);
}
componentDidUpdate() {
if (this.activeYearNode) {
this.scrollToActive();
}
}
componentWillUnmount() {
document.body.removeEventListener('keydown', this.handleKeys);
}
scrollToActive() {
const offset = (this.yearsNode.offsetHeight / 2) + (this.activeYearNode.offsetHeight / 2);
this.yearsNode.scrollTop = this.activeYearNode.offsetTop - offset;
}
handleDayClick = (day) => {
this.props.onChange(time.setDay(this.state.viewDate, day), true);
};
handleYearClick = (event) => {
const year = parseInt(event.currentTarget.id, 10);
const viewDate = time.setYear(this.props.selectedDate, year);
this.setState({ viewDate });
this.props.onChange(viewDate, false);
};
handleKeys = (e) => {
const { selectedDate } = this.props;
if (e.which === 37 || e.which === 38 || e.which === 39 || e.which === 40 || e.which === 13) {
e.preventDefault();
}
switch (e.which) {
case 13: this.props.handleSelect(); break; // enter
case 37: this.handleDayArrowKey(time.addDays(selectedDate, -1)); break; // left
case 38: this.handleDayArrowKey(time.addDays(selectedDate, -7)); break; // up
case 39: this.handleDayArrowKey(time.addDays(selectedDate, 1)); break; // right
case 40: this.handleDayArrowKey(time.addDays(selectedDate, 7)); break; // down
default: break;
}
}
handleDayArrowKey = (date) => {
this.setState({ viewDate: date });
this.props.onChange(date, false);
}
changeViewMonth = (event) => {
const direction = event.currentTarget.id;
this.setState({
direction,
viewDate: time.addMonths(this.state.viewDate, DIRECTION_STEPS[direction]),
});
};
renderYears() {
return (
<ul
data-react-toolbox="years"
className={this.props.theme.years}
ref={(node) => { this.yearsNode = node; }}
>
{range(1900, 2100).map(year => (
<li
className={year === this.state.viewDate.getFullYear() ? this.props.theme.active : ''}
id={year}
key={year}
onClick={this.handleYearClick}
ref={(node) => {
if (year === this.state.viewDate.getFullYear()) {
this.activeYearNode = node;
}
}}
>
{year}
</li>
))}
</ul>
);
}
renderMonths() {
const { theme } = this.props;
const animation = this.state.direction === 'left' ? 'slideLeft' : 'slideRight';
const animationModule = getAnimationModule(animation, theme);
return (
<div data-react-toolbox="calendar">
<IconButton id="left" className={theme.prev} icon="chevron_left" onClick={this.changeViewMonth} />
<IconButton id="right" className={theme.next} icon="chevron_right" onClick={this.changeViewMonth} />
<CssTransitionGroup
transitionName={animationModule}
transitionEnterTimeout={350}
transitionLeaveTimeout={350}
>
<CalendarMonth
enabledDates={this.props.enabledDates}
disabledDates={this.props.disabledDates}
key={this.state.viewDate.getMonth()}
locale={this.props.locale}
maxDate={this.props.maxDate}
minDate={this.props.minDate}
onDayClick={this.handleDayClick}
selectedDate={this.props.selectedDate}
sundayFirstDayOfWeek={this.props.sundayFirstDayOfWeek}
theme={this.props.theme}
viewDate={this.state.viewDate}
/>
</CssTransitionGroup>
</div>
);
}
render() {
return (
<div className={this.props.theme.calendar}>
{this.props.display === 'months' ? this.renderMonths() : this.renderYears()}
</div>
);
}
}
return Calendar;
};
export default factory;
|
src/parser/shaman/elemental/modules/talents/UnlimitedPower.js | fyruna/WoWAnalyzer | import React from 'react';
import Analyzer from 'parser/core/Analyzer';
import SPELLS from 'common/SPELLS';
import SpellIcon from 'common/SpellIcon';
import { formatDuration, formatPercentage } from 'common/format';
import { STATISTIC_ORDER } from 'interface/others/StatisticBox';
import StatisticBox from 'interface/others/StatisticBox';
import UnlimitedPowerTimesByStacks from 'parser/shaman/elemental/modules/talents/UnlimitedPowerTimesByStacks';
const HASTE_PER_STACK = 0.02;
class UnlimitedPower extends Analyzer {
static dependencies = {
unlimitedPowerTimesByStacks: UnlimitedPowerTimesByStacks,
};
constructor(...args) {
super(...args);
this.active = this.selectedCombatant.hasTalent(SPELLS.UNLIMITED_POWER_TALENT.id);
}
get unlimitedPowerTimesByStack() {
return this.unlimitedPowerTimesByStacks.unlimitedPowerTimesByStacks;
}
get uptime() {
return this.selectedCombatant.getBuffUptime(SPELLS.UNLIMITED_POWER_BUFF.id) / this.owner.fightDuration;
}
get averageHaste() {
return this.unlimitedPowerTimesByStacks.averageUnlimitedPowerStacks*HASTE_PER_STACK;
}
statistic() {
return (
<StatisticBox
icon={<SpellIcon id={SPELLS.UNLIMITED_POWER_TALENT.id} />}
value={`${formatPercentage(this.averageHaste)} %`}
label={`Unlimited Power Average Haste Gain (Uptime ${formatPercentage(this.uptime)}%) `}
>
<table className="table table-condensed">
<thead>
<tr>
<th>Stacks</th>
<th>Time (s)</th>
<th>Time (%)</th>
</tr>
</thead>
<tbody>
{Object.values(this.unlimitedPowerTimesByStack).map((e, i) => (
<tr key={i}>
<th>{i}</th>
<td>{formatDuration(e.reduce((a, b) => a + b, 0) / 1000)}</td>
<td>{formatPercentage(e.reduce((a, b) => a + b, 0) / this.owner.fightDuration)}%</td>
</tr>
))}
</tbody>
</table>
</StatisticBox>
);
}
statisticOrder = STATISTIC_ORDER.CORE(5);
}
export default UnlimitedPower;
|
components/src/Button/Button.js | svef/www | import React from 'react'
import './Button.scss'
const Button = ({ theme, ...props }) => (
<button className={['Button', theme].join(' ')} {...props} />
)
export default Button
|
src/svg-icons/action/update.js | matthewoates/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let ActionUpdate = (props) => (
<SvgIcon {...props}>
<path d="M21 10.12h-6.78l2.74-2.82c-2.73-2.7-7.15-2.8-9.88-.1-2.73 2.71-2.73 7.08 0 9.79 2.73 2.71 7.15 2.71 9.88 0C18.32 15.65 19 14.08 19 12.1h2c0 1.98-.88 4.55-2.64 6.29-3.51 3.48-9.21 3.48-12.72 0-3.5-3.47-3.53-9.11-.02-12.58 3.51-3.47 9.14-3.47 12.65 0L21 3v7.12zM12.5 8v4.25l3.5 2.08-.72 1.21L11 13V8h1.5z"/>
</SvgIcon>
);
ActionUpdate = pure(ActionUpdate);
ActionUpdate.displayName = 'ActionUpdate';
ActionUpdate.muiName = 'SvgIcon';
export default ActionUpdate;
|
examples/src/components/CustomOption.js | benchrise/react-select | import React from 'react';
import Gravatar from 'react-gravatar';
var Option = React.createClass({
propTypes: {
addLabelText: React.PropTypes.string,
className: React.PropTypes.string,
mouseDown: React.PropTypes.func,
mouseEnter: React.PropTypes.func,
mouseLeave: React.PropTypes.func,
option: React.PropTypes.object.isRequired,
renderFunc: React.PropTypes.func
},
handleMouseDown (e) {
this.props.mouseDown(this.props.option, e);
},
handleMouseEnter (e) {
this.props.mouseEnter(this.props.option, e);
},
handleMouseLeave (e) {
this.props.mouseLeave(this.props.option, e);
},
render () {
var obj = this.props.option;
var size = 15;
var gravatarStyle = {
borderRadius: 3,
display: 'inline-block',
marginRight: 10,
position: 'relative',
top: -2,
verticalAlign: 'middle',
};
return (
<div className={this.props.className}
onMouseEnter={this.handleMouseEnter}
onMouseLeave={this.handleMouseLeave}
onMouseDown={this.handleMouseDown}
onClick={this.handleMouseDown}>
<Gravatar email={obj.email} size={size} style={gravatarStyle} />
{obj.value}
</div>
);
}
});
module.exports = Option;
|
src/svg-icons/device/signal-wifi-4-bar.js | pomerantsev/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let DeviceSignalWifi4Bar = (props) => (
<SvgIcon {...props}>
<path d="M12.01 21.49L23.64 7c-.45-.34-4.93-4-11.64-4C5.28 3 .81 6.66.36 7l11.63 14.49.01.01.01-.01z"/>
</SvgIcon>
);
DeviceSignalWifi4Bar = pure(DeviceSignalWifi4Bar);
DeviceSignalWifi4Bar.displayName = 'DeviceSignalWifi4Bar';
DeviceSignalWifi4Bar.muiName = 'SvgIcon';
export default DeviceSignalWifi4Bar;
|
client/src/components/App/index.js | googleinterns/Pictophone | import React from 'react';
import {
BrowserRouter as Router,
Route,
Switch,
} from "react-router-dom";
import LandingPage from '../Home';
import Dashboard from '../Dashboard';
import Game from '../Game';
import SignUpPage from '../SignUp';
import SignInPage from '../SignIn';
import PasswordForgetPage from '../PasswordForget';
import AccountPage from '../Account';
import { withAuthentication, AuthUserContext } from '../Session';
import * as ROUTES from '../../constants/routes';
import './App.css';
const App = () => (
<div className="App">
<Router>
<Switch>
<Route exact path={ROUTES.LANDING}>
<LandingPage />
</Route>
<Route path={ROUTES.SIGN_UP}>
<SignUpPage />
</Route>
<Route exact path={ROUTES.DASHBOARD}>
<AuthUserContext.Consumer>
{authUser =>
<Dashboard authUser={authUser} />
}
</AuthUserContext.Consumer>
</Route>
<Route path={ROUTES.SIGN_IN}>
<SignInPage />
</Route>
<Route path={ROUTES.ACCOUNT}>
<AccountPage />
</Route>
<Route path={ROUTES.PASSWORD_FORGET}>
<PasswordForgetPage />
</Route>
<Route path='/game/:id'>
<AuthUserContext.Consumer>
{authUser =>
<Game authUser={authUser} />
}
</AuthUserContext.Consumer>
</Route>
</Switch>
</Router>
</div>
);
export default withAuthentication(App);
|
src/SelfValidateForm/NumberInputer.js | appier/react-component-template | import React from 'react';
const NumberInputer = React.createClass({
validator: null,
timer: null,
getDefaultProps() {
return {
registerValidator: ()=>{},
};
},
componentDidMount() {
this.validator = this.props.registerValidator('Number cannot be empty');
},
componentWillUnmount() {
this.validator.remove();
},
getInitialState() {
return {
value: '',
validateMsg: 'Number cannot be empty',
};
},
updateValidateMsg(msg){
this.validator(msg)
this.setState({validateMsg: msg||''})
},
validate(value){
//Do some async validate ...
this.updateValidateMsg('Validating Number ...');
clearTimeout(this.timer);
this.timer = setTimeout(()=>{
if(value === ''){
this.updateValidateMsg('Number cannot be empty');
}
else if(isNaN(Number(value))){
this.updateValidateMsg('Not a valid Number');
}
else if(Number(value) < 1000){
this.updateValidateMsg('Number must >= 1000')
}
else{
this.updateValidateMsg(null)
}
}, 200);
},
update(e){
this.setState({value: e.target.value });
this.validate(e.target.value);
},
render(){
const {state} = this;
const {value, validateMsg} = state;
return (
<div className="vertical-input-group">
<div className="label">
Number
</div>
<div className="input-wrap">
<input
className="input"
type="text"
placeholder="try to input invalid number"
value={value}
onChange={this.update}
/>
<div className="text validate-msg">
{validateMsg}
</div>
</div>
</div>
);
}
});
export default NumberInputer;
|
src/components/slick_carousel_item.js | b0ts/react-redux-sweetlightstudios-website | import React from 'react';
const SlickCarouselItem = ({ image, altText }) => (
<div className="slick-grid-item">
<img className="slick-grid-image"
draggable="false"
src={image}
alt={altText} >
</img>
</div>
);
export default SlickCarouselItem;
|
src/routes/index.js | itjope/tipskampen | import React from 'react'
import { Route, IndexRoute, Redirect } from 'react-router'
// NOTE: here we're making use of the `resolve.root` configuration
// option in webpack, which allows us to specify import paths as if
// they were from the root of the ~/src directory. This makes it
// very easy to navigate to files regardless of how deeply nested
// your current file is.
import CoreLayout from 'layouts/CoreLayout/CoreLayout'
import HomeView from 'views/HomeView/HomeView'
import UserView from 'views/UserView/UserView'
import GamesView from 'views/GamesView/GamesView'
import LeaderboardView from 'views/LeaderboardView/LeaderboardView'
import NotFoundView from 'views/NotFoundView/NotFoundView'
import requireAuth from './RequireAuth'
import AdminGamesView from 'views/AdminGamesView/AdminGamesView'
export default (store) => (
<Route path='/' component={CoreLayout}>
<IndexRoute component={HomeView} />
<Route path='/404' component={NotFoundView} />
<Route path='/user' component={requireAuth(UserView)} />
<Route path='/leaderboard' component={LeaderboardView} />
<Route path='/games' component={requireAuth(GamesView)} />
<Route path='/admin'>
<Route path='games' component={requireAuth(AdminGamesView)} />
</Route>
<Redirect from='*' to='/404' />
</Route>
)
|
client/app/components/TagsList/index.js | gustblima/what-can-i-play-with-my-friends | import React from 'react';
import { List } from 'immutable';
import Ul from './Ul';
import Li from './Li';
function TagsList(props) {
const { tags } = props;
if (tags === undefined || tags.length === 0) {
return <h6>No Tags</h6>;
}
const list = tags.map((item, idx) => (
<Li key={idx}>{item}</Li>
));
return (
<div>
<Ul>
{list}
</Ul>
</div>
);
}
TagsList.propTypes = {
tags: React.PropTypes.instanceOf(List),
};
export default TagsList;
|
node_modules/bs-recipes/recipes/webpack.react-hot-loader/app/js/main.js | DuSoleilSLC/DuSoleilSLC.github.io | import React from 'react';
import { render } from 'react-dom';
// It's important to not define HelloWorld component right in this file
// because in that case it will do full page reload on change
import HelloWorld from './HelloWorld.jsx';
render(<HelloWorld />, document.getElementById('react-root'));
|
admin/client/App/screens/List/components/ItemsTable/ItemsTableDragDropZone.js | w01fgang/keystone | /**
* THIS IS ORPHANED AND ISN'T RENDERED AT THE MOMENT
* THIS WAS DONE TO FINISH THE REDUX INTEGRATION, WILL REWRITE SOON
* - @mxstbr
*/
import React from 'react';
import DropZoneTarget from './ItemsTableDragDropZoneTarget';
import classnames from 'classnames';
var ItemsTableDragDropZone = React.createClass({
displayName: 'ItemsTableDragDropZone',
propTypes: {
columns: React.PropTypes.array,
connectDropTarget: React.PropTypes.func,
items: React.PropTypes.object,
list: React.PropTypes.object,
},
renderPageDrops () {
const { items, currentPage, pageSize } = this.props;
const totalPages = Math.ceil(items.count / pageSize);
const style = { display: totalPages > 1 ? null : 'none' };
const pages = [];
for (let i = 0; i < totalPages; i++) {
const page = i + 1;
const pageItems = '' + (page * pageSize - (pageSize - 1)) + ' - ' + (page * pageSize);
const current = (page === currentPage);
const className = classnames('ItemList__dropzone--page', {
'is-active': current,
});
pages.push(
<DropZoneTarget
key={'page_' + page}
page={page}
className={className}
pageItems={pageItems}
pageSize={pageSize}
currentPage={currentPage}
drag={this.props.drag}
dispatch={this.props.dispatch}
/>
);
}
let cols = this.props.columns.length;
if (this.props.list.sortable) cols++;
if (!this.props.list.nodelete) cols++;
return (
<tr style={style}>
<td colSpan={cols} >
<div className="ItemList__dropzone" >
{pages}
<div className="clearfix" />
</div>
</td>
</tr>
);
},
render () {
return this.renderPageDrops();
},
});
module.exports = ItemsTableDragDropZone;
|
docs/src/app/components/pages/components/CircularProgress/ExampleDeterminate.js | hai-cea/material-ui | import React from 'react';
import CircularProgress from 'material-ui/CircularProgress';
export default class CircularProgressExampleDeterminate extends React.Component {
constructor(props) {
super(props);
this.state = {
completed: 0,
};
}
componentDidMount() {
this.timer = setTimeout(() => this.progress(5), 1000);
}
componentWillUnmount() {
clearTimeout(this.timer);
}
progress(completed) {
if (completed > 100) {
this.setState({completed: 100});
} else {
this.setState({completed});
const diff = Math.random() * 10;
this.timer = setTimeout(() => this.progress(completed + diff), 1000);
}
}
render() {
return (
<div>
<CircularProgress
mode="determinate"
value={this.state.completed}
/>
<CircularProgress
mode="determinate"
value={this.state.completed}
size={60}
thickness={7}
/>
<CircularProgress
mode="determinate"
value={this.state.completed}
size={80}
thickness={5}
/>
</div>
);
}
}
|
docs/app/Examples/addons/Confirm/index.js | mohammed88/Semantic-UI-React | import React from 'react'
import Types from './Types'
import Variations from './Variations'
const ConfirmExamples = () => (
<div>
<Types />
<Variations />
</div>
)
export default ConfirmExamples
|
src/svg-icons/action/translate.js | spiermar/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let ActionTranslate = (props) => (
<SvgIcon {...props}>
<path d="M12.87 15.07l-2.54-2.51.03-.03c1.74-1.94 2.98-4.17 3.71-6.53H17V4h-7V2H8v2H1v1.99h11.17C11.5 7.92 10.44 9.75 9 11.35 8.07 10.32 7.3 9.19 6.69 8h-2c.73 1.63 1.73 3.17 2.98 4.56l-5.09 5.02L4 19l5-5 3.11 3.11.76-2.04zM18.5 10h-2L12 22h2l1.12-3h4.75L21 22h2l-4.5-12zm-2.62 7l1.62-4.33L19.12 17h-3.24z"/>
</SvgIcon>
);
ActionTranslate = pure(ActionTranslate);
ActionTranslate.displayName = 'ActionTranslate';
ActionTranslate.muiName = 'SvgIcon';
export default ActionTranslate;
|
node_modules/react-error-overlay/lib/containers/RuntimeError.js | oiricaud/horizon-education | /**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
import React from 'react';
import Header from '../components/Header';
import StackTrace from './StackTrace';
var wrapperStyle = {
display: 'flex',
flexDirection: 'column'
};
function RuntimeError(_ref) {
var errorRecord = _ref.errorRecord,
launchEditorEndpoint = _ref.launchEditorEndpoint;
var error = errorRecord.error,
unhandledRejection = errorRecord.unhandledRejection,
contextSize = errorRecord.contextSize,
stackFrames = errorRecord.stackFrames;
var errorName = unhandledRejection ? 'Unhandled Rejection (' + error.name + ')' : error.name;
// Make header prettier
var message = error.message;
var headerText = message.match(/^\w*:/) || !errorName ? message : errorName + ': ' + message;
headerText = headerText
// TODO: maybe remove this prefix from fbjs?
// It's just scaring people
.replace(/^Invariant Violation:\s*/, '')
// This is not helpful either:
.replace(/^Warning:\s*/, '')
// Break the actionable part to the next line.
// AFAIK React 16+ should already do this.
.replace(' Check the render method', '\n\nCheck the render method').replace(' Check your code at', '\n\nCheck your code at');
return React.createElement(
'div',
{ style: wrapperStyle },
React.createElement(Header, { headerText: headerText }),
React.createElement(StackTrace, {
stackFrames: stackFrames,
errorName: errorName,
contextSize: contextSize,
launchEditorEndpoint: launchEditorEndpoint
})
);
}
export default RuntimeError; |
client/src/components/view/container/Container.js | docker-manager/docker-manager-tool | import React from 'react'
import CopyToClipboard from '../../buttons/CopyToClipboard'
const renderContainerPorts = (containerPorts) => {
let ports = []
Object.keys(containerPorts).map(port => {
let containerPort = containerPorts[port], render = ''
if (containerPort.IP && containerPort.PublicPort) {
render += containerPort.IP + ':' + containerPort.PublicPort + '->'
}
render += containerPort.PrivatePort + '/' + containerPort.Type
ports.push(render)
})
return ports.length > 0 ? ports.sort().join(', ') : '-'
}
const Container = ({container}) => (
<ul className="list-group">
<li className="list-group-item">
<table className="table table-striped table-condensed table-responsive text-left">
<tbody>
<tr>
<th>Name</th>
<td><code>{container.Names[0]}</code></td>
</tr>
<tr>
<th>Id</th>
<td>
<abbr title={container.Id}>{container.Id.substring(0,30)}</abbr>
<CopyToClipboard data={container.Id}/>
</td>
</tr>
<tr>
<th>Project</th>
<td>{container.Labels['com.docker.compose.project'] ? container.Labels['com.docker.compose.project'] : '-'}</td>
</tr>
<tr>
<th>Service</th>
<td>{container.Labels['com.docker.compose.service'] ? container.Labels['com.docker.compose.service'] : '-'}</td>
</tr>
<tr>
<th>Ports</th>
<td>{renderContainerPorts(container.Ports)}</td>
</tr>
<tr>
<th>Command</th>
<td><kbd>{container.Command}</kbd></td>
</tr>
</tbody>
</table>
</li>
</ul>
)
export default Container
|
src/svg-icons/hardware/devices-other.js | skarnecki/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let HardwareDevicesOther = (props) => (
<SvgIcon {...props}>
<path d="M3 6h18V4H3c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h4v-2H3V6zm10 6H9v1.78c-.61.55-1 1.33-1 2.22s.39 1.67 1 2.22V20h4v-1.78c.61-.55 1-1.34 1-2.22s-.39-1.67-1-2.22V12zm-2 5.5c-.83 0-1.5-.67-1.5-1.5s.67-1.5 1.5-1.5 1.5.67 1.5 1.5-.67 1.5-1.5 1.5zM22 8h-6c-.5 0-1 .5-1 1v10c0 .5.5 1 1 1h6c.5 0 1-.5 1-1V9c0-.5-.5-1-1-1zm-1 10h-4v-8h4v8z"/>
</SvgIcon>
);
HardwareDevicesOther = pure(HardwareDevicesOther);
HardwareDevicesOther.displayName = 'HardwareDevicesOther';
export default HardwareDevicesOther;
|
benchmarks/dom-comparison/src/implementations/react-jss/View.js | risetechnologies/fela | /* eslint-disable react/prop-types */
import classnames from 'classnames';
import injectSheet from 'react-jss';
import React from 'react';
class View extends React.Component {
render() {
const { classes, className, ...other } = this.props;
return <div {...other} className={classnames(classes.root, className)} />;
}
}
const styles = {
root: {
alignItems: 'stretch',
borderWidth: 0,
borderStyle: 'solid',
boxSizing: 'border-box',
display: 'flex',
flexBasis: 'auto',
flexDirection: 'column',
flexShrink: 0,
margin: 0,
padding: 0,
position: 'relative',
// fix flexbox bugs
minHeight: 0,
minWidth: 0
}
};
export default injectSheet(styles)(View);
|
fields/types/number/NumberField.js | Yaska/keystone | import React from 'react';
import Field from '../Field';
import { FormInput } from 'elemental';
module.exports = Field.create({
displayName: 'NumberField',
statics: {
type: 'Number',
},
valueChanged (event) {
var newValue = event.target.value;
if (/^-?\d*\.?\d*$/.test(newValue)) {
this.props.onChange({
path: this.props.path,
value: newValue,
});
}
},
renderField () {
return (
<FormInput
name={this.getInputName(this.props.path)}
ref="focusTarget"
value={this.props.value}
onChange={this.valueChanged}
autoComplete="off"
/>
);
},
});
|
packages/react-scripts/fixtures/kitchensink/src/features/syntax/DestructuringAndAwait.js | TryKickoff/create-kickoff-app | /**
* Copyright (c) 2015-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import React, { Component } from 'react';
import PropTypes from 'prop-types';
async function load() {
return {
users: [
{ id: 1, name: '1' },
{ id: 2, name: '2' },
{ id: 3, name: '3' },
{ id: 4, name: '4' },
],
};
}
export default class extends Component {
static propTypes = {
onReady: PropTypes.func.isRequired,
};
constructor(props) {
super(props);
this.state = { users: [] };
}
async componentDidMount() {
const { users } = await load();
this.setState({ users });
}
componentDidUpdate() {
this.props.onReady();
}
render() {
return (
<div id="feature-destructuring-and-await">
{this.state.users.map(user => <div key={user.id}>{user.name}</div>)}
</div>
);
}
}
|
src/core/display/App/Navigation/Vertical/index.js | JulienPradet/pigment-store | import React from 'react'
import {Link} from 'react-router'
import {compose, withState, withHandlers} from 'recompose'
import {MenuTitle, Item, Search} from '../../util/View/SidebarMenu'
import {CategorySubNavigation} from './CategoryNavigation'
export const isMatching = (search, name) => search !== '' && name.match(new RegExp(search, 'i'))
export const featureContainsSearch = (search) => feature => {
return isMatching(search, feature.name)
}
export const componentContainsSearch = (search) => (component) => {
return isMatching(search, component.name) ||
component.features.some(featureContainsSearch(search))
}
export const categoryContainsSearch = (search) => (category) => {
return isMatching(search, category.name) ||
category.components.some(componentContainsSearch(search)) ||
category.categories.some(categoryContainsSearch(search))
}
const Navigation = ({search, onSearchChange, indexCategory, isActive, prefix = ''}) => <div>
<MenuTitle><Link to='/'>Pigment Store</Link></MenuTitle>
<Item>
<Search search={search} onChange={onSearchChange} />
</Item>
<Item>
<CategorySubNavigation category={indexCategory} pathname={prefix} search={search} />
</Item>
</div>
const SmartNavigation = compose(
withState('search', 'setSearch', ''),
withHandlers({
onSearchChange: ({setSearch}) => (search) => setSearch(search)
})
)(Navigation)
SmartNavigation.displayName = 'Navigation'
export default SmartNavigation
|
src/entypo/CreativeCommons.js | cox-auto-kc/react-entypo | import React from 'react';
import EntypoIcon from '../EntypoIcon';
const iconClass = 'entypo-svgicon entypo--CreativeCommons';
let EntypoCreativeCommons = (props) => (
<EntypoIcon propClass={iconClass} {...props}>
<path d="M8.8,10.8l1.1,0.6c-0.2,0.4-0.6,0.8-1,1.1c-0.4,0.3-0.9,0.4-1.4,0.4c-0.8,0-1.5-0.2-2-0.8C5,11.6,4.8,10.9,4.8,10c0-0.9,0.3-1.6,0.8-2.1C6,7.4,6.7,7.1,7.5,7.1c1.1,0,2,0.4,2.4,1.3L8.7,9.1C8.5,8.8,8.4,8.6,8.2,8.5S7.8,8.4,7.7,8.4c-0.8,0-1.2,0.5-1.2,1.6c0,0.5,0.1,0.9,0.3,1.2c0.2,0.3,0.5,0.4,0.9,0.4C8.2,11.6,8.6,11.4,8.8,10.8z M13,11.6c-0.4,0-0.7-0.1-0.9-0.4c-0.2-0.3-0.3-0.7-0.3-1.2c0-1.1,0.4-1.6,1.2-1.6c0.2,0,0.4,0.1,0.5,0.2c0.2,0.1,0.4,0.3,0.5,0.6l1.2-0.6c-0.5-0.9-1.3-1.3-2.4-1.3c-0.8,0-1.4,0.3-1.9,0.8c-0.5,0.5-0.8,1.2-0.8,2.1c0,0.9,0.2,1.6,0.7,2.1c0.5,0.5,1.2,0.8,2,0.8c0.5,0,1-0.1,1.4-0.4c0.4-0.3,0.8-0.6,1-1.1l-1.2-0.6C13.9,11.4,13.5,11.6,13,11.6z M19.6,10c0,2.7-0.9,4.9-2.7,6.7c-1.9,1.9-4.2,2.9-6.9,2.9c-2.6,0-4.9-0.9-6.8-2.8c-1.9-1.9-2.8-4.1-2.8-6.8c0-2.6,0.9-4.9,2.8-6.8C5.1,1.3,7.3,0.4,10,0.4c2.7,0,5,0.9,6.8,2.8C18.7,5,19.6,7.3,19.6,10z M17.9,10c0-2.2-0.8-4-2.3-5.6C14,2.9,12.2,2.1,10,2.1c-2.2,0-4,0.8-5.5,2.3C2.9,6,2.1,7.9,2.1,10c0,2.1,0.8,4,2.3,5.5c1.6,1.6,3.4,2.3,5.6,2.3c2.1,0,4-0.8,5.6-2.4C17.1,14,17.9,12.2,17.9,10z"/>
</EntypoIcon>
);
export default EntypoCreativeCommons;
|
app/javascript/mastodon/components/status.js | SerCom-KC/mastodon | import React from 'react';
import ImmutablePropTypes from 'react-immutable-proptypes';
import PropTypes from 'prop-types';
import Avatar from './avatar';
import AvatarOverlay from './avatar_overlay';
import RelativeTimestamp from './relative_timestamp';
import DisplayName from './display_name';
import StatusContent from './status_content';
import StatusActionBar from './status_action_bar';
import AttachmentList from './attachment_list';
import { injectIntl, FormattedMessage } from 'react-intl';
import ImmutablePureComponent from 'react-immutable-pure-component';
import { MediaGallery, Video } from '../features/ui/util/async-components';
import { HotKeys } from 'react-hotkeys';
import classNames from 'classnames';
// We use the component (and not the container) since we do not want
// to use the progress bar to show download progress
import Bundle from '../features/ui/components/bundle';
export const textForScreenReader = (intl, status, rebloggedByText = false) => {
const displayName = status.getIn(['account', 'display_name']);
const values = [
displayName.length === 0 ? status.getIn(['account', 'acct']).split('@')[0] : displayName,
status.get('spoiler_text') && status.get('hidden') ? status.get('spoiler_text') : status.get('search_index').slice(status.get('spoiler_text').length),
intl.formatDate(status.get('created_at'), { hour: '2-digit', minute: '2-digit', month: 'short', day: 'numeric' }),
status.getIn(['account', 'acct']),
];
if (rebloggedByText) {
values.push(rebloggedByText);
}
return values.join(', ');
};
export default @injectIntl
class Status extends ImmutablePureComponent {
static contextTypes = {
router: PropTypes.object,
};
static propTypes = {
status: ImmutablePropTypes.map,
account: ImmutablePropTypes.map,
onReply: PropTypes.func,
onFavourite: PropTypes.func,
onReblog: PropTypes.func,
onDelete: PropTypes.func,
onDirect: PropTypes.func,
onMention: PropTypes.func,
onPin: PropTypes.func,
onOpenMedia: PropTypes.func,
onOpenVideo: PropTypes.func,
onBlock: PropTypes.func,
onEmbed: PropTypes.func,
onHeightChange: PropTypes.func,
onToggleHidden: PropTypes.func,
muted: PropTypes.bool,
hidden: PropTypes.bool,
onMoveUp: PropTypes.func,
onMoveDown: PropTypes.func,
};
// Avoid checking props that are functions (and whose equality will always
// evaluate to false. See react-immutable-pure-component for usage.
updateOnProps = [
'status',
'account',
'muted',
'hidden',
]
handleClick = () => {
if (!this.context.router) {
return;
}
const { status } = this.props;
this.context.router.history.push(`/statuses/${status.getIn(['reblog', 'id'], status.get('id'))}`);
}
handleAccountClick = (e) => {
if (this.context.router && e.button === 0 && !(e.ctrlKey || e.metaKey)) {
const id = e.currentTarget.getAttribute('data-id');
e.preventDefault();
this.context.router.history.push(`/accounts/${id}`);
}
}
handleExpandedToggle = () => {
this.props.onToggleHidden(this._properStatus());
};
renderLoadingMediaGallery () {
return <div className='media_gallery' style={{ height: '110px' }} />;
}
renderLoadingVideoPlayer () {
return <div className='media-spoiler-video' style={{ height: '110px' }} />;
}
handleOpenVideo = (media, startTime) => {
this.props.onOpenVideo(media, startTime);
}
handleHotkeyReply = e => {
e.preventDefault();
this.props.onReply(this._properStatus(), this.context.router.history);
}
handleHotkeyFavourite = () => {
this.props.onFavourite(this._properStatus());
}
handleHotkeyBoost = e => {
this.props.onReblog(this._properStatus(), e);
}
handleHotkeyMention = e => {
e.preventDefault();
this.props.onMention(this._properStatus().get('account'), this.context.router.history);
}
handleHotkeyOpen = () => {
this.context.router.history.push(`/statuses/${this._properStatus().get('id')}`);
}
handleHotkeyOpenProfile = () => {
this.context.router.history.push(`/accounts/${this._properStatus().getIn(['account', 'id'])}`);
}
handleHotkeyMoveUp = e => {
this.props.onMoveUp(this.props.status.get('id'), e.target.getAttribute('data-featured'));
}
handleHotkeyMoveDown = e => {
this.props.onMoveDown(this.props.status.get('id'), e.target.getAttribute('data-featured'));
}
handleHotkeyToggleHidden = () => {
this.props.onToggleHidden(this._properStatus());
}
_properStatus () {
const { status } = this.props;
if (status.get('reblog', null) !== null && typeof status.get('reblog') === 'object') {
return status.get('reblog');
} else {
return status;
}
}
render () {
let media = null;
let statusAvatar, prepend, rebloggedByText;
const { intl, hidden, featured } = this.props;
let { status, account, ...other } = this.props;
if (status === null) {
return null;
}
if (hidden) {
return (
<div>
{status.getIn(['account', 'display_name']) || status.getIn(['account', 'username'])}
{status.get('content')}
</div>
);
}
if (status.get('filtered') || status.getIn(['reblog', 'filtered'])) {
const minHandlers = this.props.muted ? {} : {
moveUp: this.handleHotkeyMoveUp,
moveDown: this.handleHotkeyMoveDown,
};
return (
<HotKeys handlers={minHandlers}>
<div className='status__wrapper status__wrapper--filtered focusable' tabIndex='0'>
<FormattedMessage id='status.filtered' defaultMessage='Filtered' />
</div>
</HotKeys>
);
}
if (featured) {
prepend = (
<div className='status__prepend'>
<div className='status__prepend-icon-wrapper'><i className='fa fa-fw fa-thumb-tack status__prepend-icon' /></div>
<FormattedMessage id='status.pinned' defaultMessage='Pinned toot' />
</div>
);
} else if (status.get('reblog', null) !== null && typeof status.get('reblog') === 'object') {
const display_name_html = { __html: status.getIn(['account', 'display_name_html']) };
prepend = (
<div className='status__prepend'>
<div className='status__prepend-icon-wrapper'><i className='fa fa-fw fa-retweet status__prepend-icon' /></div>
<FormattedMessage id='status.reblogged_by' defaultMessage='{name} boosted' values={{ name: <a onClick={this.handleAccountClick} data-id={status.getIn(['account', 'id'])} href={status.getIn(['account', 'url'])} className='status__display-name muted'><bdi><strong dangerouslySetInnerHTML={display_name_html} /></bdi></a> }} />
</div>
);
rebloggedByText = intl.formatMessage({ id: 'status.reblogged_by', defaultMessage: '{name} boosted' }, { name: status.getIn(['account', 'acct']) });
account = status.get('account');
status = status.get('reblog');
}
if (status.get('media_attachments').size > 0) {
if (this.props.muted || status.get('media_attachments').some(item => item.get('type') === 'unknown')) {
media = (
<AttachmentList
compact
media={status.get('media_attachments')}
/>
);
} else if (status.getIn(['media_attachments', 0, 'type']) === 'video') {
const video = status.getIn(['media_attachments', 0]);
media = (
<Bundle fetchComponent={Video} loading={this.renderLoadingVideoPlayer} >
{Component => (
<Component
preview={video.get('preview_url')}
src={video.get('url')}
alt={video.get('description')}
width={239}
height={110}
inline
sensitive={status.get('sensitive')}
onOpenVideo={this.handleOpenVideo}
/>
)}
</Bundle>
);
} else {
media = (
<Bundle fetchComponent={MediaGallery} loading={this.renderLoadingMediaGallery}>
{Component => <Component media={status.get('media_attachments')} sensitive={status.get('sensitive')} height={110} onOpenMedia={this.props.onOpenMedia} />}
</Bundle>
);
}
}
if (account === undefined || account === null) {
statusAvatar = <Avatar account={status.get('account')} size={48} />;
}else{
statusAvatar = <AvatarOverlay account={status.get('account')} friend={account} />;
}
const handlers = this.props.muted ? {} : {
reply: this.handleHotkeyReply,
favourite: this.handleHotkeyFavourite,
boost: this.handleHotkeyBoost,
mention: this.handleHotkeyMention,
open: this.handleHotkeyOpen,
openProfile: this.handleHotkeyOpenProfile,
moveUp: this.handleHotkeyMoveUp,
moveDown: this.handleHotkeyMoveDown,
toggleHidden: this.handleHotkeyToggleHidden,
};
return (
<HotKeys handlers={handlers}>
<div className={classNames('status__wrapper', `status__wrapper-${status.get('visibility')}`, { 'status__wrapper-reply': !!status.get('in_reply_to_id'), focusable: !this.props.muted })} tabIndex={this.props.muted ? null : 0} data-featured={featured ? 'true' : null} aria-label={textForScreenReader(intl, status, rebloggedByText, !status.get('hidden'))}>
{prepend}
<div className={classNames('status', `status-${status.get('visibility')}`, { 'status-reply': !!status.get('in_reply_to_id'), muted: this.props.muted })} data-id={status.get('id')}>
<div className='status__info'>
<a href={status.get('url')} className='status__relative-time' target='_blank' rel='noopener'><RelativeTimestamp timestamp={status.get('created_at')} /></a>
<a onClick={this.handleAccountClick} target='_blank' data-id={status.getIn(['account', 'id'])} href={status.getIn(['account', 'url'])} title={status.getIn(['account', 'acct'])} className='status__display-name'>
<div className='status__avatar'>
{statusAvatar}
</div>
<DisplayName account={status.get('account')} />
</a>
</div>
<StatusContent status={status} onClick={this.handleClick} expanded={!status.get('hidden')} onExpandedToggle={this.handleExpandedToggle} />
{media}
<StatusActionBar status={status} account={account} {...other} />
</div>
</div>
</HotKeys>
);
}
}
|
src/components/itemsManager/ItemTransferModal.js | MrRandol/littleLight | /******************
REACT IMPORTS
******************/
import React from 'react';
import { Modal, View, ScrollView, Text, Image, Button, Dimensions, TouchableOpacity, TouchableWithoutFeedback } from 'react-native';
/*****************
CUSTOM IMPORTS
******************/
import T from 'i18n-react';
var styles = require('../../styles/itemsManager/ItemTransferModal');
import LoadingImage from '../common/LoadingImage'
import * as BUNGIE from '../../utils/bungie/static';
import * as transfer from '../../utils/bungie/transfer';
class ItemTransferModal extends React.Component {
constructor(props) {
super(props);
}
closeModal() {
console.log("close !");
this.props.closeModalCallback.call(this, false);
}
transferItem(sourceGuardian, destinationGuardian) {
console.log("Source Guardian : " + sourceGuardian);
console.log("Dest Guardian : " + destinationGuardian);
this.props.transferItemCallback.call(this, this.props.item, this.props.itemIsInVault, destinationGuardian, sourceGuardian);
this.closeModal();
}
render() {
var source = this.props.item && this.props.item.displayProperties.icon ? BUNGIE.HOST+this.props.item.displayProperties.icon : BUNGIE.FALLBACK_ICON;
var {height, width} = Dimensions.get('window');
var title = this.props.itemIsInVault ? "Transfer to current guardian" : "Transfer to vault";
var guardians = this.props.guardians;
var currentGuardianId = this.props.currentGuardianId;
var itemAssociatedGuardian = this.props.itemAssociatedGuardian;
var self = this;
var tierColor = this.props.item && this.props.item.inventory ? BUNGIE.TIER_COLORS[this.props.item.inventory.tierType] : BUNGIE.FALLBACK_TIER_COLORS;
return (
<Modal
animationType="slide"
transparent={true}
visible={this.props.visible}
onRequestClose={() => this.closeModal()}
>
<TouchableOpacity onPressOut={() => this.closeModal()} style={[{width: width, height: height, backgroundColor: 'rgba(0, 0, 0, 0.8)'}]}>
<View
style={styles.itemTransferModal}
>
<TouchableWithoutFeedback style={styles.itemTransferModal}>
{this.props.item && (
<View style={[styles.content, {width: width, height: height/1.6}]} >
<View style={[styles.titleContainer, { backgroundColor: tierColor }]} >
<Text style={styles.title} > { this.props.item.displayProperties.name } </Text>
<Text style={styles.description} > { this.props.item.displayProperties.description } </Text>
</View>
<View style={styles.itemContainer} >
<View style={styles.itemContainerLeft} >
<LoadingImage
resizeMode='cover'
style={styles.itemIcon}
source={{uri: source}}
/>
<Text style={styles.iconDescription} > { this.props.item.itemTypeAndTierDisplayName }</Text>
</View>
<View style={styles.itemContainerRight} >
{ this.props.item.primaryStat &&
<Text style={styles.itemStat} > { "Power level : " + this.props.item.primaryStat.value }</Text>
}
{ this.props.item.damageTypeHashes &&
<Text style={styles.itemStat} > { "Damage type : " + BUNGIE.DAMAGE_TYPES[this.props.item.damageTypes[0]] }</Text>
}
</View>
</View>
<View style={styles.buttonsContainer} >
{
Object.keys(guardians).map(function(guardianId) {
if (guardianId !== itemAssociatedGuardian) {
return (
<TouchableOpacity onPress={() => self.transferItem(itemAssociatedGuardian, guardianId)} key={"touchStoreTo-"+guardianId} >
<LoadingImage
style={styles.transferButton}
key={"storeTo-"+guardianId}
source={{uri: BUNGIE.HOST+guardians[guardianId].emblemPath}} >
<Text style={styles.transferButtonText}> STORE </Text>
</LoadingImage>
</TouchableOpacity>
)
}
})
}
{
!this.props.itemIsInVault &&
<TouchableOpacity activeOpacity={1} onPress={() => self.transferItem(null, itemAssociatedGuardian)} >
<LoadingImage
style={styles.transferButton}
source={{uri : BUNGIE.VAULT_ICON}} >
<Text style={styles.transferButtonText}> STORE </Text>
</LoadingImage>
</TouchableOpacity>
}
</View>
<Button style={styles.cancelButton} color='#242424' onPress={ () => {this.closeModal()} } title="CANCEL" />
</View>
)}
</TouchableWithoutFeedback>
</View>
</TouchableOpacity>
</Modal>
);
}
}
export default ItemTransferModal; |
src/js/components/GroupListItem.js | grommet/grommet-people-finder | // (C) Copyright 2014-2016 Hewlett Packard Enterprise Development LP
import React from 'react';
import PropTypes from 'prop-types';
import ListItem from 'grommet/components/ListItem';
import config from '../config';
const GroupListItem = (props) => {
const { item, first } = props;
return (
<ListItem
justify='between'
pad='medium'
align={props.direction === 'column' ? 'start' : 'center'}
direction={props.direction}
onClick={props.onClick}
separator={first ? 'horizontal' : 'bottom'}
>
<strong>{item[config.scopes.groups.attributes.id]}</strong>
<span className='secondary'>
{item[config.scopes.groups.attributes.description]}
</span>
</ListItem>
);
};
GroupListItem.defaultProps = {
direction: undefined,
first: undefined,
item: undefined,
onClick: undefined,
};
GroupListItem.propTypes = {
direction: PropTypes.oneOf(['column', 'row']),
first: PropTypes.bool,
item: PropTypes.object,
onClick: PropTypes.func,
};
export default GroupListItem;
|
ReactNative/node_modules/react-navigation/src/views/ResourceSavingSceneView.js | tahashahid/cloud-computing-2017 | import React from 'react';
import { Platform, StyleSheet, View } from 'react-native';
import PropTypes from 'prop-types';
import SceneView from './SceneView';
const FAR_FAR_AWAY = 3000; // this should be big enough to move the whole view out of its container
export default class ResourceSavingSceneView extends React.PureComponent {
constructor(props) {
super();
const key = props.childNavigation.state.key;
const focusedIndex = props.navigation.state.index;
const focusedKey = props.navigation.state.routes[focusedIndex].key;
const isFocused = key === focusedKey;
this.state = {
awake: props.lazy ? isFocused : true,
visible: isFocused,
};
}
componentWillMount() {
this._actionListener = this.props.navigation.addListener(
'action',
this._onAction
);
}
componentWillUnmount() {
this._actionListener.remove();
}
render() {
const { awake, visible } = this.state;
const {
childNavigation,
navigation,
removeClippedSubviews,
lazy,
...rest
} = this.props;
return (
<View
style={styles.container}
collapsable={false}
removeClippedSubviews={
Platform.OS === 'android'
? removeClippedSubviews
: !visible && removeClippedSubviews
}
>
<View
style={
this._mustAlwaysBeVisible() || visible
? styles.innerAttached
: styles.innerDetached
}
>
{awake ? <SceneView {...rest} navigation={childNavigation} /> : null}
</View>
</View>
);
}
_mustAlwaysBeVisible = () => {
return this.props.animationEnabled || this.props.swipeEnabled;
};
_onAction = payload => {
// We do not care about transition complete events, they won't actually change the state
if (
payload.action.type == 'Navigation/COMPLETE_TRANSITION' ||
!payload.state
) {
return;
}
const { routes, index } = payload.state;
const key = this.props.childNavigation.state.key;
if (routes[index].key === key) {
if (!this.state.visible) {
let nextState = { visible: true };
if (!this.state.awake) {
nextState.awake = true;
}
this.setState(nextState);
}
} else {
if (this.state.visible) {
this.setState({ visible: false });
}
}
};
}
const styles = StyleSheet.create({
container: {
flex: 1,
overflow: 'hidden',
},
innerAttached: {
flex: 1,
},
innerDetached: {
flex: 1,
top: FAR_FAR_AWAY,
},
});
|
react-backend/client/src/components/FeedbackView/index.js | JonasJan89/JSChallenge | import React, { Component } from 'react';
import StaticFeedbackView from '../StaticFeedbackView';
import DynamicFeedbackView from '../DynamicFeedbackView';
import axios from 'axios';
import SolutionUpload from "../SolutionUpload/index";
export default class FeedbackView extends Component {
constructor(props) {
super(props);
this.state = {
feedback: null,
solutionID: props.match.params.id,
};
}
componentWillMount() {
this.getFeedback();
}
getFeedback = () => {
axios.get(`/assessor/${this.state.solutionID}`)
.then(res => {
this.setState({
feedback: {
staticFeedback: res.data.staticAutomaticFeedback,
dynamicFeedback: res.data.dynamicAutomaticFeedback
},
});
})
.catch(err => alert(err));
};
componentWillReceiveProps(nextProps) {
if(nextProps.feedback) {
this.setState({ feedback: nextProps.feedback });
} else {
this.getFeedback();
}
}
render() {
return(
<div className="feedback-view">
<div className="container">
<div className="feedback-view__wrapper white-box">
{this.state.feedback && this.state.feedback.staticFeedback &&
<StaticFeedbackView staticFeedback={this.state.feedback.staticFeedback}/>
}
{this.state.feedback && this.state.feedback.dynamicFeedback && this.state.feedback.staticFeedback.length <= 0 &&
<DynamicFeedbackView dynamicFeedback={this.state.feedback.dynamicFeedback}/>
}
</div>
</div>
{this.state.solutionID &&
<SolutionUpload onFeedbackView={true} solutionID={this.state.solutionID}/>
}
</div>
);
}
};
|
webApp/web_client/components/Loading.js | deliquescentlicorice/silent-disco | import React from 'react';
// MATERIAL DESIGN
import CircularProgress from '../../node_modules/material-ui/lib/circular-progress';
class Loading extends React.Component {
render() {
return (
<div style={styles.loader}>
<CircularProgress />
</div>
)
}
}
var styles = {
loader: {
'position': 'fixed',
'top': '50%',
'left': '50%',
'transform': 'translate(-50%, -50%)',
'border': '1px solid grey',
'borderRadius': '15px',
'padding': '10px'
}
}
export default Loading;
|
client/src/views/Home/components/picture-nav/index.js | DillGromble/TNABT-org | import React from 'react'
import { Link } from 'react-router'
import './picture-nav.css'
import about from '../../../../img/about-us.jpg'
import awards from '../../../../img/awards.jpg'
import membership from '../../../../img/membership.jpg'
import resources from '../../../../img/resources.jpg'
const PictureNav = () => (
<section className="section-picture-nav">
<ul className="picture-nav clearfix">
<Link to="/about">
<li>
<figure className="link-photo">
<h3>About Us</h3>
<img src={ about } alt="About Us" />
</figure>
</li>
</Link>
<Link to="/membership">
<li>
<figure className="link-photo">
<h3>Membership</h3>
<img src={ membership } alt="Membership" />
</figure>
</li>
</Link>
<Link to="/resources">
<li>
<figure className="link-photo">
<h3>Resources</h3>
<img src={ resources } alt="Resources" />
</figure>
</li>
</Link>
<Link to="/awards-service">
<li>
<figure className="link-photo">
<h3>Awards <br /> and <br /> Service</h3>
<img src={ awards } alt="Awards and Service" />
</figure>
</li>
</Link>
</ul>
</section>
)
export default PictureNav
|
UI/ToolTip/BottomLeft.js | Datasilk/Dedicate | import React from 'react';
import {Animated, Easing} from 'react-native';
import Text from 'text/Text';
import {Svg, Path} from 'react-native-svg';
import AppStyles from 'dedicate/AppStyles';
export default class ToolTipBottomLeft extends React.Component {
constructor(props){
super(props);
this.state = {
pos: new Animated.Value(0)
}
}
componentDidMount(){
setTimeout(() => {
Animated.timing(
this.state.pos,
{
toValue:1,
duration:500,
easing:Easing.out(Easing.quad)
}
).start();
}, 1000);
}
render(){
const color = this.props.color || AppStyles.tooltipColor;
const textColor = this.props.textColor || AppStyles.tooltipTextColor;
const bg = this.props.background || AppStyles.backgroundColor;
const y = this.state.pos.interpolate({
inputRange:[0, 1],
outputRange:[-50, 0]
});
return (
<Animated.View style={{position:'relative', opacity:this.state.pos, top:y}}>
<Svg viewBox="0 0 350 85" width={350 * AppStyles.vw} height={85 * AppStyles.vw}>
<Path fill={bg} d="M347.5 68.5v-66H2.5v66h12.8l10.25 12.6 9.2-12.6H347.5z"/>
<Path fill={color} d="M350 6q0-6-6-6H5.95q-.65 0-1.2.05Q-.05.65-.05 6v59q0 5.25 4.55 5.9.7.1 1.45.1h9.75l9.65 13.5L35 71h309q6 0 6-6V6m-6-2q2 0 2 2v59q0 2-2 2H32.35l-7 10.5-7.9-10.5H5.95q-.75 0-1.2-.3-.8-.45-.8-1.7V6q0-1.25.8-1.75Q5.2 4 5.95 4H344z"/>
</Svg>
<Text style={{position:'absolute', paddingTop:AppStyles.paddingMedium, paddingLeft:AppStyles.paddingLarge, width:335 * AppStyles.vw, color:textColor, fontSize:AppStyles.fontSize, zIndex:1}}>{this.props.text}</Text>
</Animated.View>
);
}
} |
src/components/StockTable/StockTable.js | pvijeh/stock-tracking-app-reactjs | /**
* React Starter Kit (https://www.reactstarterkit.com/)
*
* Copyright © 2014-2016 Kriasoft, LLC. All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE.txt file in the root directory of this source tree.
*/
import React, { Component } from 'react';
import {Table, Column, Cell } from '../fixed-data-table';
import withStyles from 'isomorphic-style-loader/lib/withStyles';
import s from './StockTable.scss';
const DateCell = ({rowIndex, data, col, ...props}) => (
<Cell {...props}>
{data.getObjectAt(rowIndex)[col].toLocaleString()}
</Cell>
);
const TextCell = ({rowIndex, data, col, ...props}) => (
<Cell {...props}>
{data.getObjectAt(rowIndex)[col]}
</Cell>
);
class StockTable extends Component {
render() {
let dataList = this.props.content;
return (
<Table
rowHeight={50}
headerHeight={50}
rowsCount={dataList.getSize()}
width={1000}
height={500}
{...this.props}>
<Column
header={<Cell>Product Name</Cell>}
cell={<TextCell data={dataList} col="name" />}
fixed={true}
width={200}
/>
<Column
header={<Cell>Product Description</Cell>}
cell={<TextCell data={dataList} col="description" />}
fixed={true}
width={400}
/>
<Column
header={<Cell>Price</Cell>}
cell={<TextCell data={dataList} col="price" />}
width={100}
/>
<Column
header={<Cell>Taxable? </Cell>}
cell={<DateCell data={dataList} col="taxable" />}
width={100}
/>
<Column
header={<Cell>Date Available</Cell>}
cell={<DateCell data={dataList} col="date" />}
width={200}
/>
</Table>
);
}
}
export default withStyles(StockTable, s);
|
app/index.js | emilyaviva/code-501-react-boilerplate | import React from 'react'
import { render } from 'react-dom'
if (process.env.NODE_ENV !== 'production') {
React.Perf = require('react-addons-perf')
}
const page = (
<div>
<h1>Welcome to Code 501</h1>
<h2>Building Web Apps with React + Redux</h2>
</div>
)
render(page, document.getElementById('app'))
|
actor-apps/app-web/src/app/components/sidebar/HeaderSection.react.js | chengjunjian/actor-platform | import React from 'react';
import mixpanel from 'utils/Mixpanel';
import MyProfileActions from 'actions/MyProfileActions';
import LoginActionCreators from 'actions/LoginActionCreators';
import AvatarItem from 'components/common/AvatarItem.react';
import MyProfileModal from 'components/modals/MyProfile.react';
import ActorClient from 'utils/ActorClient';
import classNames from 'classnames';
var getStateFromStores = () => {
return {dialogInfo: null};
};
class HeaderSection extends React.Component {
componentWillMount() {
ActorClient.bindUser(ActorClient.getUid(), this.setUser);
}
constructor() {
super();
this.setUser = this.setUser.bind(this);
this.toggleHeaderMenu = this.toggleHeaderMenu.bind(this);
this.openMyProfile = this.openMyProfile.bind(this);
this.setLogout = this.setLogout.bind(this);
this.state = getStateFromStores();
}
setUser(user) {
this.setState({user: user});
}
toggleHeaderMenu() {
mixpanel.track('Open sidebar menu');
this.setState({isOpened: !this.state.isOpened});
}
setLogout() {
LoginActionCreators.setLoggedOut();
}
render() {
var user = this.state.user;
if (user) {
var headerClass = classNames('sidebar__header', 'sidebar__header--clickable', {
'sidebar__header--opened': this.state.isOpened
});
return (
<header className={headerClass}>
<div className="sidebar__header__user row" onClick={this.toggleHeaderMenu}>
<AvatarItem image={user.avatar}
placeholder={user.placeholder}
size="small"
title={user.name} />
<span className="sidebar__header__user__name col-xs">{user.name}</span>
<span className="sidebar__header__user__expand">
<i className="material-icons">keyboard_arrow_down</i>
</span>
</div>
<ul className="sidebar__header__menu">
<li className="sidebar__header__menu__item" onClick={this.openMyProfile}>
<i className="material-icons">person</i>
<span>Profile</span>
</li>
{/*
<li className="sidebar__header__menu__item" onClick={this.openCreateGroup}>
<i className="material-icons">group_add</i>
<span>Create group</span>
</li>
*/}
<li className="sidebar__header__menu__item hide">
<i className="material-icons">cached</i>
<span>Integrations</span>
</li>
<li className="sidebar__header__menu__item hide">
<i className="material-icons">settings</i>
<span>Settings</span>
</li>
<li className="sidebar__header__menu__item hide">
<i className="material-icons">help</i>
<span>Help</span>
</li>
<li className="sidebar__header__menu__item" onClick={this.setLogout}>
<i className="material-icons">power_settings_new</i>
<span>Log out</span>
</li>
</ul>
<MyProfileModal/>
</header>
);
} else {
return null;
}
}
openMyProfile() {
MyProfileActions.modalOpen();
mixpanel.track('My profile open');
this.setState({isOpened: false});
}
}
export default HeaderSection;
|
packages/reactor-kitchensink/src/examples/Picker/Picker.js | sencha/extjs-reactor | import React, { Component } from 'react';
import { Container, Picker, Button } from '@extjs/ext-react';
export default class PickerExample extends Component {
state = { displayed: false };
showPicker = () => this.setState({ displayed: true });
onHidden = () => this.setState({ displayed: false });
render() {
const { displayed } = this.state;
return (
<Container>
<Button ui="action" handler={this.showPicker} text="Show Picker"/>
<Picker
displayed={displayed}
value={[100]}
onHide={this.onHidden}
slots={[
{
name: 'limit_speed',
title: 'Speed',
data: [
{text: '50 KB/s', value: 50},
{text: '100 KB/s', value: 100},
{text: '200 KB/s', value: 200},
{text: '300 KB/s', value: 300}
]
}
]}
/>
</Container>
)
}
} |
node_modules/react-native-scripts/template/App.js | jasonlarue/react-native-flashcards | import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
export default class App extends React.Component {
render() {
return (
<View style={styles.container}>
<Text>Open up App.js to start working on your app!</Text>
<Text>Changes you make will automatically reload.</Text>
<Text>Shake your phone to open the developer menu.</Text>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});
|
src/svg-icons/image/assistant-photo.js | manchesergit/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let ImageAssistantPhoto = (props) => (
<SvgIcon {...props}>
<path d="M14.4 6L14 4H5v17h2v-7h5.6l.4 2h7V6z"/>
</SvgIcon>
);
ImageAssistantPhoto = pure(ImageAssistantPhoto);
ImageAssistantPhoto.displayName = 'ImageAssistantPhoto';
ImageAssistantPhoto.muiName = 'SvgIcon';
export default ImageAssistantPhoto;
|
hackupc/node_modules/react-router/es/IndexLink.js | IKholopov/HackUPC2017 | var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
import React from 'react';
import Link from './Link';
/**
* An <IndexLink> is used to link to an <IndexRoute>.
*/
var IndexLink = React.createClass({
displayName: 'IndexLink',
render: function render() {
return React.createElement(Link, _extends({}, this.props, { onlyActiveOnIndex: true }));
}
});
export default IndexLink; |
fields/types/cloudinaryimages/CloudinaryImagesColumn.js | lastjune/keystone | import React from 'react';
import CloudinaryImageSummary from '../../components/columns/CloudinaryImageSummary';
import ItemsTableCell from '../../../admin/src/components/ItemsTableCell';
import ItemsTableValue from '../../../admin/src/components/ItemsTableValue';
const moreIndicatorStyle = {
color: '#888',
fontSize: '.8rem',
};
var CloudinaryImagesColumn = React.createClass({
displayName: 'CloudinaryImagesColumn',
propTypes: {
col: React.PropTypes.object,
data: React.PropTypes.object,
},
renderMany (value) {
if (!value || !value.length) return;
let refList = this.props.col.field.refList;
let items = [];
for (let i = 0; i < 3; i++) {
if (!value[i]) break;
items.push(<CloudinaryImageSummary key={'image' + i} image={value[i]} />);
}
if (value.length > 3) {
items.push(<span key="more" style={moreIndicatorStyle}>[...{value.length - 3} more]</span>);
}
return items;
},
renderValue (value) {
if (!value || !Object.keys(value).length) return;
return <CloudinaryImageSummary image={value} />;
},
render () {
let value = this.props.data.fields[this.props.col.path];
let many = value.length > 1;
return (
<ItemsTableCell>
<ItemsTableValue field={this.props.col.type}>
{many ? this.renderMany(value) : this.renderValue(value[0])}
</ItemsTableValue>
</ItemsTableCell>
);
}
});
module.exports = CloudinaryImagesColumn;
|
react-vr/v2-tree/components/Tree.js | nikgraf/webvr-experiments | import React from 'react';
import {asset, Model, View} from 'react-vr';
export default ({style}) => (
<View style={style}>
<Model
source={{obj: asset('tree-trunk.obj'), mtl: asset('tree-trunk.mtl')}}
lit
style={{
transform: [{scale: [0.6, 1, 0.6]}],
}}
/>
<Model
source={{obj: asset('tree-crown.obj'), mtl: asset('tree-crown.mtl')}}
lit
style={{
transform: [{translate: [0, 2.5, 0]}],
}}
/>
</View>
);
|
src/components/Layout/Layout.js | kinshuk-jain/TB-Dfront | import React from 'react';
import PropTypes from 'prop-types';
import withStyles from 'isomorphic-style-loader/lib/withStyles';
import s from './Layout.scss';
import Footer from '../Footer';
import TopBar from '../TopBar';
class Layout extends React.Component {
static propTypes = {
children: PropTypes.node.isRequired,
};
render() {
return (
<div>
<TopBar />
<div className={s.childContainer}>
{this.props.children}
</div>
<Footer />
</div>
);
}
}
export default withStyles(s)(Layout);
|
test/integration/image-component/base-path/pages/missing-src.js | flybayer/next.js | import React from 'react'
import Image from 'next/image'
const Page = () => {
return (
<div>
<Image width={200}></Image>
</div>
)
}
export default Page
|
src/components/Question.js | nebgnahz/style-guess | import React from 'react';
import './Question.css';
import Hammer from 'react-hammerjs';
const title = "What's my wedding style?";
function Question(props) {
const clickLike = (e) => {
props.answered(1)
};
const clickNay = (e) => {
props.answered(0)
};
var divStyle = {
'backgroundImage': "url(" + props.image + ")",
'backgroundRepeat': "no-repeat",
'backgroundSize': '100%'
};
var progress = 100.0 * (props.current + 1) / props.total + "%";
var progressStyle = {
width: progress
}
return (
<div>
<div className="row">
<p className="fancy-text">{title}</p>
</div>
<Hammer>
<div className="row question" style={divStyle}>
<div className="left-side" onClick={clickNay}>
<span>
<i className="fa fa-lg fa-ban" aria-hidden="true"></i>
<div className="space"/>
not for me
</span>
</div>
<div className="right-side" onClick={clickLike}>
<span>
<i className="fa fa-lg fa-heart" aria-hidden="true"></i>
<div className="space"/>
like
</span>
</div>
</div>
</Hammer>
<div className="row">
<div id="progressbar">
<div id="progress" style={progressStyle}>
<div id="pbaranim">
</div>
</div>
</div>
</div>
<div className="row">
<span>{props.current + 1} / {props.total}</span>
</div>
</div>
);
}
Question.propTypes = {
image: React.PropTypes.string.isRequired,
answered: React.PropTypes.func.isRequired,
current: React.PropTypes.number.isRequired,
total: React.PropTypes.number.isRequired,
reset: React.PropTypes.func,
};
export default Question;
|
docs/index.js | simonguo/markdownLoader | import React from 'react';
import ReactDOM from 'react-dom';
import Markdown from '../src/Markdown';
import '../less/highlight.less';
const App = () => {
return <Markdown>{require('../README.md')}</Markdown>;
};
ReactDOM.render(<App />, document.getElementById('app'));
|
src/components/EyeIcon/EyeIcon.js | emanualjade/react-jade | import React from 'react';
/** SVG Eye Icon */
function EyeIcon() {
// Attribution: Fabián Alexis at https://commons.wikimedia.org/wiki/File:Antu_view-preview.svg
return (
<svg width="16" height="16" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 22 22">
<g transform="matrix(.02146 0 0 .02146 1 1)" fill="#4d4d4d">
<path d="m466.07 161.53c-205.6 0-382.8 121.2-464.2 296.1-2.5 5.3-2.5 11.5 0 16.9 81.4 174.9 258.6 296.1 464.2 296.1 205.6 0 382.8-121.2 464.2-296.1 2.5-5.3 2.5-11.5 0-16.9-81.4-174.9-258.6-296.1-464.2-296.1m0 514.7c-116.1 0-210.1-94.1-210.1-210.1 0-116.1 94.1-210.1 210.1-210.1 116.1 0 210.1 94.1 210.1 210.1 0 116-94.1 210.1-210.1 210.1" />
<circle cx="466.08" cy="466.02" r="134.5" />
</g>
</svg>
)
}
export default EyeIcon; |
js/components/form/placeholder.js | bengaara/simbapp |
import React, { Component } from 'react';
import { connect } from 'react-redux';
import { actions } from 'react-native-navigation-redux-helpers';
import { Container, Header, Title, Content, Button, Item, Label, Input, Body, Left, Right, Icon, Form, Text } from 'native-base';
import { Actions } from 'react-native-router-flux';
import styles from './styles';
const {
popRoute,
} = actions;
class Placeholder extends Component {
static propTypes = {
popRoute: React.PropTypes.func,
navigation: React.PropTypes.shape({
key: React.PropTypes.string,
}),
}
popRoute() {
this.props.popRoute(this.props.navigation.key);
}
render() {
return (
<Container style={styles.container}>
<Header>
<Left>
<Button transparent onPress={() => Actions.pop()}>
<Icon name="arrow-back" />
</Button>
</Left>
<Body>
<Title>Placeholder Label</Title>
</Body>
<Right />
</Header>
<Content>
<Form>
<Item placeholderLabel>
<Input placeholder="Username" />
</Item>
<Item last placeholderLabel>
<Input placeholder="Password" />
</Item>
</Form>
<Button block style={{ margin: 15, marginTop: 50 }}>
<Text>Sign In</Text>
</Button>
</Content>
</Container>
);
}
}
function bindAction(dispatch) {
return {
popRoute: key => dispatch(popRoute(key)),
};
}
const mapStateToProps = state => ({
navigation: state.cardNavigation,
themeState: state.drawer.themeState,
});
export default connect(mapStateToProps, bindAction)(Placeholder);
|
src/components/HeaderBar/index.js | welovekpop/uwave-web-welovekpop.club | import cx from 'classnames';
import React from 'react';
import PropTypes from 'prop-types';
import AppTitle from './AppTitle';
import Progress from './Progress';
import CurrentMedia from './CurrentMedia';
import Volume from './Volume';
import HistoryButton from './HistoryButton';
import CurrentDJ from './CurrentDJ';
const HeaderBar = ({
className,
title,
dj,
media,
mediaProgress,
mediaTimeRemaining,
volume,
muted,
onVolumeChange,
onVolumeMute,
onVolumeUnmute,
onToggleRoomHistory,
onToggleAboutOverlay,
...attrs
}) => (
<div
className={cx('HeaderBar', className)}
{...attrs}
>
<AppTitle
className="HeaderBar-title"
onClick={onToggleAboutOverlay}
>
{title}
</AppTitle>
<div className="HeaderBar-nowPlaying">
<CurrentMedia className="HeaderBar-media" media={media} />
{dj && <CurrentDJ className="HeaderBar-dj" dj={dj} />}
</div>
{media && (
<Progress
className="HeaderBar-progress"
currentProgress={mediaProgress}
timeRemaining={mediaTimeRemaining}
/>
)}
<div className="HeaderBar-volume">
<Volume
volume={volume}
muted={muted}
onVolumeChange={onVolumeChange}
onMute={onVolumeMute}
onUnmute={onVolumeUnmute}
/>
</div>
<div className="HeaderBar-history">
<HistoryButton onClick={onToggleRoomHistory} />
</div>
</div>
);
HeaderBar.propTypes = {
className: PropTypes.string,
title: PropTypes.string,
dj: PropTypes.object,
media: PropTypes.object,
mediaProgress: PropTypes.number.isRequired,
mediaTimeRemaining: PropTypes.number.isRequired,
volume: PropTypes.number,
muted: PropTypes.bool,
onVolumeChange: PropTypes.func,
onVolumeMute: PropTypes.func,
onVolumeUnmute: PropTypes.func,
onToggleRoomHistory: PropTypes.func,
onToggleAboutOverlay: PropTypes.func,
};
export default HeaderBar;
|
src/PanelContainer.js | billyryanwill/amplify | import React, { Component } from 'react';
import Playlist from './Playlist';
class PanelContainer extends Component {
render() {
return (
<main>
<Playlist/>
</main>
);
}
}
export default PanelContainer;
|
src/widgets/dropdown/component.js | InseeFr/Pogues | import React from 'react';
import { WIDGET_DROPDOWN } from 'constants/dom-constants';
const { COMPONENT_CLASS, SELECT_CLASS } = WIDGET_DROPDOWN;
const Dropdown = ({ onChange, value, options }) => (
<div className={COMPONENT_CLASS}>
<select
onChange={e => onChange(e.target.value)}
value={value}
id="STAMPS"
className={SELECT_CLASS}
>
<option value="" />
{options.map(s => (
<option key={s.id} value={s.id}>
{s.label}
</option>
))}
</select>
</div>
);
export default Dropdown;
|
docs/src/app/components/pages/get-started/ServerRendering.js | nathanmarks/material-ui | import React from 'react';
import Title from 'react-title-component';
import MarkdownElement from '../../MarkdownElement';
import serverRenderingText from './serverRendering.md';
const ServerRendering = () => (
<div>
<Title render={(previousTitle) => `Server Rendering - ${previousTitle}`} />
<MarkdownElement text={serverRenderingText} />
</div>
);
export default ServerRendering;
|
node_modules/react-native/local-cli/templates/HelloWorld/index.ios.js | niukui/gitpro | /**
* 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);
|
src/pages/CommunityPage.js | Open-Seat-Philly/open-seat | import React from 'react';
const CommunityPage = () => (
<div className='community-page'>
<h1>This is the community page.</h1>
</div>
);
export default CommunityPage;
|
node_modules/react-router/es6/Route.js | silky098/Youtube-React-Search | import React from 'react';
import invariant from 'invariant';
import { createRouteFromReactElement } from './RouteUtils';
import { component, components } from './InternalPropTypes';
var _React$PropTypes = React.PropTypes;
var string = _React$PropTypes.string;
var func = _React$PropTypes.func;
/**
* A <Route> is used to declare which components are rendered to the
* page when the URL matches a given pattern.
*
* Routes are arranged in a nested tree structure. When a new URL is
* requested, the tree is searched depth-first to find a route whose
* path matches the URL. When one is found, all routes in the tree
* that lead to it are considered "active" and their components are
* rendered into the DOM, nested in the same order as in the tree.
*/
var Route = React.createClass({
displayName: 'Route',
statics: {
createRouteFromReactElement: createRouteFromReactElement
},
propTypes: {
path: string,
component: component,
components: components,
getComponent: func,
getComponents: func
},
/* istanbul ignore next: sanity check */
render: function render() {
!false ? process.env.NODE_ENV !== 'production' ? invariant(false, '<Route> elements are for router configuration only and should not be rendered') : invariant(false) : void 0;
}
});
export default Route; |
javascript/components/region-details/index.js | artyomtrityak/atlantis-pbem-online | import React from 'react';
const RegionDetailsComponent = (props) => {
if (!props.details) {
return null;
}
//TODO: change key and add styles
return (
<div>
<h3>{props.title}</h3>
{props.details.map((line, i) => {
return (
<div key={i}>{line}</div>
);
})}
</div>
);
};
export default RegionDetailsComponent;
|
ampjsx/export.sparse.js | ampproject/amp-react-prototype | import React from 'react';
import SparseDoc from './src/stories/doc1.sparse';
import {hydrate} from 'react-dom';
// import {hydrate} from './src/tools/extract-doc';
console.log('QQQQ: index.sparse.js');
hydrate(<SparseDoc />, document.body);
|
src/svg-icons/av/equalizer.js | andrejunges/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let AvEqualizer = (props) => (
<SvgIcon {...props}>
<path d="M10 20h4V4h-4v16zm-6 0h4v-8H4v8zM16 9v11h4V9h-4z"/>
</SvgIcon>
);
AvEqualizer = pure(AvEqualizer);
AvEqualizer.displayName = 'AvEqualizer';
AvEqualizer.muiName = 'SvgIcon';
export default AvEqualizer;
|
modules/IndexLink.js | schnerd/react-router | import React from 'react'
import Link from './Link'
const IndexLink = React.createClass({
render() {
return <Link {...this.props} onlyActiveOnIndex={true} />
}
})
export default IndexLink
|
docs/app/Examples/elements/Image/Variations/ImageExampleFluid.js | clemensw/stardust | import React from 'react'
import { Image } from 'semantic-ui-react'
const ImageExampleFluid = () => (
<Image src='/assets/images/wireframe/image.png' fluid />
)
export default ImageExampleFluid
|
src/components/ProgressBar/ProgressBar.js | alopezitrs/ps-react-analo | import React from 'react';
import PropTypes from 'prop-types';
class ProgressBar extends React.Component {
getColor = (percent) => {
if (this.props.percent === 100) return 'green';
return this.props.percent > 50 ? 'lightgreen' : 'red';
}
getWidthAsPercentOfTotalWidth = () => {
return parseInt(this.props.width * (this.props.percent / 100), 10);
}
render() {
const {percent, width, height} = this.props;
return (
<div style={{border: 'solid 1px lightgray', width: width}}>
<div style={{
width: this.getWidthAsPercentOfTotalWidth(),
height,
backgroundColor: this.getColor(percent)
}} />
</div>
);
}
}
ProgressBar.propTypes = {
/** Percent of progress completed */
percent: PropTypes.number.isRequired,
/** Bar width */
width: PropTypes.number.isRequired,
/** Bar height */
height: PropTypes.number
};
ProgressBar.defaultProps = {
height: 5
};
export default ProgressBar;
|
src/svg-icons/device/network-cell.js | IsenrichO/mui-with-arrows | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let DeviceNetworkCell = (props) => (
<SvgIcon {...props}>
<path fillOpacity=".3" d="M2 22h20V2z"/><path d="M17 7L2 22h15z"/>
</SvgIcon>
);
DeviceNetworkCell = pure(DeviceNetworkCell);
DeviceNetworkCell.displayName = 'DeviceNetworkCell';
DeviceNetworkCell.muiName = 'SvgIcon';
export default DeviceNetworkCell;
|
components/Tutorial/LineTutorial.stories.js | cofacts/rumors-site | import React from 'react';
import { LineTutorialDesktop, LineTutorialMobile } from './LineTutorial';
import { withKnobs } from '@storybook/addon-knobs';
export default {
title: 'Tutorial/LineTutorial',
component: 'LineTutorial',
decorators: [withKnobs],
};
export const Desktop = () => <LineTutorialDesktop />;
export const Mobile = () => (
<div style={{ maxWidth: '500px' }}>
<LineTutorialMobile />
</div>
);
|
app/javascript/mastodon/features/compose/components/emoji_picker_dropdown.js | masarakki/mastodon | import React from 'react';
import PropTypes from 'prop-types';
import { defineMessages, injectIntl } from 'react-intl';
import { EmojiPicker as EmojiPickerAsync } from '../../ui/util/async-components';
import Overlay from 'react-overlays/lib/Overlay';
import classNames from 'classnames';
import ImmutablePropTypes from 'react-immutable-proptypes';
import detectPassiveEvents from 'detect-passive-events';
import { buildCustomEmojis } from '../../emoji/emoji';
const messages = defineMessages({
emoji: { id: 'emoji_button.label', defaultMessage: 'Insert emoji' },
emoji_search: { id: 'emoji_button.search', defaultMessage: 'Search...' },
emoji_not_found: { id: 'emoji_button.not_found', defaultMessage: 'No emojos!! (╯°□°)╯︵ ┻━┻' },
custom: { id: 'emoji_button.custom', defaultMessage: 'Custom' },
recent: { id: 'emoji_button.recent', defaultMessage: 'Frequently used' },
search_results: { id: 'emoji_button.search_results', defaultMessage: 'Search results' },
people: { id: 'emoji_button.people', defaultMessage: 'People' },
nature: { id: 'emoji_button.nature', defaultMessage: 'Nature' },
food: { id: 'emoji_button.food', defaultMessage: 'Food & Drink' },
activity: { id: 'emoji_button.activity', defaultMessage: 'Activity' },
travel: { id: 'emoji_button.travel', defaultMessage: 'Travel & Places' },
objects: { id: 'emoji_button.objects', defaultMessage: 'Objects' },
symbols: { id: 'emoji_button.symbols', defaultMessage: 'Symbols' },
flags: { id: 'emoji_button.flags', defaultMessage: 'Flags' },
});
const assetHost = process.env.CDN_HOST || '';
let EmojiPicker, Emoji; // load asynchronously
const backgroundImageFn = () => `${assetHost}/emoji/sheet_10.png`;
const listenerOptions = detectPassiveEvents.hasSupport ? { passive: true } : false;
const categoriesSort = [
'recent',
'custom',
'people',
'nature',
'foods',
'activity',
'places',
'objects',
'symbols',
'flags',
];
class ModifierPickerMenu extends React.PureComponent {
static propTypes = {
active: PropTypes.bool,
onSelect: PropTypes.func.isRequired,
onClose: PropTypes.func.isRequired,
};
handleClick = e => {
this.props.onSelect(e.currentTarget.getAttribute('data-index') * 1);
}
componentWillReceiveProps (nextProps) {
if (nextProps.active) {
this.attachListeners();
} else {
this.removeListeners();
}
}
componentWillUnmount () {
this.removeListeners();
}
handleDocumentClick = e => {
if (this.node && !this.node.contains(e.target)) {
this.props.onClose();
}
}
attachListeners () {
document.addEventListener('click', this.handleDocumentClick, false);
document.addEventListener('touchend', this.handleDocumentClick, listenerOptions);
}
removeListeners () {
document.removeEventListener('click', this.handleDocumentClick, false);
document.removeEventListener('touchend', this.handleDocumentClick, listenerOptions);
}
setRef = c => {
this.node = c;
}
render () {
const { active } = this.props;
return (
<div className='emoji-picker-dropdown__modifiers__menu' style={{ display: active ? 'block' : 'none' }} ref={this.setRef}>
<button onClick={this.handleClick} data-index={1}><Emoji emoji='fist' set='twitter' size={22} sheetSize={32} skin={1} backgroundImageFn={backgroundImageFn} /></button>
<button onClick={this.handleClick} data-index={2}><Emoji emoji='fist' set='twitter' size={22} sheetSize={32} skin={2} backgroundImageFn={backgroundImageFn} /></button>
<button onClick={this.handleClick} data-index={3}><Emoji emoji='fist' set='twitter' size={22} sheetSize={32} skin={3} backgroundImageFn={backgroundImageFn} /></button>
<button onClick={this.handleClick} data-index={4}><Emoji emoji='fist' set='twitter' size={22} sheetSize={32} skin={4} backgroundImageFn={backgroundImageFn} /></button>
<button onClick={this.handleClick} data-index={5}><Emoji emoji='fist' set='twitter' size={22} sheetSize={32} skin={5} backgroundImageFn={backgroundImageFn} /></button>
<button onClick={this.handleClick} data-index={6}><Emoji emoji='fist' set='twitter' size={22} sheetSize={32} skin={6} backgroundImageFn={backgroundImageFn} /></button>
</div>
);
}
}
class ModifierPicker extends React.PureComponent {
static propTypes = {
active: PropTypes.bool,
modifier: PropTypes.number,
onChange: PropTypes.func,
onClose: PropTypes.func,
onOpen: PropTypes.func,
};
handleClick = () => {
if (this.props.active) {
this.props.onClose();
} else {
this.props.onOpen();
}
}
handleSelect = modifier => {
this.props.onChange(modifier);
this.props.onClose();
}
render () {
const { active, modifier } = this.props;
return (
<div className='emoji-picker-dropdown__modifiers'>
<Emoji emoji='fist' set='twitter' size={22} sheetSize={32} skin={modifier} onClick={this.handleClick} backgroundImageFn={backgroundImageFn} />
<ModifierPickerMenu active={active} onSelect={this.handleSelect} onClose={this.props.onClose} />
</div>
);
}
}
@injectIntl
class EmojiPickerMenu extends React.PureComponent {
static propTypes = {
custom_emojis: ImmutablePropTypes.list,
frequentlyUsedEmojis: PropTypes.arrayOf(PropTypes.string),
loading: PropTypes.bool,
onClose: PropTypes.func.isRequired,
onPick: PropTypes.func.isRequired,
style: PropTypes.object,
placement: PropTypes.string,
arrowOffsetLeft: PropTypes.string,
arrowOffsetTop: PropTypes.string,
intl: PropTypes.object.isRequired,
skinTone: PropTypes.number.isRequired,
onSkinTone: PropTypes.func.isRequired,
};
static defaultProps = {
style: {},
loading: true,
frequentlyUsedEmojis: [],
};
state = {
modifierOpen: false,
placement: null,
};
handleDocumentClick = e => {
if (this.node && !this.node.contains(e.target)) {
this.props.onClose();
}
}
componentDidMount () {
document.addEventListener('click', this.handleDocumentClick, false);
document.addEventListener('touchend', this.handleDocumentClick, listenerOptions);
}
componentWillUnmount () {
document.removeEventListener('click', this.handleDocumentClick, false);
document.removeEventListener('touchend', this.handleDocumentClick, listenerOptions);
}
setRef = c => {
this.node = c;
}
getI18n = () => {
const { intl } = this.props;
return {
search: intl.formatMessage(messages.emoji_search),
notfound: intl.formatMessage(messages.emoji_not_found),
categories: {
search: intl.formatMessage(messages.search_results),
recent: intl.formatMessage(messages.recent),
people: intl.formatMessage(messages.people),
nature: intl.formatMessage(messages.nature),
foods: intl.formatMessage(messages.food),
activity: intl.formatMessage(messages.activity),
places: intl.formatMessage(messages.travel),
objects: intl.formatMessage(messages.objects),
symbols: intl.formatMessage(messages.symbols),
flags: intl.formatMessage(messages.flags),
custom: intl.formatMessage(messages.custom),
},
};
}
handleClick = emoji => {
if (!emoji.native) {
emoji.native = emoji.colons;
}
this.props.onClose();
this.props.onPick(emoji);
}
handleModifierOpen = () => {
this.setState({ modifierOpen: true });
}
handleModifierClose = () => {
this.setState({ modifierOpen: false });
}
handleModifierChange = modifier => {
this.props.onSkinTone(modifier);
}
render () {
const { loading, style, intl, custom_emojis, skinTone, frequentlyUsedEmojis } = this.props;
if (loading) {
return <div style={{ width: 299 }} />;
}
const title = intl.formatMessage(messages.emoji);
const { modifierOpen } = this.state;
return (
<div className={classNames('emoji-picker-dropdown__menu', { selecting: modifierOpen })} style={style} ref={this.setRef}>
<EmojiPicker
perLine={8}
emojiSize={22}
sheetSize={32}
custom={buildCustomEmojis(custom_emojis)}
color=''
emoji=''
set='twitter'
title={title}
i18n={this.getI18n()}
onClick={this.handleClick}
include={categoriesSort}
recent={frequentlyUsedEmojis}
skin={skinTone}
showPreview={false}
backgroundImageFn={backgroundImageFn}
autoFocus
emojiTooltip
/>
<ModifierPicker
active={modifierOpen}
modifier={skinTone}
onOpen={this.handleModifierOpen}
onClose={this.handleModifierClose}
onChange={this.handleModifierChange}
/>
</div>
);
}
}
export default @injectIntl
class EmojiPickerDropdown extends React.PureComponent {
static propTypes = {
custom_emojis: ImmutablePropTypes.list,
frequentlyUsedEmojis: PropTypes.arrayOf(PropTypes.string),
intl: PropTypes.object.isRequired,
onPickEmoji: PropTypes.func.isRequired,
onSkinTone: PropTypes.func.isRequired,
skinTone: PropTypes.number.isRequired,
};
state = {
active: false,
loading: false,
};
setRef = (c) => {
this.dropdown = c;
}
onShowDropdown = ({ target }) => {
this.setState({ active: true });
if (!EmojiPicker) {
this.setState({ loading: true });
EmojiPickerAsync().then(EmojiMart => {
EmojiPicker = EmojiMart.Picker;
Emoji = EmojiMart.Emoji;
this.setState({ loading: false });
}).catch(() => {
this.setState({ loading: false });
});
}
const { top } = target.getBoundingClientRect();
this.setState({ placement: top * 2 < innerHeight ? 'bottom' : 'top' });
}
onHideDropdown = () => {
this.setState({ active: false });
}
onToggle = (e) => {
if (!this.state.loading && (!e.key || e.key === 'Enter')) {
if (this.state.active) {
this.onHideDropdown();
} else {
this.onShowDropdown(e);
}
}
}
handleKeyDown = e => {
if (e.key === 'Escape') {
this.onHideDropdown();
}
}
setTargetRef = c => {
this.target = c;
}
findTarget = () => {
return this.target;
}
render () {
const { intl, onPickEmoji, onSkinTone, skinTone, frequentlyUsedEmojis } = this.props;
const title = intl.formatMessage(messages.emoji);
const { active, loading, placement } = this.state;
return (
<div className='emoji-picker-dropdown' onKeyDown={this.handleKeyDown}>
<div ref={this.setTargetRef} className='emoji-button' title={title} aria-label={title} aria-expanded={active} role='button' onClick={this.onToggle} onKeyDown={this.onToggle} tabIndex={0}>
<img
className={classNames('emojione', { 'pulse-loading': active && loading })}
alt='🙂'
src={`${assetHost}/emoji/1f602.svg`}
/>
</div>
<Overlay show={active} placement={placement} target={this.findTarget}>
<EmojiPickerMenu
custom_emojis={this.props.custom_emojis}
loading={loading}
onClose={this.onHideDropdown}
onPick={onPickEmoji}
onSkinTone={onSkinTone}
skinTone={skinTone}
frequentlyUsedEmojis={frequentlyUsedEmojis}
/>
</Overlay>
</div>
);
}
}
|
app/react-icons/fa/wheelchair.js | scampersand/sonos-front | import React from 'react';
import IconBase from 'react-icon-base';
export default class FaWheelchair extends React.Component {
render() {
return (
<IconBase viewBox="0 0 40 40" {...this.props}>
<g><path d="m24.8 26.5l2.3 4.5q-1.3 4-4.7 6.5t-7.5 2.5q-3.5 0-6.5-1.7t-4.7-4.7-1.7-6.5q0-4 2.3-7.3t6.2-4.7l0.3 2.9q-2.7 1.2-4.3 3.7t-1.6 5.4q0 4.2 2.9 7.1t7.1 2.9q2.8 0 5.1-1.4t3.7-3.9 1.1-5.3z m12.3 2.2l1.3 2.6-5.8 2.8q-0.2 0.2-0.6 0.2-0.9 0-1.3-0.8l-5.3-10.6h-10.5q-0.6 0-1-0.4t-0.5-0.9l-2.1-17.4q-0.1-0.4 0.1-0.9 0.3-1.2 1.3-1.9t2.2-0.7q1.4 0 2.5 1.1t1 2.5q0 1.5-1.1 2.6t-2.7 0.9l0.8 6.5h9.5v2.8h-9.1l0.3 2.9h10.2q0.9 0 1.3 0.8l5 10.1z"/></g>
</IconBase>
);
}
}
|
node_modules/react-router/es6/Redirect.js | PanJ/SimplerCityGlide | 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/app/components/auth/signin.js | rokbar/vivdchat | import React, { Component } from 'react';
import { Field, reduxForm } from 'redux-form';
import { connect } from 'react-redux'
import { signinUser } from '../../actions';
import { RaisedButton, TextField, Paper } from 'material-ui';
import PersonIcon from 'material-ui/svg-icons/social/person';
import verticalAlignCenter from 'material-ui/svg-icons/editor/vertical-align-center';
class Signin extends Component {
handleFormSubmit({ username, password }) {
// Need to do something to log user in
this.props.signinUser({ username, password });
}
renderAlert() {
if (this.props.errormessage) {
return (
<Paper
zDepth={3}
style={{ height: '30px', display: 'flex', alignItems: 'center', justifyContent: 'center', boxShadow: 'rgb(244, 67, 54) 0px 1px 6px', margin: '5px 0' }}
>
<div style={{ color: 'rgb(244, 67, 54)', fontSize: '14px' }}>
<strong>Oops!</strong> {this.props.errormessage}
</div>
</Paper>
)
}
}
render() {
const { handleSubmit, fields: { username, password } } = this.props;
return (
<div style={{ textAlign: 'center', height: '60%' }}>
<div style={{ display: 'table', margin: 'auto', height: '100%' }}>
<form style={{ display: 'table-cell', verticalAlign: 'middle' }} onSubmit={handleSubmit(this.handleFormSubmit.bind(this))}>
<TextField
floatingLabelText="Username"
children={<Field name="username" component="input" />}
/><br />
<TextField
floatingLabelText="Password"
children={<Field name="password" type="password" component="input" />}
/>
{this.renderAlert()}
<div style={{ paddingTop: '5px', textAlign: 'left' }}>
<RaisedButton
type="submit"
backgroundColor={'rgb(0, 188, 212)'}
labelColor={'rgb(255, 255, 255)'}
label="Sign In"
icon={<PersonIcon />}
/>
</div>
</form>
</div>
</div>
);
}
}
function mapStateToProps(state) {
return { errormessage: state.auth.error };
}
Signin = reduxForm({
form: 'signin',
fields: ['username', 'password']
})(Signin)
export default connect(mapStateToProps, { signinUser })(Signin); |
src/components/sub-components/CDN/CDN.js | theIYD/source-me | import React, { Component } from 'react';
import axios from 'axios';
class CDN extends React.Component {
constructor(props) {
super(props);
this.handleChangeOption = this.handleChangeOption.bind(this);
this.state = {
data: []
};
}
componentDidMount() {
this._isMounted = true;
axios.get(`${this.props.url}`)
.then(res => {
this.setState({
data: res.data.results,
link: ''
});
});
}
componentWillUnmount() {
this._isMounted = false;
}
handleChangeOption(e) {
let id = e.target.options[e.target.selectedIndex].id;
let cdn_link = this.state.data[id].latest;
this.setState({
link: cdn_link
});
}
render() {
return (
<div>
<section className="wrapper cdn">
<h2>Content Delivery Network Library</h2>
<hr />
<p className="about-library">CDNJS is one of the most famous free and public web front-end CDN services which is used by ~2,380,000 websites worldwide</p>
<select className="dropdown" onChange={this.handleChangeOption}>
{this.state.data.map((each, index) => <option id={index} key={each.name}>{each.name}</option>)}
</select>
<div className="color-cdn-link">
<p className="cdn-link">{this.state.link}</p>
</div>
</section>
</div>
);
}
}
export default CDN; |
src/components/ViewAppraisals.js | wiserl/appraisal-frontend | import React, { Component } from 'react';
import Appraisal from './AppraisalFormat';
export default class extends Component {
constructor(props) {
super(props);
this.state = { appraisals: [] };
}
componentDidMount() {
fetch(`http://localhost:5000/appraisals/`)
.then(response => response.json())
.then(appraisals => this.setState({ appraisals }))
.catch(console.error);
}
render() {
return (
<div>
<h1>List of appraisals</h1>
{this.state.appraisals.map(appraisals => Appraisal(appraisals))}
<li><a href="http://localhost:3000/menu">menu</a></li>
</div>
);
}
} |
packages/mineral-ui-icons/src/IconAirlineSeatReclineNormal.js | mineral-ui/mineral-ui | /* @flow */
import React from 'react';
import Icon from 'mineral-ui/Icon';
import type { IconProps } from 'mineral-ui/Icon/types';
/* eslint-disable prettier/prettier */
export default function IconAirlineSeatReclineNormal(props: IconProps) {
const iconProps = {
rtl: false,
...props
};
return (
<Icon {...iconProps}>
<g>
<path d="M7.59 5.41c-.78-.78-.78-2.05 0-2.83.78-.78 2.05-.78 2.83 0 .78.78.78 2.05 0 2.83-.79.79-2.05.79-2.83 0zM6 16V7H4v9c0 2.76 2.24 5 5 5h6v-2H9c-1.66 0-3-1.34-3-3zm14 4.07L14.93 15H11.5v-3.68c1.4 1.15 3.6 2.16 5.5 2.16v-2.16c-1.66.02-3.61-.87-4.67-2.04l-1.4-1.55c-.19-.21-.43-.38-.69-.5-.29-.14-.62-.23-.96-.23h-.03C8.01 7 7 8.01 7 9.25V15c0 1.66 1.34 3 3 3h5.07l3.5 3.5L20 20.07z"/>
</g>
</Icon>
);
}
IconAirlineSeatReclineNormal.displayName = 'IconAirlineSeatReclineNormal';
IconAirlineSeatReclineNormal.category = 'notification';
|
src/nav/StreamTabs.js | kunall17/zulip-mobile | /* @TODO flow */
import React from 'react';
import { Text } from 'react-native';
import { TabNavigator, TabBarTop } from 'react-navigation';
import { FormattedMessage } from 'react-intl';
import tabsOptions from '../styles/tabs';
import UnreadStreamsContainer from '../unread/UnreadStreamsContainer';
import SubscriptionsContainer from '../streams/SubscriptionsContainer';
import StreamListContainer from '../subscriptions/StreamListContainer';
export default TabNavigator(
{
unread: {
screen: props => <UnreadStreamsContainer {...props.screenProps} />,
navigationOptions: {
tabBarLabel: props => (
<Text style={{ color: props.tintColor }}>
<FormattedMessage id="Unread" defaultMessage="Unread" />
</Text>
),
},
},
subscribed: {
screen: props => <SubscriptionsContainer {...props.screenProps} />,
navigationOptions: {
tabBarLabel: props => (
<Text style={{ color: props.tintColor }}>
<FormattedMessage id="Subscribed" defaultMessage="Subscribed" />
</Text>
),
},
},
streams: {
screen: props => <StreamListContainer {...props.screenProps} />,
navigationOptions: {
tabBarLabel: props => (
<Text style={{ color: props.tintColor }}>
<FormattedMessage id="All streams" defaultMessage="All streams" />
</Text>
),
},
},
},
tabsOptions(TabBarTop, 'top', true, 100),
);
|
KDReactNative/index.ios.js | csyibei/KDReactNative | /**
* Sample React Native App
* https://github.com/facebook/react-native
* @flow
*/
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
Text,
View
} from 'react-native';
var TabBar = require('./KDClass/KDTabbar');
var KDNav = require('./KDClass/KDNavigator');
var KDReactNative = React.createClass({
render() {
return (
<KDNav />
);
}
});
AppRegistry.registerComponent('KDReactNative', () => KDReactNative);
|
internals/templates/appContainer.js | AK33M/scalable-react | /**
*
* App.react.js
*
* This component is the skeleton around the actual pages, and should only
* contain code that should be seen on all pages. (e.g. navigation bar)
*
* NOTE: while this component should technically be a stateless functional
* component (SFC), hot reloading does not currently support SFCs. If hot
* reloading is not a neccessity for you then you can refactor it and remove
* the linting exception.
*/
import React from 'react';
import styles from './styles.css';
export default class App extends React.Component { // eslint-disable-line react/prefer-stateless-function
static propTypes = {
children: React.PropTypes.node,
};
render() {
return (
<div className={styles.container}>
{React.Children.toArray(this.props.children)}
</div>
);
}
}
|
examples/js/selection/default-select-table.js | dana2208/react-bootstrap-table | /* eslint max-len: 0 */
import React from 'react';
import { BootstrapTable, TableHeaderColumn } from 'react-bootstrap-table';
const products = [];
function addProducts(quantity) {
const startId = products.length;
for (let i = 0; i < quantity; i++) {
const id = startId + i;
products.push({
id: id,
name: 'Item name ' + id,
price: 2100 + i
});
}
}
addProducts(5);
const selectRowProp = {
mode: 'checkbox',
selected: [ 0, 2, 4 ] // give a array which contain the row key you want to select.
};
export default class DefaultSelectTable extends React.Component {
render() {
return (
<BootstrapTable data={ products } selectRow={ selectRowProp }>
<TableHeaderColumn dataField='id' isKey={ true }>Product ID</TableHeaderColumn>
<TableHeaderColumn dataField='name'>Product Name</TableHeaderColumn>
<TableHeaderColumn dataField='price'>Product Price</TableHeaderColumn>
</BootstrapTable>
);
}
}
|
examples/complete/simple/src/App.js | prescottprue/react-redux-firebase | import React from 'react'
import { Provider } from 'react-redux'
import firebase from 'firebase/app'
import 'firebase/auth'
import 'firebase/database'
import 'firebase/firestore' // make sure you add this for firestore
import { ReactReduxFirebaseProvider } from 'react-redux-firebase';
import { createFirestoreInstance } from 'redux-firestore';
import Home from './Home'
import configureStore from './store'
import initFirebase from './initFirebase'
import { reduxFirebase as rfConfig } from './config'
import './App.css'
const initialState = window && window.__INITIAL_STATE__ // set initial state here
const store = configureStore(initialState)
// Initialize Firebase instance
initFirebase()
export default function App () {
return (
<Provider store={store}>
<ReactReduxFirebaseProvider
firebase={firebase}
config={rfConfig}
dispatch={store.dispatch}
createFirestoreInstance={createFirestoreInstance}>
<Home />
</ReactReduxFirebaseProvider>
</Provider>
)
}
|
[JS-ES6][React] Raji client - second version/app/lib/routes.js | datyayu/cemetery | import React from 'react';
import {Router, Route, IndexRoute, Redirect} from 'react-router';
import App from './containers/App';
import NowPlaying from './containers/NowPlaying';
import Series from './containers/Series.js';
export const createRouter = (history) =>
<Router history={history}>
<Route path="/" component={App}>
<IndexRoute component={NowPlaying} />
<Route path="series" component={Series} />
<Redirect from="*" to="/" />
</Route>
</Router>
;
|
js/components/CSHeader.js | kilimondjaro/react-native-couchsurfing-app | // @flow
import React, { Component } from 'react';
import {
Platform,
Text,
TouchableOpacity,
Image,
View,
StyleSheet
} from 'react-native';
export type Item = {
text?: string;
icon?: Object;
onPress?: () => void;
};
export type Props = {
title?: string;
leftItem?: Array<Item>;
rightItem?: Array<Item>;
style?: any;
children?: any;
};
class HeaderAndroid extends Component {
}
export class ItemsWrapperIOS extends Component {
props: {
items?: Array<Item>;
};
render() {
if (!this.props.items) {
return null;
}
return (
<View style={styles.itemWrapper}>
{this.props.items.map((itemElement, i) => {
const {text, icon, onPress} = itemElement;
if (!text && !icon) {
return null;
}
return (
<TouchableOpacity key={i} onPress={onPress}>
{
text
? (<Text style={styles.itemText}>{text}</Text>)
: (<Image source={icon}/>)
}
</TouchableOpacity>
);
})}
</View>
);
}
}
class HeaderIOS extends Component {
props: Props;
render() {
const { title, leftItem, rightItem } = this.props;
const titleElement = title
? (<View style={styles.centerItem}>
<Text style={styles.title}>{title.toUpperCase()}</Text>
</View>)
: null;
return (
<View style={[styles.header, this.props.style]}>
<View style={styles.leftItem}>
<ItemsWrapperIOS
items={leftItem}
/>
</View>
{ titleElement }
<View style={styles.rightItem}>
<ItemsWrapperIOS
items={rightItem}
/>
</View>
</View>
);
}
}
export const CSHeader = Platform.OS === 'ios' ? HeaderIOS : HeaderAndroid;
var STATUS_BAR_HEIGHT = Platform.OS === 'ios' ? 20 : 25;
var HEADER_HEIGHT = Platform.OS === 'ios' ? 44 + STATUS_BAR_HEIGHT : 56 + STATUS_BAR_HEIGHT;
const styles = StyleSheet.create({
header: {
height: HEADER_HEIGHT,
paddingTop: STATUS_BAR_HEIGHT,
borderBottomWidth: 0.5,
borderColor: 'gray',
flexDirection: 'row',
justifyContent: 'space-between',
alignItems: 'center',
backgroundColor: 'white'
},
title: {
fontSize: 16
},
itemText: {
fontSize: 15
},
leftItem: {
flex: 1,
alignItems: 'flex-start',
paddingLeft: 10
},
centerItem: {
flex: 4,
alignItems: 'center',
},
rightItem: {
flex: 1,
alignItems: 'flex-end',
paddingRight: 10
},
itemWrapper: {
flexDirection: 'row'
}
});
|
src/components/App.js | dggriffin/MPSOhhh | require('styles/App.css');
import React from 'react';
import darkBaseTheme from 'material-ui/styles/baseThemes/lightBaseTheme';
import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider';
import getMuiTheme from 'material-ui/styles/getMuiTheme';
const darkMuiTheme = getMuiTheme(darkBaseTheme);
class AppComponent extends React.Component {
constructor(props) {
super(props);
this.state = {
...props
};
}
render() {
return (
<MuiThemeProvider muiTheme={darkMuiTheme}>
{this.props.children}
</MuiThemeProvider>
);
}
}
export default AppComponent;
|
node_modules/bs-recipes/recipes/webpack.react-hot-loader/app/js/main.js | IdealEnigma/idealenigma.github.io | import React from 'react';
import { render } from 'react-dom';
// It's important to not define HelloWorld component right in this file
// because in that case it will do full page reload on change
import HelloWorld from './HelloWorld.jsx';
render(<HelloWorld />, document.getElementById('react-root'));
|
lib/site/topic-layout/topic-article/comments/list/comment/content/component.js | lomegor/DemocracyOS-App | import React from 'react'
import t from 't-component'
import AutoGrowTextarea from 'lib/site/topic-layout/topic-article/comments/form/autogrow-textarea'
export default function CommentContent (props) {
let Content = (
<div
className='text'
dangerouslySetInnerHTML={{ __html: props.textHtml }} />
)
if (props.isOwner && props.editing) {
Content = (
<form
className='edit-form'
onSubmit={props.onHandleEdit}>
<AutoGrowTextarea
autoFocus
defaultValue={props.text}
maxLength='4096'
minLength='1' />
<button
type='submit'
className='btn btn-sm btn-success'>
{t('common.ok')}
</button>
<button
type='button'
onClick={props.handleHideEdit}
className='btn btn-sm btn-default'>
{t('common.cancel')}
</button>
</form>
)
}
return Content
}
|
components/ScoreCard.js | imsolost/Set-React | import React from 'react'
import { StyleSheet, Text, View } from 'react-native'
import Dimensions from 'Dimensions'
export default ScoreCard = ( props ) => {
return <Text style={styles.score}>Score: {props.score}</Text>
}
const styles = StyleSheet.create({
score: {
color: 'red',
fontSize: 22,
alignSelf: 'center',
}
})
|
platforms/server/controllers/serverRenderCtrl.js | wssgcg1213/koa2-react-isomorphic-boilerplate | /**
* Created at 16/5/20.
* @Author Ling.
* @Email i@zeroling.com
*/
import React from 'react'
import { RouterContext } from 'react-router'
import { renderToString } from 'react-dom/server'
import { Provider } from 'react-redux'
import config from '../../common/config'
import configureStore from '../../../app/store/configureStore'
const store = configureStore()
export default async (ctx, next, renderProps) => {
const route = renderProps.routes[renderProps.routes.length - 1]
let prefetchTasks = []
for (let component of renderProps.components) {
if (component && component.WrappedComponent && component.WrappedComponent.fetch) {
const _tasks = component.WrappedComponent.fetch(store.getState(), store.dispatch)
if (Array.isArray(_tasks)) {
prefetchTasks = prefetchTasks.concat(_tasks)
} else if (_tasks.then) {
prefetchTasks.push(_tasks)
}
}
}
await Promise.all(prefetchTasks)
await ctx.render('index', {
title: config.title,
dev: ctx.app.env === 'development',
reduxData: store.getState(),
app: renderToString(<Provider store={store}>
<RouterContext {...renderProps} />
</Provider>)
})
}
|
src/svg-icons/image/music-note.js | rscnt/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let ImageMusicNote = (props) => (
<SvgIcon {...props}>
<path d="M12 3v10.55c-.59-.34-1.27-.55-2-.55-2.21 0-4 1.79-4 4s1.79 4 4 4 4-1.79 4-4V7h4V3h-6z"/>
</SvgIcon>
);
ImageMusicNote = pure(ImageMusicNote);
ImageMusicNote.displayName = 'ImageMusicNote';
export default ImageMusicNote;
|
src/svg-icons/device/signal-cellular-no-sim.js | hai-cea/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let DeviceSignalCellularNoSim = (props) => (
<SvgIcon {...props}>
<path d="M18.99 5c0-1.1-.89-2-1.99-2h-7L7.66 5.34 19 16.68 18.99 5zM3.65 3.88L2.38 5.15 5 7.77V19c0 1.1.9 2 2 2h10.01c.35 0 .67-.1.96-.26l1.88 1.88 1.27-1.27L3.65 3.88z"/>
</SvgIcon>
);
DeviceSignalCellularNoSim = pure(DeviceSignalCellularNoSim);
DeviceSignalCellularNoSim.displayName = 'DeviceSignalCellularNoSim';
DeviceSignalCellularNoSim.muiName = 'SvgIcon';
export default DeviceSignalCellularNoSim;
|
assets/jqwidgets/demos/react/app/tabs/events/app.js | juannelisalde/holter | import React from 'react';
import ReactDOM from 'react-dom';
import JqxTabs from '../../../jqwidgets-react/react_jqxtabs.js';
import JqxPanel from '../../../jqwidgets-react/react_jqxpanel.js';
class App extends React.Component {
componentDidMount() {
//Create event
this.refs.myTabs.on('created', (event) => {
displayEvent(event);
});
//Selected event
this.refs.myTabs.on('selected', (event) => {
displayEvent(event);
});
//Selected event
this.refs.myTabs.on('tabclick', (event) => {
displayEvent(event);
});
//Unselected event
this.refs.myTabs.on('unselected', (event) => {
displayEvent(event);
});
//DragStart event
this.refs.myTabs.on('dragStart', (event) => {
displayEvent(event);
});
//DragEnd event
this.refs.myTabs.on('dragEnd', (event) => {
displayEvent(event);
});
let capitaliseFirstLetter = (string) => {
return string.charAt(0).toUpperCase() + string.slice(1);
}
let displayEvent = (event) => {
let eventData = capitaliseFirstLetter(event.type);
if (event.type !== 'removed') {
if (event.args !== undefined) {
eventData += ': ' + this.refs.myTabs.getTitleAt(event.args.item);
if (this.refs.myTabs.getTitleAt(event.args.item) == null) {
let v = 23;
}
}
if (event.type === 'dragEnd') {
eventData += ', Drop index: ' + this.refs.myTabs.getTitleAt(event.args.dropIndex);
}
} else {
eventData += ': ' + event.args.title;
title = null;
}
this.refs.events.prepend('<div style="margin-top: 5px;">' + eventData + '</div>');
}
this.refs.events.prepend('<div style="margin-top: 5px;">Created</div>');
}
render() {
return (
<div>
<JqxTabs ref='myTabs'
height={200} width={500} reorder={true} enableDropAnimation={false}
>
<ul style={{ marginLeft: 30 }}>
<li>Node.js</li>
<li>JavaServer Pages</li>
<li>Active Server Pages</li>
</ul>
<div>
Node.js is an event-driven I/O server-side JavaScript environment based on V8. It
is intended for writing scalable network programs such as web servers. It was created
by Ryan Dahl in 2009, and its growth is sponsored by Joyent, which employs Dahl.
Similar environments written in other programming languages include Twisted for
Python, Perl Object Environment for Perl, libevent for C and EventMachine for Ruby.
Unlike most JavaScript, it is not executed in a web browser, but is instead a form
of server-side JavaScript. Node.js implements some CommonJS specifications. Node.js
includes a REPL environment for interactive testing.
</div>
<div>
JavaServer Pages (JSP) is a Java technology that helps software developers serve
dynamically generated web pages based on HTML, XML, or other document types. Released
in 1999 as Sun's answer to ASP and PHP,[citation needed] JSP was designed to address
the perception that the Java programming environment didn't provide developers with
enough support for the Web. To deploy and run, a compatible web server with servlet
container is required. The Java Servlet and the JavaServer Pages (JSP) specifications
from Sun Microsystems and the JCP (Java Community Process) must both be met by the
container.
</div>
<div>
ASP.NET is a web application framework developed and marketed by Microsoft to allow
programmers to build dynamic web sites, web applications and web services. It was
first released in January 2002 with version 1.0 of the .NET Framework, and is the
successor to Microsoft's Active Server Pages (ASP) technology. ASP.NET is built
on the Common Language Runtime (CLR), allowing programmers to write ASP.NET code
using any supported .NET language. The ASP.NET SOAP extension framework allows ASP.NET
components to process SOAP messages.
</div>
</JqxTabs>
<br />
<div style={{ fontFamily: 'Arial, Verdana', fontSize: 13 }}>Events:</div>
<JqxPanel ref='events' style={{ borderWidth: 0 }}
height={250} width={450}
/>
</div>
)
}
}
ReactDOM.render(<App />, document.getElementById('app'));
|
src/components/common/svg-icons/image/control-point.js | abzfarah/Pearson.NAPLAN.GnomeH | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let ImageControlPoint = (props) => (
<SvgIcon {...props}>
<path d="M13 7h-2v4H7v2h4v4h2v-4h4v-2h-4V7zm-1-5C6.49 2 2 6.49 2 12s4.49 10 10 10 10-4.49 10-10S17.51 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8z"/>
</SvgIcon>
);
ImageControlPoint = pure(ImageControlPoint);
ImageControlPoint.displayName = 'ImageControlPoint';
ImageControlPoint.muiName = 'SvgIcon';
export default ImageControlPoint;
|
index.android.js | jcollum/kishar-nine | /**
* 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 kalmaTen 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.android.js
</Text>
<Text style={styles.instructions}>
Double tap R on your keyboard to reload,{'\n'}
Shake or press menu button 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('kalmaTen', () => kalmaTen);
|
app/javascript/mastodon/features/compose/components/emoji_picker_dropdown.js | clworld/mastodon | import React from 'react';
import PropTypes from 'prop-types';
import { defineMessages, injectIntl } from 'react-intl';
import { EmojiPicker as EmojiPickerAsync } from '../../ui/util/async-components';
import Overlay from 'react-overlays/lib/Overlay';
import classNames from 'classnames';
import ImmutablePropTypes from 'react-immutable-proptypes';
import detectPassiveEvents from 'detect-passive-events';
import { buildCustomEmojis } from '../../emoji/emoji';
const messages = defineMessages({
emoji: { id: 'emoji_button.label', defaultMessage: 'Insert emoji' },
emoji_search: { id: 'emoji_button.search', defaultMessage: 'Search...' },
emoji_not_found: { id: 'emoji_button.not_found', defaultMessage: 'No emojos!! (╯°□°)╯︵ ┻━┻' },
custom: { id: 'emoji_button.custom', defaultMessage: 'Custom' },
recent: { id: 'emoji_button.recent', defaultMessage: 'Frequently used' },
search_results: { id: 'emoji_button.search_results', defaultMessage: 'Search results' },
people: { id: 'emoji_button.people', defaultMessage: 'People' },
nature: { id: 'emoji_button.nature', defaultMessage: 'Nature' },
food: { id: 'emoji_button.food', defaultMessage: 'Food & Drink' },
activity: { id: 'emoji_button.activity', defaultMessage: 'Activity' },
travel: { id: 'emoji_button.travel', defaultMessage: 'Travel & Places' },
objects: { id: 'emoji_button.objects', defaultMessage: 'Objects' },
symbols: { id: 'emoji_button.symbols', defaultMessage: 'Symbols' },
flags: { id: 'emoji_button.flags', defaultMessage: 'Flags' },
});
const assetHost = process.env.CDN_HOST || '';
let EmojiPicker, Emoji; // load asynchronously
const backgroundImageFn = () => `${assetHost}/emoji/sheet_10.png`;
const listenerOptions = detectPassiveEvents.hasSupport ? { passive: true } : false;
const categoriesSort = [
'recent',
'custom',
'people',
'nature',
'foods',
'activity',
'places',
'objects',
'symbols',
'flags',
];
class ModifierPickerMenu extends React.PureComponent {
static propTypes = {
active: PropTypes.bool,
onSelect: PropTypes.func.isRequired,
onClose: PropTypes.func.isRequired,
};
handleClick = e => {
this.props.onSelect(e.currentTarget.getAttribute('data-index') * 1);
}
componentWillReceiveProps (nextProps) {
if (nextProps.active) {
this.attachListeners();
} else {
this.removeListeners();
}
}
componentWillUnmount () {
this.removeListeners();
}
handleDocumentClick = e => {
if (this.node && !this.node.contains(e.target)) {
this.props.onClose();
}
}
attachListeners () {
document.addEventListener('click', this.handleDocumentClick, false);
document.addEventListener('touchend', this.handleDocumentClick, listenerOptions);
}
removeListeners () {
document.removeEventListener('click', this.handleDocumentClick, false);
document.removeEventListener('touchend', this.handleDocumentClick, listenerOptions);
}
setRef = c => {
this.node = c;
}
render () {
const { active } = this.props;
return (
<div className='emoji-picker-dropdown__modifiers__menu' style={{ display: active ? 'block' : 'none' }} ref={this.setRef}>
<button onClick={this.handleClick} data-index={1}><Emoji emoji='fist' set='twitter' size={22} sheetSize={32} skin={1} backgroundImageFn={backgroundImageFn} /></button>
<button onClick={this.handleClick} data-index={2}><Emoji emoji='fist' set='twitter' size={22} sheetSize={32} skin={2} backgroundImageFn={backgroundImageFn} /></button>
<button onClick={this.handleClick} data-index={3}><Emoji emoji='fist' set='twitter' size={22} sheetSize={32} skin={3} backgroundImageFn={backgroundImageFn} /></button>
<button onClick={this.handleClick} data-index={4}><Emoji emoji='fist' set='twitter' size={22} sheetSize={32} skin={4} backgroundImageFn={backgroundImageFn} /></button>
<button onClick={this.handleClick} data-index={5}><Emoji emoji='fist' set='twitter' size={22} sheetSize={32} skin={5} backgroundImageFn={backgroundImageFn} /></button>
<button onClick={this.handleClick} data-index={6}><Emoji emoji='fist' set='twitter' size={22} sheetSize={32} skin={6} backgroundImageFn={backgroundImageFn} /></button>
</div>
);
}
}
class ModifierPicker extends React.PureComponent {
static propTypes = {
active: PropTypes.bool,
modifier: PropTypes.number,
onChange: PropTypes.func,
onClose: PropTypes.func,
onOpen: PropTypes.func,
};
handleClick = () => {
if (this.props.active) {
this.props.onClose();
} else {
this.props.onOpen();
}
}
handleSelect = modifier => {
this.props.onChange(modifier);
this.props.onClose();
}
render () {
const { active, modifier } = this.props;
return (
<div className='emoji-picker-dropdown__modifiers'>
<Emoji emoji='fist' set='twitter' size={22} sheetSize={32} skin={modifier} onClick={this.handleClick} backgroundImageFn={backgroundImageFn} />
<ModifierPickerMenu active={active} onSelect={this.handleSelect} onClose={this.props.onClose} />
</div>
);
}
}
@injectIntl
class EmojiPickerMenu extends React.PureComponent {
static propTypes = {
custom_emojis: ImmutablePropTypes.list,
frequentlyUsedEmojis: PropTypes.arrayOf(PropTypes.string),
loading: PropTypes.bool,
onClose: PropTypes.func.isRequired,
onPick: PropTypes.func.isRequired,
style: PropTypes.object,
placement: PropTypes.string,
arrowOffsetLeft: PropTypes.string,
arrowOffsetTop: PropTypes.string,
intl: PropTypes.object.isRequired,
skinTone: PropTypes.number.isRequired,
onSkinTone: PropTypes.func.isRequired,
};
static defaultProps = {
style: {},
loading: true,
frequentlyUsedEmojis: [],
};
state = {
modifierOpen: false,
placement: null,
};
handleDocumentClick = e => {
if (this.node && !this.node.contains(e.target)) {
this.props.onClose();
}
}
componentDidMount () {
document.addEventListener('click', this.handleDocumentClick, false);
document.addEventListener('touchend', this.handleDocumentClick, listenerOptions);
}
componentWillUnmount () {
document.removeEventListener('click', this.handleDocumentClick, false);
document.removeEventListener('touchend', this.handleDocumentClick, listenerOptions);
}
setRef = c => {
this.node = c;
}
getI18n = () => {
const { intl } = this.props;
return {
search: intl.formatMessage(messages.emoji_search),
notfound: intl.formatMessage(messages.emoji_not_found),
categories: {
search: intl.formatMessage(messages.search_results),
recent: intl.formatMessage(messages.recent),
people: intl.formatMessage(messages.people),
nature: intl.formatMessage(messages.nature),
foods: intl.formatMessage(messages.food),
activity: intl.formatMessage(messages.activity),
places: intl.formatMessage(messages.travel),
objects: intl.formatMessage(messages.objects),
symbols: intl.formatMessage(messages.symbols),
flags: intl.formatMessage(messages.flags),
custom: intl.formatMessage(messages.custom),
},
};
}
handleClick = emoji => {
if (!emoji.native) {
emoji.native = emoji.colons;
}
this.props.onClose();
this.props.onPick(emoji);
}
handleModifierOpen = () => {
this.setState({ modifierOpen: true });
}
handleModifierClose = () => {
this.setState({ modifierOpen: false });
}
handleModifierChange = modifier => {
this.props.onSkinTone(modifier);
}
render () {
const { loading, style, intl, custom_emojis, skinTone, frequentlyUsedEmojis } = this.props;
if (loading) {
return <div style={{ width: 299 }} />;
}
const title = intl.formatMessage(messages.emoji);
const { modifierOpen } = this.state;
return (
<div className={classNames('emoji-picker-dropdown__menu', { selecting: modifierOpen })} style={style} ref={this.setRef}>
<EmojiPicker
perLine={8}
emojiSize={22}
sheetSize={32}
custom={buildCustomEmojis(custom_emojis)}
color=''
emoji=''
set='twitter'
title={title}
i18n={this.getI18n()}
onClick={this.handleClick}
include={categoriesSort}
recent={frequentlyUsedEmojis}
skin={skinTone}
showPreview={false}
backgroundImageFn={backgroundImageFn}
autoFocus
emojiTooltip
/>
<ModifierPicker
active={modifierOpen}
modifier={skinTone}
onOpen={this.handleModifierOpen}
onClose={this.handleModifierClose}
onChange={this.handleModifierChange}
/>
</div>
);
}
}
export default @injectIntl
class EmojiPickerDropdown extends React.PureComponent {
static propTypes = {
custom_emojis: ImmutablePropTypes.list,
frequentlyUsedEmojis: PropTypes.arrayOf(PropTypes.string),
intl: PropTypes.object.isRequired,
onPickEmoji: PropTypes.func.isRequired,
onSkinTone: PropTypes.func.isRequired,
skinTone: PropTypes.number.isRequired,
};
state = {
active: false,
loading: false,
};
setRef = (c) => {
this.dropdown = c;
}
onShowDropdown = ({ target }) => {
this.setState({ active: true });
if (!EmojiPicker) {
this.setState({ loading: true });
EmojiPickerAsync().then(EmojiMart => {
EmojiPicker = EmojiMart.Picker;
Emoji = EmojiMart.Emoji;
this.setState({ loading: false });
}).catch(() => {
this.setState({ loading: false });
});
}
const { top } = target.getBoundingClientRect();
this.setState({ placement: top * 2 < innerHeight ? 'bottom' : 'top' });
}
onHideDropdown = () => {
this.setState({ active: false });
}
onToggle = (e) => {
if (!this.state.loading && (!e.key || e.key === 'Enter')) {
if (this.state.active) {
this.onHideDropdown();
} else {
this.onShowDropdown(e);
}
}
}
handleKeyDown = e => {
if (e.key === 'Escape') {
this.onHideDropdown();
}
}
setTargetRef = c => {
this.target = c;
}
findTarget = () => {
return this.target;
}
render () {
const { intl, onPickEmoji, onSkinTone, skinTone, frequentlyUsedEmojis } = this.props;
const title = intl.formatMessage(messages.emoji);
const { active, loading, placement } = this.state;
return (
<div className='emoji-picker-dropdown' onKeyDown={this.handleKeyDown}>
<div ref={this.setTargetRef} className='emoji-button' title={title} aria-label={title} aria-expanded={active} role='button' onClick={this.onToggle} onKeyDown={this.onToggle} tabIndex={0}>
<img
className={classNames('emojione', { 'pulse-loading': active && loading })}
alt='🙂'
src={`${assetHost}/emoji/1f602.svg`}
/>
</div>
<Overlay show={active} placement={placement} target={this.findTarget}>
<EmojiPickerMenu
custom_emojis={this.props.custom_emojis}
loading={loading}
onClose={this.onHideDropdown}
onPick={onPickEmoji}
onSkinTone={onSkinTone}
skinTone={skinTone}
frequentlyUsedEmojis={frequentlyUsedEmojis}
/>
</Overlay>
</div>
);
}
}
|
src/components/UIShell/HeaderMenuItem.js | joshblack/carbon-components-react | /**
* Copyright IBM Corp. 2016, 2018
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/
import { settings } from 'carbon-components';
import PropTypes from 'prop-types';
import React from 'react';
import Link, { LinkPropTypes } from './Link';
const { prefix } = settings;
const HeaderMenuItem = React.forwardRef(function HeaderMenuItem(
{ className, children, role, ...rest },
ref
) {
return (
<li className={className} role={role}>
<Link
{...rest}
className={`${prefix}--header__menu-item`}
ref={ref}
role="menuitem"
tabIndex={0}>
<span className={`${prefix}--text-truncate--end`}>{children}</span>
</Link>
</li>
);
});
HeaderMenuItem.propTypes = {
/**
* Pass in a valid `element` to replace the underlying `<a>` tag with a
* custom `Link` element
*/
...LinkPropTypes,
/**
* Optionally provide a custom class to apply to the underlying <li> node
*/
className: PropTypes.string,
/**
* Pass in children that are either a string or can be read as a string by
* screen readers
*/
children: PropTypes.node.isRequired,
/**
* Optionally supply a role for the underlying <li> node. Useful for resetting
* <ul> semantics for menus.
*/
role: PropTypes.string,
};
export default HeaderMenuItem;
|
src/client/app/components/app.js | JuMBoSLICE/JuMBo | import React, { Component } from 'react';
import {Router, Route, Link, IndexRoute, hashHistory, browserHistory} from 'react-router';
import Login from './login.js';
import Signup from './signup.js';
import styles from './../../style.css';
import Dashboard from './dashboard.js';
import ProjectCreator from './projectCreator.js';
import ProjectContainer from './projectContainer.js';
import axios from 'axios';
import AddProj from './addProj.js';
import Header from './header';
import ViewProject from './viewProject.js';
class App extends Component {
constructor(props) {
super(props);
this.state = {
page: 0,
name: '',
username: '',
password: '',
message: '',
newProject: '',
newProjectSummary: '',
}
this.newRegistration = this.newRegistration.bind(this);
this.signUpPost = this.signUpPost.bind(this);
this.usernameChange = this.usernameChange.bind(this);
this.nameChange = this.nameChange.bind(this);
this.passwordChange = this.passwordChange.bind(this);
this.userVerify = this.userVerify.bind(this);
this.changeView = this.changeView.bind(this);
this.projChange = this.projChange.bind(this);
this.createProject = this.createProject.bind(this);
}
//setState to change Login page to SignUp page
newRegistration() {
if (this.state.page === 0) {
this.setState({page: 1});
} else {
this.setState({page: 0});
}
}
//register new user on signup page, create new user in database, send client to login page
signUpPost() {
axios.post('/signup', {
username: this.state.username,
name: this.state.name,
password: this.state.password,
}).then((res) => {
this.setState({
page: res.data.view,
message: res.data.message
});
}).catch(function(error) {
console.log(error);
})
}
//verify user, send user to database
userVerify() {
axios.post('/login', {
username: this.state.username,
password: this.state.password
}).then((res) => {
// this.setState({page: res.data.view, message: res.data.message});
this.context.router.transitionTo('/home');
}).catch((error) => {
console.log(error);
})
}
//create new project in database, send client to dashboard
createProject() {
axios.post('/createProject', {
title: this.state.newProject,
summary: this.state.newProjectSummary
}).then((res) => {
this.setState({page: res.data.view, message: res.data.message})
}).catch((error) => {
console.log(error);
})
}
//changes to appropriate view based on passed in variable
changeView(num) {
this.setState({page: num})
}
//wraps username input and sends username value to state
usernameChange(e) {
const state = {};
state.username = e.target.value;
this.setState(state);
}
//wraps name input and sends name value to state
nameChange(e) {
const state = {};
state.name = e.target.value;
this.setState(state);
}
//wraps password input and sends password value to state
passwordChange(e) {
const state = {};
state.password= e.target.value;
this.setState(state);
}
//wraps project title input and sends project title value to state
projChange(e) {
const state = {};
state.newProject = e.target.value;
this.setState(state);
}
//conditional rendering for components based on 'page' property in state
render() {
return (
<Router history={browserHistory}>
<Route path='/' component={Header}>
<IndexRoute component={Dashboard} />
<Route path='/createProject' component={ProjectCreator} />
<Route path='/viewProject/:projectID' component={ViewProject} />
</Route>
</Router>
)
// if (this.state.page === 0) {
// return (
// <Login
// newRegistration = {this.newRegistration}
// page={this.state.page}
// userVerify = {this.userVerify}
// usernameChange = {this.usernameChange}
// passwordChange = {this.passwordChange}
// message = {this.state.message}
// />
// )
// };
// if (this.state.page === 1) {
// return (
// <Signup
// newRegistration = {this.newRegistration}
// usernameChange = {this.usernameChange}
// nameChange = {this.nameChange}
// passwordChange = {this.passwordChange}
// username = {this.state.username}
// password = {this.state.password}
// name = {this.state.name}
// signUpPost = {this.signUpPost}
// message = {this.state.message}
// />
// )
// }
// if (this.state.page === 2) {
// return (
// <Dashboard changeView = {this.changeView}/>
// )
// }
// if (this.state.page === 3) {
// return (
// <AddProj
// projChange = {this.projChange}
// createProject = {this.createProject}
// changeView = {this.changeView}
// />
// )
// }
}
}
export default App;
|
src/svg-icons/communication/call-made.js | lawrence-yu/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let CommunicationCallMade = (props) => (
<SvgIcon {...props}>
<path d="M9 5v2h6.59L4 18.59 5.41 20 17 8.41V15h2V5z"/>
</SvgIcon>
);
CommunicationCallMade = pure(CommunicationCallMade);
CommunicationCallMade.displayName = 'CommunicationCallMade';
CommunicationCallMade.muiName = 'SvgIcon';
export default CommunicationCallMade;
|
src/components/catList.js | nytai/cats | import '../styles/main.scss';
import React, { Component } from 'react';
import ReactCSSTransitionGroup from 'react-addons-css-transition-group';
export const Cat = (props) => {
const { id, fact, image, isHidden, byeSelf } = props;
let item;
if(!isHidden) {
item = (
<li key={id}
className="cat-item">
<img src={image.url} className="cat-image"/>
<p className="cat-fact"> {fact} </p>
<a className="delete-cat" href="#" onClick={byeSelf(id)}> Bye </a>
</li>
);
}
return(
<ReactCSSTransitionGroup
key={id}
transitionName="cat"
transitionEnterTimeout={500}
transitionLeaveTimeout={500}>
{item}
</ReactCSSTransitionGroup>
);
}
export class CatList extends Component {
componentDidMount() {
const { getCats } = this.props
getCats();
}
render(){
const { stateContainer, removeCat, getCats } = this.props;
const byeCat = id => e => {
e.preventDefault();
return removeCat(id);
}
const getMoreCats = e => {
e.preventDefault();
return getCats();
}
const killedAll = stateContainer.catImages.every( (e) => e.isHidden );
if (stateContainer.isFetching) {
return (
<div className="cats">
<p className="loading"> Loading... </p>
</div>
)
}
if (killedAll) {
return (
<div className="cats">
<div className="vertical-padd"> </div>
<a className="more-cats" href="#" onClick={getMoreCats}>Gimme More</a>
</div>
);
}
return (
<div className="cats">
<ul className="cat-list">
{
stateContainer.catImages.map( (e, i) => (
<Cat key={i} byeSelf={byeCat} id={i} image={e} isHidden={e.isHidden} fact={stateContainer.catFacts[i]} />
) )
}
</ul>
</div>
);
}
}
|
ui/node_modules/react-bootstrap/src/ButtonToolbar.js | bpatters/eservice | import React from 'react';
import classSet from 'classnames';
import BootstrapMixin from './BootstrapMixin';
const ButtonToolbar = React.createClass({
mixins: [BootstrapMixin],
getDefaultProps() {
return {
bsClass: 'button-toolbar'
};
},
render() {
let classes = this.getBsClassSet();
return (
<div
{...this.props}
role="toolbar"
className={classSet(this.props.className, classes)}>
{this.props.children}
</div>
);
}
});
export default ButtonToolbar;
|
src/js/components/widget/Graph.js | kukua/dashboard | import React from 'react'
import ReactHighcharts from 'react-highcharts'
import BaseWidget from './Base'
// http://stackoverflow.com/a/17853889/1453912
ReactHighcharts.Highcharts.dateFormats = {
W: function (timestamp) {
var date = new Date(timestamp)
var day = date.getUTCDay() == 0 ? 7 : date.getUTCDay()
var dayNumber
date.setDate(date.getUTCDate() + 4 - day)
dayNumber = Math.floor((date.getTime() - new Date(date.getUTCFullYear(), 0, 1, -6)) / 86400000)
return 1 + Math.floor(dayNumber / 7)
}
}
class GraphWidget extends BaseWidget {
constructor () {
super()
this.state = {
isLoading: true,
}
}
componentWillMount () {
this.setState({ isLoading: false })
}
getConfig (height) {
return {
title: {
text: this.getTitle(),
align: 'left',
style: {
fontSize: '14px',
fontWeight: 'bold',
fontFamily: '"Source Sans Pro", "Helvetica Neue", Helvetica, Arial, sans-serif',
},
},
tooltip: {
shared: true,
useHTML: true,
valueSuffix: '',
dateTimeLabelFormats: {
millisecond: '%H:%M %d-%m-%Y',
second: '%H:%M %d-%m-%Y',
minute: '%H:%M %d-%m-%Y',
hour: '%H:%M %d-%m-%Y',
day: '%H:%M %d-%m-%Y',
week: '%H:%M %d-%m-%Y',
month: '%H:%M %d-%m-%Y',
year: '%H:%M %d-%m-%Y',
},
},
legend: {
enabled: false,
},
chart: {
height,
style: {
fontFamily: 'Trebuchet MS',
},
zoomType: 'x',
},
plotOptions: {
series: {
cropTreshhold: 5000,
states: {
hover: {
enabled: false,
},
},
},
line: {
turboThreshold: 5000,
lineWidth: 1,
marker: {
enabled: false,
},
},
},
credits: {
enabled: false,
},
xAxis: {
type: 'datetime',
labels: {
rotation: -45,
align: 'right',
},
title: {
text: '',
},
crosshair: true,
alternateGridColor: '#f7f7f7',
dateTimeLabelFormats: {
millisecond: '%H:%M:%S.%L',
second: '%H:%M:%S',
minute: '%H:%M',
hour: '%H:%M',
day: '%d-%m-%Y',
week: 'week %W / %Y',
month: '%m-%Y',
year: '%Y',
},
},
yAxis: {
title: {
text: '',
},
},
series: this.getSeries(),
}
}
getTitle () {
return ''
}
getSeries () {
return this.props.series
}
renderChart (config) {
return (<ReactHighcharts config={config} />)
}
renderWarning () {}
render () {
var body, height = 400
if (this.state.isLoading) {
body = (<span>Loading…</span>)
}
if ( ! body) {
body = this.renderWarning(height)
}
if ( ! body) {
var config = this.getConfig(height)
if (config.series.length > 0) {
body = this.renderChart(config)
} else {
body = (<div class="alert alert-warning">No measurements.</div>)
}
}
return (<div style={{ height, position: 'relative' }}>{body}</div>)
}
}
GraphWidget.propTypes = {
series: React.PropTypes.array.isRequired,
}
export default GraphWidget
|
src/svg-icons/file/cloud-done.js | verdan/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let FileCloudDone = (props) => (
<SvgIcon {...props}>
<path d="M19.35 10.04C18.67 6.59 15.64 4 12 4 9.11 4 6.6 5.64 5.35 8.04 2.34 8.36 0 10.91 0 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5 0-2.64-2.05-4.78-4.65-4.96zM10 17l-3.5-3.5 1.41-1.41L10 14.17 15.18 9l1.41 1.41L10 17z"/>
</SvgIcon>
);
FileCloudDone = pure(FileCloudDone);
FileCloudDone.displayName = 'FileCloudDone';
FileCloudDone.muiName = 'SvgIcon';
export default FileCloudDone;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.