path
stringlengths 5
296
| repo_name
stringlengths 5
85
| content
stringlengths 25
1.05M
|
---|---|---|
js/components/sideBar/index.js | kondoSoft/que_hacer_movil |
import React, { Component } from 'react';
import { connect } from 'react-redux';
import { Content, Text, List, ListItem, Icon, Thumbnail, View } from 'native-base';
import { setIndex, resetState } from '../../actions/list';
import navigateTo from '../../actions/sideBarNav';
import myTheme from '../../themes/base-theme';
import styles from './style';
class SideBar extends Component {
static propTypes = {
setIndex: React.PropTypes.func,
navigateTo: React.PropTypes.func,
}
navigateTo(route, reset) {
this.props.navigateTo(route, 'home');
// if (reset) {
// this.props.resetState()
// }
}
render() {
return (
<Content style={styles.sidebar} >
<View style={styles.view} >
<Thumbnail square style={styles.image} source={require('../../../assets/img/Menu-Imagen.png')} />
</View>
<ListItem style={styles.listItem} button onPress={() => this.navigateTo('home', true)} >
<Icon style={styles.icon} name="ios-home"/>
<Text style={styles.text}>INICIO</Text>
</ListItem>
<ListItem style={styles.listItem} button onPress={() => this.navigateTo('contactus', true)} >
<Icon style={styles.icon} name="ios-mail"/>
<Text style={styles.text}>CONTACTANOS</Text>
</ListItem>
<ListItem style={styles.listItem} button onPress={() => this.navigateTo('bookmarks', true)} >
<Icon style={styles.icon} name="ios-heart"/>
<Text style={styles.text}>FAVORITOS</Text>
</ListItem>
</Content>
);
}
}
function bindAction(dispatch) {
return {
setIndex: index => dispatch(setIndex(index)),
navigateTo: (route, homeRoute) => dispatch(navigateTo(route, homeRoute)),
resetState: () => dispatch(resetState()),
};
}
const mapStateToProps = state => ({
navigation: state.cardNavigation,
});
export default connect(mapStateToProps, bindAction)(SideBar);
|
client/src/components/Home/ActivityList.js | seripap/darkwire.io | import React from 'react';
import PropTypes from 'prop-types';
import ChatInput from 'components/Chat';
import Activity from './Activity';
import T from 'components/T';
import { defer } from 'lodash';
import styles from './styles.module.scss';
const ActivityList = ({ activities, openModal }) => {
const [focusChat, setFocusChat] = React.useState(false);
const [scrolledToBottom, setScrolledToBottom] = React.useState(true);
const messageStream = React.useRef(null);
const activitiesList = React.useRef(null);
React.useEffect(() => {
const currentMessageStream = messageStream.current;
// Update scrolledToBottom state if we scroll the activity stream
const onScroll = () => {
const messageStreamHeight = messageStream.current.clientHeight;
const activitiesListHeight = activitiesList.current.clientHeight;
const bodyRect = document.body.getBoundingClientRect();
const elemRect = activitiesList.current.getBoundingClientRect();
const offset = elemRect.top - bodyRect.top;
const activitiesListYPos = offset;
const newScrolledToBottom = activitiesListHeight + (activitiesListYPos - 60) <= messageStreamHeight;
if (newScrolledToBottom) {
if (!scrolledToBottom) {
setScrolledToBottom(true);
}
} else if (scrolledToBottom) {
setScrolledToBottom(false);
}
};
currentMessageStream.addEventListener('scroll', onScroll);
return () => {
// Unbind event if component unmounted
currentMessageStream.removeEventListener('scroll', onScroll);
};
}, [scrolledToBottom]);
const scrollToBottomIfShould = React.useCallback(() => {
if (scrolledToBottom) {
messageStream.current.scrollTop = messageStream.current.scrollHeight;
}
}, [scrolledToBottom]);
React.useEffect(() => {
scrollToBottomIfShould(); // Only if activities.length bigger
}, [scrollToBottomIfShould, activities]);
const scrollToBottom = React.useCallback(() => {
messageStream.current.scrollTop = messageStream.current.scrollHeight;
setScrolledToBottom(true);
}, []);
const handleChatClick = () => {
setFocusChat(true);
defer(() => setFocusChat(false));
};
return (
<div className="main-chat">
<div onClick={handleChatClick} className="message-stream h-100" ref={messageStream} data-testid="main-div">
<ul className="plain" ref={activitiesList}>
<li>
<p className={styles.tos}>
<button className="btn btn-link" onClick={() => openModal('About')}>
{' '}
<T path="agreement" />
</button>
</p>
</li>
{activities.map((activity, index) => (
<li key={index} className={`activity-item ${activity.type}`}>
<Activity activity={activity} scrollToBottom={scrollToBottomIfShould} />
</li>
))}
</ul>
</div>
<div className="chat-container">
<ChatInput scrollToBottom={scrollToBottom} focusChat={focusChat} />
</div>
</div>
);
};
ActivityList.propTypes = {
activities: PropTypes.array.isRequired,
openModal: PropTypes.func.isRequired,
};
export default ActivityList;
|
docs/src/app/components/pages/components/AppBar/ExampleIcon.js | kittyjumbalaya/material-components-web | import React from 'react';
import AppBar from 'material-ui/AppBar';
/**
* A simple example of `AppBar` with an icon on the right.
* By default, the left icon is a navigation-menu.
*/
const AppBarExampleIcon = () => (
<AppBar
title="Title"
iconClassNameRight="muidocs-icon-navigation-expand-more"
/>
);
export default AppBarExampleIcon;
|
docs/src/IntroductionPage.js | chilts/react-bootstrap | import React from 'react';
import CodeExample from './CodeExample';
import NavMain from './NavMain';
import PageHeader from './PageHeader';
import PageFooter from './PageFooter';
const IntroductionPage = React.createClass({
render() {
return (
<div>
<NavMain activePage="introduction" />
<PageHeader
title="Introduction"
subTitle="The most popular front-end framework, rebuilt for React."/>
<div className="container bs-docs-container">
<div className="row">
<div className="col-md-9" role="main">
<div className="bs-docs-section">
<p className="lead">
React-Bootstrap is a library of reuseable front-end components.
You'll get the look-and-feel of Twitter Bootstrap,
but with much cleaner code, via Facebook's React.js framework.
</p>
<p>
Let's say you want a small button that says "Something",
to trigger the function someCallback.
If you were writing a native application,
you might write something like:
</p>
<div className="highlight">
<CodeExample
mode="javascript"
codeText={
`button(size=SMALL, color=GREEN, text="Something", onClick=someCallback)`
}
/>
</div>
<p>
With the most popular web front-end framework,
Twitter Bootstrap, you'd write this in your HTML:
</p>
<div className="highlight">
<CodeExample
mode="htmlmixed"
codeText={
`<button id="something-btn" type="button" class="btn btn-success btn-sm">
Something
</button>`
}
/>
</div>
<p>
And something like
<code className="js">
$('#something-btn').click(someCallback);
</code>
in your Javascript.
</p>
<p>
By web standards this is quite nice,
but it's still quite nasty.
React-Bootstrap lets you write this:
</p>
<div className="highlight">
<CodeExample
mode="javascript"
codeText={
`<Button bsStyle="success" bsSize="small" onClick={someCallback}>
Something
</Button>`
}
/>
</div>
<p>
The HTML/CSS implementation details are abstracted away,
leaving you with an interface that more closely resembles
what you would expect to write in other programming languages.
</p>
<h2>A better Bootstrap API using React.js</h2>
<p>
The Bootstrap code is so repetitive because HTML and CSS
do not support the abstractions necessary for a nice library
of components. That's why we have to write <code>btn</code>
three times, within an element called <code>button</code>.
</p>
<p>
<strong>
The React.js solution is to write directly in Javascript.
</strong> React takes over the page-rendering entirely.
You just give it a tree of Javascript objects,
and tell it how state is transmitted between them.
</p>
<p>
For instance, we might tell React to render a page displaying
a single button, styled using the handy Bootstrap CSS:
</p>
<div className="highlight">
<CodeExample
mode="javascript"
codeText={
`var button = React.DOM.button({
className: "btn btn-lg btn-success",
children: "Register"
});
React.render(button, mountNode);`
}
/>
</div>
<p>
But now that we're in Javascript, we can wrap the HTML/CSS,
and provide a much better API:
</p>
<div className="highlight">
<CodeExample
mode="javascript"
codeText={
`var button = ReactBootstrap.Button({
bsStyle: "success",
bsSize: "large",
children: "Register"
});
React.render(button, mountNode);`
}
/>
</div>
<p>
React-Bootstrap is a library of such components,
which you can also easily extend and enhance
with your own functionality.
</p>
<h3>JSX Syntax</h3>
<p>
While each React component is really just a Javascript object,
writing tree-structures that way gets tedious.
React encourages the use of a syntactic-sugar called JSX,
which lets you write the tree in an HTML-like syntax:
</p>
<div className="highlight">
<CodeExample
mode="javascript"
codeText={
`var buttonGroupInstance = (
<ButtonGroup>
<DropdownButton bsStyle="success" title="Dropdown">
<MenuItem key="1">Dropdown link</MenuItem>
<MenuItem key="2">Dropdown link</MenuItem>
</DropdownButton>
<Button bsStyle="info">Middle</Button>
<Button bsStyle="info">Right</Button>
</ButtonGroup>
);
React.render(buttonGroupInstance, mountNode);`
}
/>
</div>
<p>
Some people's first impression of React.js is that it seems
messy to mix Javascript and HTML in this way.
However, compare the code required to add
a dropdown button in the example above to the <a
href="http://getbootstrap.com/javascript/#dropdowns">
Bootstrap Javascript</a> and <a
href="http://getbootstrap.com/components/#btn-dropdowns">
Components</a> documentation for creating a dropdown button.
The documentation is split in two because
you have to implement the component in two places
in your code: first you must add the HTML/CSS elements,
and then you must call some Javascript setup
code to wire the component together.
</p>
<p>
The React-Bootstrap component library tries to follow
the React.js philosophy that a single piece of functionality
should be defined in a single place.
View the current React-Bootstrap library on the <a
href="/components.html">components page</a>.
</p>
</div>
</div>
</div>
</div>
<PageFooter />
</div>
);
}
});
export default IntroductionPage;
|
src/routes/dashboard/index.js | zhouchao0924/SLCOPY | import React from 'react'
import PropTypes from 'prop-types'
import { connect } from 'dva'
import { Row, Col, Card } from 'antd'
import { NumberCard, Quote, Sales, Weather, RecentSales, Comments, Completed, Browser, Cpu, User } from './components'
import styles from './index.less'
import { color } from '../../utils'
const bodyStyle = {
bodyStyle: {
height: 432,
background: '#fff',
},
}
function Dashboard ({ dashboard }) {
const { weather, sales, quote, numbers, recentSales, comments, completed, browser, cpu, user } = dashboard
const numberCards = numbers.map((item, key) => <Col key={key} lg={6} md={12}>
<NumberCard {...item} />
</Col>)
return (
<Row gutter={24}>
{numberCards}
<Col lg={18} md={24}>
<Card bordered={false} bodyStyle={{
padding: '24px 36px 24px 0',
}}>
<Sales data={sales} />
</Card>
</Col>
<Col lg={6} md={24}>
<Row gutter={24}>
<Col lg={24} md={12}>
<Card bordered={false} className={styles.weather} bodyStyle={{
padding: 0,
height: 204,
background: color.blue,
}}>
<Weather {...weather} />
</Card>
</Col>
<Col lg={24} md={12}>
<Card bordered={false} className={styles.quote} bodyStyle={{
padding: 0,
height: 204,
background: color.peach,
}}>
<Quote {...quote} />
</Card>
</Col>
</Row>
</Col>
<Col lg={12} md={24}>
<Card bordered={false} {...bodyStyle}>
<RecentSales data={recentSales} />
</Card>
</Col>
<Col lg={12} md={24}>
<Card bordered={false} {...bodyStyle}>
<Comments data={comments} />
</Card>
</Col>
<Col lg={24} md={24}>
<Card bordered={false} bodyStyle={{
padding: '24px 36px 24px 0',
}}>
<Completed data={completed} />
</Card>
</Col>
<Col lg={8} md={24}>
<Card bordered={false} {...bodyStyle}>
<Browser data={browser} />
</Card>
</Col>
<Col lg={8} md={24}>
<Card bordered={false} {...bodyStyle}>
<Cpu {...cpu} />
</Card>
</Col>
<Col lg={8} md={24}>
<Card bordered={false} bodyStyle={{ ...bodyStyle.bodyStyle, padding: 0 }}>
<User {...user} />
</Card>
</Col>
</Row>
)
}
Dashboard.propTypes = {
dashboard: PropTypes.object,
}
export default connect(({ dashboard }) => ({ dashboard }))(Dashboard)
|
src/js/components/icons/base/Bookmark.js | linde12/grommet | // (C) Copyright 2014-2015 Hewlett Packard Enterprise Development LP
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import classnames from 'classnames';
import CSSClassnames from '../../../utils/CSSClassnames';
import Intl from '../../../utils/Intl';
import Props from '../../../utils/Props';
const CLASS_ROOT = CSSClassnames.CONTROL_ICON;
const COLOR_INDEX = CSSClassnames.COLOR_INDEX;
export default class Icon extends Component {
render () {
const { className, colorIndex } = this.props;
let { a11yTitle, size, responsive } = this.props;
let { intl } = this.context;
const classes = classnames(
CLASS_ROOT,
`${CLASS_ROOT}-bookmark`,
className,
{
[`${CLASS_ROOT}--${size}`]: size,
[`${CLASS_ROOT}--responsive`]: responsive,
[`${COLOR_INDEX}-${colorIndex}`]: colorIndex
}
);
a11yTitle = a11yTitle || Intl.getMessage(intl, 'bookmark');
const restProps = Props.omit(this.props, Object.keys(Icon.propTypes));
return <svg {...restProps} version="1.1" viewBox="0 0 24 24" width="24px" height="24px" role="img" className={classes} aria-label={a11yTitle}><polygon fill="none" stroke="#000" strokeWidth="2" points="5 1 5 22 12 17 19 22 19 1"/></svg>;
}
};
Icon.contextTypes = {
intl: PropTypes.object
};
Icon.defaultProps = {
responsive: true
};
Icon.displayName = 'Bookmark';
Icon.icon = true;
Icon.propTypes = {
a11yTitle: PropTypes.string,
colorIndex: PropTypes.string,
size: PropTypes.oneOf(['xsmall', 'small', 'medium', 'large', 'xlarge', 'huge']),
responsive: PropTypes.bool
};
|
src/routes.js | hdngr/mantenuto | import React from 'react';
import { IndexRoute, Route } from 'react-router';
import {
App,
Home,
Profile,
Talk,
Listen,
Register,
Registered,
Login,
Rooms,
NotFound,
Password
} from 'modules';
import { TryAuth, RequireLoggedIn, RequireNotLoggedIn } from 'modules/Auth';
const Routes = () =>
(
<Route path='/' component={App}>
<Route component={TryAuth}>
{/* <Route onEnter={tryAuth} path="/" component={App}> */}
<IndexRoute component={Home} />
{/* Routes requiring login */}
{/* <Route onEnter={requireLogin}> */}
<Route component={RequireLoggedIn}>
<Route path='profile' component={Profile} />
{ Talk }
{ Listen }
{/* <Route path="talk" component={Talk} />
<Route path="listen" component={Listen} /> */}
{ Rooms }
{/* <Route path="rooms/:slug" component={Room} /> */}
{/* <Route path="loginSuccess" component={LoginSuccess} /> */}
</Route>
{/* Routes disallow login */}
<Route component={RequireNotLoggedIn}>
{ Login }
{ Password }
{ Register }
<Route path='registered' component={Registered} />
</Route>
{/* Catch all route */}
<Route path='*' component={NotFound} status={404} />
</Route>
</Route>
);
export default Routes;
|
app/javascript/mastodon/components/status.js | pixiv/mastodon | import React from 'react';
import Immutable from 'immutable';
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 { 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 default class Status extends ImmutablePureComponent {
static contextTypes = {
router: PropTypes.object,
pawooPushHistory: PropTypes.func,
};
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,
onPin: PropTypes.func,
intersectionObserverWrapper: PropTypes.object,
hidden: PropTypes.bool,
onMoveUp: PropTypes.func,
onMoveDown: PropTypes.func,
pawooMediaScale: PropTypes.string,
pawooWideMedia: PropTypes.bool,
};
// 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 = (e) => {
if (!this.context.router) {
return;
}
const { status } = this.props;
const statusId = status.getIn(['reblog', 'id'], status.get('id'));
const path = `/statuses/${statusId}`;
const isApple = /Mac|iPod|iPhone|iPad/.test(navigator.platform);
const pawooOtherColumn = (!isApple && e.ctrlKey) || (isApple && e.metaKey);
this.context.pawooPushHistory(path, pawooOtherColumn);
}
handleAccountClick = (e) => {
if (this.context.router && e.button === 0) {
const id = e.currentTarget.getAttribute('data-id');
e.preventDefault();
const path = `/accounts/${id}`;
this.context.pawooPushHistory(path);
}
}
handleExpandedToggle = () => {
this.props.onToggleHidden(this._properStatus());
};
renderLoadingMediaGallery = () => {
return <div className='media_gallery' style={{ height: 132 }} />;
}
renderLoadingVideoPlayer = () => {
return <div className='media-spoiler-video' style={{ height: 132 }} />;
}
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 = () => {
const statusId = this._properStatus().get('id');
this.context.pawooPushHistory(`/statuses/${statusId}`);
}
handleHotkeyOpenProfile = () => {
this.context.pawooPushHistory(`/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());
}
handleHotkeyPawooOpenOtherColumn = () => {
const statusId = this._properStatus().get('id');
this.context.pawooPushHistory(`/statuses/${statusId}`, true);
}
_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;
const { hidden, featured } = this.props;
let { status, account, pawooMediaScale, pawooWideMedia, ...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 (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>
);
account = status.get('account');
status = status.get('reblog');
}
let attachments = status.get('media_attachments');
if (attachments.size === 0 && status.getIn(['pixiv_cards'], Immutable.List()).size > 0) {
attachments = status.get('pixiv_cards').map(card => {
return Immutable.fromJS({
id: Math.random().toString(),
preview_url: card.get('image_url'),
remote_url: '',
text_url: card.get('url'),
type: 'image',
url: card.get('image_url'),
});
});
}
if (attachments.size > 0) {
if (this.props.muted || attachments.some(item => item.get('type') === 'unknown')) {
media = (
<AttachmentList
compact
media={attachments}
/>
);
} else if (attachments.getIn([0, 'type']) === 'video') {
const video = attachments.first();
media = (
<Bundle fetchComponent={Video} loading={this.renderLoadingVideoPlayer} >
{Component => (
<Component
preview={video.get('preview_url')}
src={video.get('url')}
height={229}
inline
sensitive={status.get('sensitive')}
onOpenVideo={this.handleOpenVideo}
/>
)}
</Bundle>
);
} else {
media = (
<Bundle fetchComponent={MediaGallery} loading={this.renderLoadingMediaGallery}>
{Component => <Component media={attachments} sensitive={status.get('sensitive')} onOpenMedia={this.props.onOpenMedia} pawooOnClick={this.handleClick} pawooScale={pawooMediaScale} pawooWide={pawooWideMedia} />}
</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,
pawooOpenOtherColumn: this.handleHotkeyPawooOpenOtherColumn,
};
return (
<HotKeys handlers={handlers}>
<div className={classNames('status__wrapper', `status__wrapper-${status.get('visibility')}`, { focusable: !this.props.muted })} tabIndex={this.props.muted ? null : 0} data-featured={featured ? 'true' : null}>
{prepend}
<div className={classNames('status', `status-${status.get('visibility')}`, { muted: this.props.muted })} data-id={status.get('id')}>
<div className='status__info'>
<a href={status.get('url')} className='status__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/docs/examples/Promotion/ExamplePromotion.js | undefinedist/sicario | import React from 'react'
import Promotion from 'sicario/Promotion'
/** With a custom message: */
export default function ExamplePromotion() {
return (
<div>
{promotions.map((props, index) => (
<Promotion {...props} {...promotionAttr} key={`promotion-${index}`} index={index} />
))}
</div>
)
}
const promotionAttr = {
title: {
titleSizes: [8],
titleColor: '#ea9a4c',
bold: 'normal',
titlePbs: [1],
},
description: {
descriptionSizes: [2],
descriptionColor: 'black',
bold: 'normal',
descriptionPbs: [1],
},
}
const promotions = [
{
image: 'http://via.placeholder.com/400x300',
titleText: 'RUN\nAND FLY',
descriptionText:
'๊ฐํ๋ฅด์ง ์์ ๊ฒฝ์ฌ๋ฉด์ ์กฐ๊ธ ๋ฐ์ด ๋ด๋ ค๊ฐ๋ฉด ๊ธ๋ผ์ด๋์ ๊ณต๊ธฐ๊ฐ ์ฐจ๋ฉฐ ์ฌ๋ฌ๋ถ๊ณผ ํ์ผ๋ฟ์ ๊ฐ๋ณ๊ฒ ๊ณต์ค์ผ๋ก ๋์์ค๋๋ค. ์ฐฉ๋ฅ ๋ฐ๋ก ์ , ๊ผฟ๊ผฟํ ์์ธ๋ฅผ ์ทจํ๊ฒ ๋๋ฉฐ ๊ณง ๋ถ๋๋ฝ๊ฒ ๋ฐ์ ๋๋๊ฒ ๋ฉ๋๋ค. ๋นํ์ด ์ข
๋ฃ๋๋ ์ฐฉ๋ฅ์ฅ์ ์ธํฐ๋ผ์ผ์ ์ค์ ์๋ ๋ฐญ ์
๋๋ค.',
},
{
image: 'http://via.placeholder.com/400x300',
titleText: 'SAFE\nTHRILLER',
descriptionText:
'์ค์นด์ด์์ฆ์ ๋ชจ๋ ํ์ผ๋ฟ๋ค์ SHPA(์ค์์ค ํ๊ธ๋ผ์ด๋ฉ, ํจ๋ฌ๊ธ๋ผ์ด๋ฉ ํํ)์์ ๊ณต์์ ์ผ๋ก ๊ฒ์ฆ ๋ฐ์์ผ๋ฉฐ ๊ณ ๋์ด๋์ ํ๋ จ์ ํต๊ณผํ์์ต๋๋ค. ๋ค๋
๊ฐ์ ๋นํ ๊ฒฝํ์ ํตํ ๋
ธํ์ฐ์ ๋นํ์คํฌ๋ก ์ ํ๋์์ต๋๋ค. ์ด๋ ์์ฌ์ ์์ ์ฑ๊ณผ ์ ๋ฌธ์ฑ์ด ์ต์์์ ํ๊ฐ๋ฅผ ๋ฐ๋ ์ด์ ์
๋๋ค.',
},
]
|
src/components/auth/signup.js | camboio/ibis | import React from 'react';
import { reduxForm } from 'redux-form';
import * as actions from '../../actions';
class Signup extends React.Component {
handleFormSubmit(formProps){
this.props.signupUser(formProps);
}
renderAlert(){
if(this.props.errorMessage){
return (
<div className="alert alert-danger">
<strong>Oops!</strong> {this.props.errorMessage}
</div>
);
}
}
render(){
const { handleSubmit, fields: { email, password, passwordConfirm } } = this.props;
return(
<form onSubmit={handleSubmit(this.handleFormSubmit.bind(this))}>
<fieldset className="form-group">
<label>Email:</label>
<input {...email} className="form-control" />
{ email.touched && email.error && <div className="error">{email.error}</div>}
</fieldset>
<fieldset className="form-group">
<label>Password:</label>
<input {...password} type="password" className="form-control" />
{ password.touched && password.error && <div className="error">{password.error}</div>}
</fieldset>
<fieldset className="form-group">
<label>Confirm Password:</label>
<input {...passwordConfirm} type="password" className="form-control" />
{ passwordConfirm.touched && passwordConfirm.error && <div className="error">{passwordConfirm.error}</div>}
</fieldset>
{ this.renderAlert() }
<button action="submit" className="btn btn-primary">Sign Up</button>
</form>
);
}
}
function mapStateToProps(state){
return { errorMessage: state.auth.error };
}
function validate(formProps){
const errors = {};
errors.email = (!formProps.email) ? 'Please enter an email' : '';
errors.password = (!formProps.password) ? 'Please enter a password' : '';
errors.passwordConfirm = (!formProps.passwordConfirm) ? 'Please confirm password' : '';
if(formProps.password !== formProps.passwordConfirm){
errors.password = 'Passwords must match';
}
return errors;
}
export default reduxForm({
form: 'signup',
fields: ['email', 'password', 'passwordConfirm'],
validate
}, mapStateToProps, actions)(Signup);
|
react/features/base/react/components/web/Text.js | bgrozev/jitsi-meet | import React, { Component } from 'react';
/**
* Implements a React/Web {@link Component} for displaying text similar to React
* Native's {@code Text} in order to faciliate cross-platform source code.
*
* @extends Component
*/
export default class Text extends Component {
/**
* Implements React's {@link Component#render()}.
*
* @inheritdoc
* @returns {ReactElement}
*/
render() {
return React.createElement('span', this.props);
}
}
|
React.WebPack.Init/src/main.js | yodfz/JS | // ๆ ธๅฟ
import React from 'react';
import ReactDom from 'react-dom';
// UI
import HelloWorld from './components/HelloWorld';
// class App extends React.Component {
// render() {
// return (<h1>hello world</h1>);
// };
// }
// const App = () => <h1>hello world,const!</h1>;
// export default helloworld;
console.log(HelloWorld);
console.log(React);
ReactDom.render(<HelloWorld />, window.document.querySelector('app'));
|
packages/veritone-react-common/src/components/DelayedProgress/index.js | veritone/veritone-sdk | // https://material-ui.com/demos/progress/#delaying-appearance
// when props.loading is set to true, will delay for props.delay ms before
// showing a loading indicator.
import React from 'react';
import { number, bool, objectOf, any } from 'prop-types';
import Fade from '@material-ui/core/Fade';
import CircularProgress from '@material-ui/core/CircularProgress';
export default class DelayedProgress extends React.Component {
static propTypes = {
loading: bool,
delay: number,
circularProgressProps: objectOf(any)
};
static defaultProps = {
delay: 800,
loading: false
};
render() {
return (
<Fade
in={this.props.loading}
style={{
transitionDelay: this.props.loading ? `${this.props.delay}ms` : '0ms'
}}
unmountOnExit
>
<CircularProgress {...this.props.circularProgressProps} />
</Fade>
);
}
}
|
src/frontend/src/components/LegislatorList.js | open-austin/influence-texas | import React from 'react'
import PaginatedList from 'components/PaginatedList'
import { ImageSquare } from 'styles'
import { capitalize } from 'utils'
import Typography from '@material-ui/core/Typography'
const PARTIES = {
R: 'Republican',
D: 'Democrat',
I: 'Independent',
}
export default function LegislatorsList({
data,
nestedUnder = 'legislators',
...props
}) {
return (
<PaginatedList
{...props}
url="legislators/legislator"
data={data}
emptyState={<div>No legislators found</div>}
nestedUnder={nestedUnder}
columns={[
{
render: (rowData) => (
<div style={{ display: 'flex' }}>
<ImageSquare photoUrl={rowData.node.photoUrl} />
<div style={{ margin: '0 1em' }}>
<Typography>{rowData.node.name}</Typography>
<Typography variant="subtitle2">
{capitalize(rowData.node.chamber)}
</Typography>
<Typography variant="subtitle2">
{PARTIES[rowData.node.party] || rowData.node.party}
</Typography>
</div>
</div>
),
},
{
field: 'node.party',
render: (rowData) => (
<div style={{ textAlign: 'right' }}>
District {rowData.node.district}
</div>
),
},
]}
/>
)
}
|
src/components/layer/layer.js | miaoji/guojibackend | import { Modal, message } from 'antd'
import React from 'react'
import ReactDOM from 'react-dom'
import classnames from 'classnames'
import styles from './layer.less'
const { info, success, error, warning, confirm } = Modal
const layer = {
prefixCls: 'ant-layer',
index: 1,
info,
success,
error,
warning,
confirm,
}
layer.close = (index) => new Promise((resolve, reject) => {
const { prefixCls } = layer
let div = document.getElementById(`${prefixCls}-reference-${index}`)
if (index === undefined) {
const references = document.querySelectorAll(`.${prefixCls}-reference`)
div = references[references.length - 1]
}
if (!div) {
message.error('ๅ
ณ้ญๅคฑ่ดฅ๏ผๆชๆพๅฐDom')
return
}
const unmountResult = ReactDOM.unmountComponentAtNode(div)
if (unmountResult && div.parentNode) {
div.parentNode.removeChild(div)
resolve(index)
} else {
reject(index)
}
})
layer.closeAll = () => {
const { prefixCls } = layer
const references = document.querySelectorAll(`.${prefixCls}-reference`)
let i = 0
while (i < references.length) {
layer.close()
i++
}
}
layer.open = (config) => {
const props = Object.assign({}, config)
const { content, ...modalProps } = props
const { className, wrapClassName = '', verticalCenter = true } = modalProps
const { prefixCls } = layer
const index = layer.index++
let div = document.createElement('div')
div.id = `${prefixCls}-reference-${index}`
div.className = `${prefixCls}-reference`
document.body.appendChild(div)
ReactDOM.render(
<Modal
visible
title="Title"
transitionName="zoom"
maskTransitionName="fade"
onCancel={() => {
layer.close(index)
}}
onOk={() => {
layer.close(index)
}}
{...modalProps}
wrapClassName={classnames({ [styles.verticalCenter]: verticalCenter, [wrapClassName]: true })}
className={classnames(prefixCls, className, [`${prefixCls}-${index}`])}
>
<div className={`${prefixCls}-body-wrapper`} style={{ maxHeight: document.body.clientHeight - 256 }}>
{content}
</div>
</Modal>, div)
return index
}
export default layer
|
js/__tests__/helper.js | erik-sn/webapp | import chai from 'chai'; // eslint-disable-line no-unused-vars
import { JSDOM } from 'jsdom';
import React from 'react';
import { Provider } from 'react-redux';
import { applyMiddleware, createStore } from 'redux';
import reducers from '../src/reducers/root_reducer';
// jsdom configuration
const jsdom = new JSDOM('<!doctype html><html><body></body></html>');
const window = jsdom.window;
global.window = window;
global.document = window.document;
global.navigator = { userAgent: 'node.js' };
global.HTMLElement = global.window.HTMLElement;
// necessary for promise resolution
const createStoreWithMiddleware = applyMiddleware()(createStore);
export const store = createStoreWithMiddleware(reducers);
export function reduxWrap(component) {
return (
<Provider store={store}>
{component}
</Provider>
);
}
|
src/widgets/ReactApp/index.js | cncjs/cncjs-widget-boilerplate | import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
export default () => {
ReactDOM.render(
<App />,
document.getElementById('viewport')
);
};
|
recipe-server/client/control/components/NoMatch.js | Osmose/normandy | import React from 'react';
import { Link } from 'react-router';
/**
* 404-ish view shown for routes that don't match any valid route.
*/
export default function NoMatch() {
return (
<div className="no-match fluid-8">
<h2>Page Not Found</h2>
<p>Sorry, we could not find the page you're looking for.</p>
<p><Link to="/control/">Click here to return to the control index.</Link></p>
</div>
);
}
|
src/components/MainHeader/GenericDropdown.js | falmar/react-adm-lte | import React from 'react'
import PropTypes from 'prop-types'
import Link from '../../utils/Link'
import Dropdown from './Dropdown'
import DropdownToggle from './DropdownToggle'
import DropdownMenu from './DropdownMenu'
const GenericDropdown = (props) => {
const {className, open, onToggle, children} = props
const {iconClass, labelClass, label} = props
const {header, footer, onClickFooter} = props
return (
<Dropdown className={className} open={open} onToggle={onToggle}>
<DropdownToggle onToggle={onToggle}>
<i className={iconClass} />
<span className={labelClass}>{label}</span>
</DropdownToggle>
<DropdownMenu>
<li className='header'>{header}</li>
<li>
<ul className='menu'>
{children}
</ul>
</li>
<li className='footer'>
<Link onClick={onClickFooter}>{footer}</Link>
</li>
</DropdownMenu>
</Dropdown>
)
}
GenericDropdown.propTypes = {
className: PropTypes.string,
open: PropTypes.bool,
iconClass: PropTypes.string,
labelClass: PropTypes.string,
label: PropTypes.oneOfType([
PropTypes.number,
PropTypes.string
]),
onToggle: PropTypes.func,
header: PropTypes.string,
footer: PropTypes.string,
onClickFooter: PropTypes.func,
children: PropTypes.node
}
export default GenericDropdown
|
app/javascript/mastodon/features/home_timeline/components/column_settings.js | tateisu/mastodon | import React from 'react';
import PropTypes from 'prop-types';
import ImmutablePropTypes from 'react-immutable-proptypes';
import { injectIntl, FormattedMessage } from 'react-intl';
import SettingToggle from '../../notifications/components/setting_toggle';
export default @injectIntl
class ColumnSettings extends React.PureComponent {
static propTypes = {
settings: ImmutablePropTypes.map.isRequired,
onChange: PropTypes.func.isRequired,
intl: PropTypes.object.isRequired,
};
render () {
const { settings, onChange } = this.props;
return (
<div>
<span className='column-settings__section'><FormattedMessage id='home.column_settings.basic' defaultMessage='Basic' /></span>
<div className='column-settings__row'>
<SettingToggle prefix='home_timeline' settings={settings} settingPath={['shows', 'reblog']} onChange={onChange} label={<FormattedMessage id='home.column_settings.show_reblogs' defaultMessage='Show boosts' />} />
</div>
<div className='column-settings__row'>
<SettingToggle prefix='home_timeline' settings={settings} settingPath={['shows', 'reply']} onChange={onChange} label={<FormattedMessage id='home.column_settings.show_replies' defaultMessage='Show replies' />} />
</div>
</div>
);
}
}
|
src/components/FuelSavingsResults.js | redsheep-io/redsheep.io | import React from 'react';
import PropTypes from 'prop-types';
import NumberFormatter from '../utils/numberFormatter';
// This is a stateless functional component. (Also known as pure or dumb component)
// More info: https://facebook.github.io/react/blog/2015/10/07/react-v0.14.html#stateless-functional-components
// And https://medium.com/@joshblack/stateless-components-in-react-0-14-f9798f8b992d
// Props are being destructured below to extract the savings object to shorten calls within component.
const FuelSavingsResults = ({savings}) => {
// console.log(savings);
// console.log("typeof", typeof(savings.monthly));
const savingsExist = NumberFormatter.scrubFormatting(savings.monthly) > 0;
const savingsClass = savingsExist ? 'savings' : 'loss';
const resultLabel = savingsExist ? 'Savings' : 'Loss';
// You can even exclude the return statement below if the entire component is
// composed within the parentheses. Return is necessary here because some
// variables are set above.
return (
<table>
<tbody>
<tr>
<td className="fuel-savings-label">{resultLabel}</td>
<td>
<table>
<tbody>
<tr>
<td>Monthly</td>
<td>1 Year</td>
<td>3 Year</td>
</tr>
<tr>
<td className={savingsClass}>{savings.monthly}</td>
<td className={savingsClass}>{savings.annual}</td>
<td className={savingsClass}>{savings.threeYear}</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
);
};
// Note that this odd style is utilized for propType validation for now. Must be defined *after*
// the component is defined, which is why it's separate and down here.
FuelSavingsResults.propTypes = {
savings: PropTypes.object.isRequired
};
export default FuelSavingsResults;
|
app/screens/MatchesValidation/index.js | mbernardeau/Road-to-Russia-2018 | import React from 'react'
// eslint-disable-next-line react/prefer-stateless-function
export default class MatchesValidation extends React.PureComponent {
render() {
return <h1>Ceci sera la page de validation des matches.</h1>
}
}
|
examples/01 Dustbin/Single Target/__tests__/Box-test.js | arnif/react-dnd | import React from 'react';
import TestUtils from 'react/lib/ReactTestUtils';
import wrapInTestContext from '../../../shared/wrapInTestContext';
import expect from 'expect';
import Box from '../Box';
describe('Box', () => {
it('can be tested independently', () => {
// Obtain the reference to the component before React DnD wrapping
const OriginalBox = Box.DecoratedComponent;
// Stub the React DnD connector functions with an identity function
const identity = x => x;
// Render with one set of props and test
let root = TestUtils.renderIntoDocument(
<OriginalBox name='test'
connectDragSource={identity} />
);
let div = TestUtils.findRenderedDOMComponentWithTag(root, 'div');
expect(div.props.style.opacity).toEqual(1);
// Render with another set of props and test
root = TestUtils.renderIntoDocument(
<OriginalBox name='test'
connectDragSource={identity}
isDragging />
);
div = TestUtils.findRenderedDOMComponentWithTag(root, 'div');
expect(div.props.style.opacity).toEqual(0.4);
});
it('can be tested with the testing backend', () => {
// Render with the testing backend
const BoxContext = wrapInTestContext(Box);
const root = TestUtils.renderIntoDocument(<BoxContext name='test' />);
// Obtain a reference to the backend
const backend = root.getManager().getBackend();
// Check that the opacity is 1
let div = TestUtils.findRenderedDOMComponentWithTag(root, 'div');
expect(div.props.style.opacity).toEqual(1);
// Find the drag source ID and use it to simulate the dragging state
const box = TestUtils.findRenderedComponentWithType(root, Box);
backend.simulateBeginDrag([box.getHandlerId()]);
// Verify that the div changed its opacity
div = TestUtils.findRenderedDOMComponentWithTag(root, 'div');
expect(div.props.style.opacity).toEqual(0.4);
});
}); |
node_modules/react-bootstrap/es/Tabs.js | mohammed52/something.pk | import _extends from 'babel-runtime/helpers/extends';
import _objectWithoutProperties from 'babel-runtime/helpers/objectWithoutProperties';
import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn';
import _inherits from 'babel-runtime/helpers/inherits';
import React from 'react';
import PropTypes from 'prop-types';
import requiredForA11y from 'prop-types-extra/lib/isRequiredForA11y';
import uncontrollable from 'uncontrollable';
import Nav from './Nav';
import NavItem from './NavItem';
import UncontrolledTabContainer from './TabContainer';
import TabContent from './TabContent';
import { bsClass as setBsClass } from './utils/bootstrapUtils';
import ValidComponentChildren from './utils/ValidComponentChildren';
var TabContainer = UncontrolledTabContainer.ControlledComponent;
var propTypes = {
/**
* Mark the Tab with a matching `eventKey` as active.
*
* @controllable onSelect
*/
activeKey: PropTypes.any,
/**
* Navigation style
*/
bsStyle: PropTypes.oneOf(['tabs', 'pills']),
animation: PropTypes.bool,
id: requiredForA11y(PropTypes.oneOfType([PropTypes.string, PropTypes.number])),
/**
* Callback fired when a Tab is selected.
*
* ```js
* function (
* Any eventKey,
* SyntheticEvent event?
* )
* ```
*
* @controllable activeKey
*/
onSelect: PropTypes.func,
/**
* Wait until the first "enter" transition to mount tabs (add them to the DOM)
*/
mountOnEnter: PropTypes.bool,
/**
* Unmount tabs (remove it from the DOM) when it is no longer visible
*/
unmountOnExit: PropTypes.bool
};
var defaultProps = {
bsStyle: 'tabs',
animation: true,
mountOnEnter: false,
unmountOnExit: false
};
function getDefaultActiveKey(children) {
var defaultActiveKey = void 0;
ValidComponentChildren.forEach(children, function (child) {
if (defaultActiveKey == null) {
defaultActiveKey = child.props.eventKey;
}
});
return defaultActiveKey;
}
var Tabs = function (_React$Component) {
_inherits(Tabs, _React$Component);
function Tabs() {
_classCallCheck(this, Tabs);
return _possibleConstructorReturn(this, _React$Component.apply(this, arguments));
}
Tabs.prototype.renderTab = function renderTab(child) {
var _child$props = child.props,
title = _child$props.title,
eventKey = _child$props.eventKey,
disabled = _child$props.disabled,
tabClassName = _child$props.tabClassName;
if (title == null) {
return null;
}
return React.createElement(
NavItem,
{
eventKey: eventKey,
disabled: disabled,
className: tabClassName
},
title
);
};
Tabs.prototype.render = function render() {
var _props = this.props,
id = _props.id,
onSelect = _props.onSelect,
animation = _props.animation,
mountOnEnter = _props.mountOnEnter,
unmountOnExit = _props.unmountOnExit,
bsClass = _props.bsClass,
className = _props.className,
style = _props.style,
children = _props.children,
_props$activeKey = _props.activeKey,
activeKey = _props$activeKey === undefined ? getDefaultActiveKey(children) : _props$activeKey,
props = _objectWithoutProperties(_props, ['id', 'onSelect', 'animation', 'mountOnEnter', 'unmountOnExit', 'bsClass', 'className', 'style', 'children', 'activeKey']);
return React.createElement(
TabContainer,
{
id: id,
activeKey: activeKey,
onSelect: onSelect,
className: className,
style: style
},
React.createElement(
'div',
null,
React.createElement(
Nav,
_extends({}, props, {
role: 'tablist'
}),
ValidComponentChildren.map(children, this.renderTab)
),
React.createElement(
TabContent,
{
bsClass: bsClass,
animation: animation,
mountOnEnter: mountOnEnter,
unmountOnExit: unmountOnExit
},
children
)
)
);
};
return Tabs;
}(React.Component);
Tabs.propTypes = propTypes;
Tabs.defaultProps = defaultProps;
setBsClass('tab', Tabs);
export default uncontrollable(Tabs, { activeKey: 'onSelect' }); |
node_modules/babel-plugin-react-transform/test/fixtures/code-class-extends-component-with-render-method/expected.js | rafser01/installer_electron | import _transformLib from 'transform-lib';
const _components = {
Foo: {
displayName: 'Foo'
}
};
const _transformLib2 = _transformLib({
filename: '%FIXTURE_PATH%',
components: _components,
locals: [],
imports: []
});
function _wrapComponent(id) {
return function (Component) {
return _transformLib2(Component, id);
};
}
import React, { Component } from 'react';
const Foo = _wrapComponent('Foo')(class Foo extends Component {
render() {}
});
|
src/svg-icons/communication/phonelink-erase.js | mit-cml/iot-website-source | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let CommunicationPhonelinkErase = (props) => (
<SvgIcon {...props}>
<path d="M13 8.2l-1-1-4 4-4-4-1 1 4 4-4 4 1 1 4-4 4 4 1-1-4-4 4-4zM19 1H9c-1.1 0-2 .9-2 2v3h2V4h10v16H9v-2H7v3c0 1.1.9 2 2 2h10c1.1 0 2-.9 2-2V3c0-1.1-.9-2-2-2z"/>
</SvgIcon>
);
CommunicationPhonelinkErase = pure(CommunicationPhonelinkErase);
CommunicationPhonelinkErase.displayName = 'CommunicationPhonelinkErase';
CommunicationPhonelinkErase.muiName = 'SvgIcon';
export default CommunicationPhonelinkErase;
|
test/components/Counter.spec.js | r24y/delta-calibration | /* eslint no-unused-expressions: 0 */
import { expect } from 'chai';
import { spy } from 'sinon';
import jsdom from 'mocha-jsdom';
import React from 'react';
import TestUtils from 'react-addons-test-utils';
import Counter from '../../src/components/Counter';
function setup() {
const actions = {
increment: spy(),
incrementIfOdd: spy(),
incrementAsync: spy(),
decrement: spy()
};
const component = TestUtils.renderIntoDocument(<Counter counter={1} {...actions} />);
return {
component: component,
actions: actions,
buttons: TestUtils.scryRenderedDOMComponentsWithTag(component, 'button').map(button => {
return button;
}),
p: TestUtils.findRenderedDOMComponentWithTag(component, 'p')
};
}
describe('Counter component', () => {
jsdom();
it('should display count', () => {
const { p } = setup();
expect(p.textContent).to.match(/^Clicked: 1 times/);
});
it('first button should call increment', () => {
const { buttons, actions } = setup();
TestUtils.Simulate.click(buttons[0]);
expect(actions.increment.called).to.be.true;
});
it('second button should call decrement', () => {
const { buttons, actions } = setup();
TestUtils.Simulate.click(buttons[1]);
expect(actions.decrement.called).to.be.true;
});
it('third button should call incrementIfOdd', () => {
const { buttons, actions } = setup();
TestUtils.Simulate.click(buttons[2]);
expect(actions.incrementIfOdd.called).to.be.true;
});
it('fourth button should call incrementAsync', () => {
const { buttons, actions } = setup();
TestUtils.Simulate.click(buttons[3]);
expect(actions.incrementAsync.called).to.be.true;
});
});
|
src/modules/universal-discovery/components/tab-content/tab.content.panel.component.js | sunpietro/react-udw | import React from 'react';
import PropTypes from 'prop-types';
import './css/tab.content.panel.component.css';
const TabContentPanelComponent = (props) => {
const attrs = {
id: props.id,
className: 'c-tab-content-panel'
};
if (!props.isVisible) {
attrs.hidden = true;
}
return (
<div {...attrs}>
{props.children}
</div>
);
};
TabContentPanelComponent.propTypes = {
id: PropTypes.string.isRequired,
isVisible: PropTypes.bool.isRequired,
children: PropTypes.any,
maxHeight: PropTypes.number
};
export default TabContentPanelComponent;
|
src/js/components/icons/base/Target.js | linde12/grommet | // (C) Copyright 2014-2015 Hewlett Packard Enterprise Development LP
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import classnames from 'classnames';
import CSSClassnames from '../../../utils/CSSClassnames';
import Intl from '../../../utils/Intl';
import Props from '../../../utils/Props';
const CLASS_ROOT = CSSClassnames.CONTROL_ICON;
const COLOR_INDEX = CSSClassnames.COLOR_INDEX;
export default class Icon extends Component {
render () {
const { className, colorIndex } = this.props;
let { a11yTitle, size, responsive } = this.props;
let { intl } = this.context;
const classes = classnames(
CLASS_ROOT,
`${CLASS_ROOT}-target`,
className,
{
[`${CLASS_ROOT}--${size}`]: size,
[`${CLASS_ROOT}--responsive`]: responsive,
[`${COLOR_INDEX}-${colorIndex}`]: colorIndex
}
);
a11yTitle = a11yTitle || Intl.getMessage(intl, 'target');
const restProps = Props.omit(this.props, Object.keys(Icon.propTypes));
return <svg {...restProps} version="1.1" viewBox="0 0 24 24" width="24px" height="24px" role="img" className={classes} aria-label={a11yTitle}><path fill="none" stroke="#000" strokeWidth="2" d="M23,12 C23,18.075 18.075,23 12,23 C5.925,23 1,18.075 1,12 C1,5.925 5.925,1 12,1 C18.075,1 23,5.925 23,12 L23,12 Z M18,12 C18,8.691 15.309,6 12,6 C8.691,6 6,8.691 6,12 C6,15.309 8.691,18 12,18 C15.309,18 18,15.309 18,12 L18,12 Z M13,12 C13,11.448 12.552,11 12,11 C11.448,11 11,11.448 11,12 C11,12.552 11.448,13 12,13 C12.552,13 13,12.552 13,12 L13,12 Z"/></svg>;
}
};
Icon.contextTypes = {
intl: PropTypes.object
};
Icon.defaultProps = {
responsive: true
};
Icon.displayName = 'Target';
Icon.icon = true;
Icon.propTypes = {
a11yTitle: PropTypes.string,
colorIndex: PropTypes.string,
size: PropTypes.oneOf(['xsmall', 'small', 'medium', 'large', 'xlarge', 'huge']),
responsive: PropTypes.bool
};
|
stories/Stagger.js | unruffledBeaver/react-animation-components | import React from 'react';
import { storiesOf } from '@storybook/react';
import { withKnobs, boolean, number } from '@storybook/addon-knobs';
import { Fade, Stagger } from '../src/index';
const exampleArray = ['Example', 'Example', 'Example', 'Example', 'Example'];
storiesOf('Wrappers/Stagger', module)
.addDecorator(withKnobs)
.add('default', () => (
<Stagger
in={boolean('in', true)}
reverse={boolean('reverse', false)}
chunk={number('chunk', 0)}
>
{exampleArray.map((example, i) => (
<Fade key={`${i}-example`}>
<h1>{example}</h1>
</Fade>
))}
</Stagger>
));
|
examples/03 Nesting/Drag Sources/Container.js | arnif/react-dnd | import React from 'react';
import SourceBox from './SourceBox';
import TargetBox from './TargetBox';
import Colors from './Colors';
import { DragDropContext } from 'react-dnd';
import HTML5Backend from 'react-dnd/modules/backends/HTML5';
@DragDropContext(HTML5Backend)
export default class Container {
render() {
return (
<div style={{ overflow: 'hidden', clear: 'both', margin: '-.5rem' }}>
<div style={{ float: 'left' }}>
<SourceBox color={Colors.BLUE}>
<SourceBox color={Colors.YELLOW}>
<SourceBox color={Colors.YELLOW} />
<SourceBox color={Colors.BLUE} />
</SourceBox>
<SourceBox color={Colors.BLUE}>
<SourceBox color={Colors.YELLOW} />
</SourceBox>
</SourceBox>
</div>
<div style={{ float: 'left', marginLeft: '5rem', marginTop: '.5rem' }}>
<TargetBox />
</div>
</div>
);
}
} |
src/pages/index.js | ScottDowne/donate.mozilla.org | import fs from 'fs';
import React from 'react';
import Optimizely from '../components/optimizely.js';
import OptimizelySubdomain from '../components/optimizelysubdomain.js';
import Path from 'path';
import Pontoon from '../components/pontoon.js';
var Index = React.createClass({
render: function() {
var metaData = this.props.metaData;
var robots = 'index, follow';
var googleFonts = "https://fonts.googleapis.com/css?family=Open+Sans:600,400,300,300italic";
if (metaData.current_url.indexOf("jan-thank-you") !== -1) {
googleFonts = "https://fonts.googleapis.com/css?family=Roboto+Slab:600,400,300,200,100";
}
var localesData = [];
if (this.props.localesInfo.length) {
this.props.localesInfo.forEach(function(locale) {
if (locale === "cs") {
googleFonts += "&subset=latin-ext";
}
localesData.push(fs.readFileSync(Path.join(__dirname, '../../node_modules/react-intl/locale-data/' + locale.split('-')[0] + '.js'), 'utf8'));
});
}
if (metaData.current_url.indexOf('thank-you') !== -1) {
robots = 'noindex, nofollow';
}
var fileHashes = JSON.parse(fs.readFileSync(Path.join(__dirname, '../../public/webpack-assets.json')));
var ga = `
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-49796218-32', 'auto');
ga('send', 'pageview');
`;
var polyfillLocale = "";
if (this.props.locale) {
polyfillLocale = '&locale=' + this.props.locale;
}
var dir = 'ltr';
if (['ar', 'fa', 'he', 'ur'].indexOf(this.props.locale) >= 0) {
dir = 'rtl';
}
return (
<html dir={dir}>
<head>
<meta charSet="UTF-8"/>
<meta httpEquiv="X-UA-Compatible" content="IE=edge"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<meta name='robots' content={robots}/>
<meta property="og:type" content="website" />
<meta property="og:title" content={metaData.title} />
<meta property="og:site_name" content={metaData.site_name} />
<meta property="og:url" content={metaData.site_url} />
<meta property="og:description" content={metaData.desc} />
<meta property="og:image" content={metaData.facebook_image} />
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:site" content="@mozilla" />
<meta name="twitter:title" content={metaData.title} />
<meta name="twitter:description" content={metaData.desc} />
<meta name="twitter:image" content={metaData.twitter_image} />
<link rel="preconnect" href="https://www.google-analytics.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" />
<link rel="preconnect" href="https://206878104.log.optimizely.com" />
<title>donate.mozilla.org | {metaData.site_title}</title>
<OptimizelySubdomain/>
<Optimizely/>
<link rel="icon" href={this.props.favicon} type="image/x-icon"/>
<link rel="stylesheet" href={'/' + fileHashes.main.css}/>
<script dangerouslySetInnerHTML={{__html: ga}}></script>
{
localesData.map((localeData, index) => {
return (
<script key={"localeData-" + index} dangerouslySetInnerHTML={{__html: localeData}}></script>
);
})
}
</head>
<body>
<div id="my-app" dangerouslySetInnerHTML={{__html: this.props.markup}}></div>
<link rel="stylesheet" href={googleFonts}/>
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css" rel="stylesheet"/>
<script src={'/api/polyfill.js?features=Event,CustomEvent,Promise' + polyfillLocale}></script>
<script src={'/' + fileHashes.main.js} ></script>
<Pontoon/>
<script src="https://checkout.stripe.com/checkout.js"></script>
<script src="https://c.shpg.org/352/sp.js"></script>
</body>
</html>
);
}
});
module.exports = Index;
|
docs/src/app/components/pages/components/RadioButton/Page.js | ArcanisCz/material-ui | import React from 'react';
import Title from 'react-title-component';
import CodeExample from '../../../CodeExample';
import PropTypeDescription from '../../../PropTypeDescription';
import MarkdownElement from '../../../MarkdownElement';
import radioButtonReadmeText from './README';
import RadioButtonExampleSimple from './ExampleSimple';
import radioButtonExampleSimpleCode from '!raw!./ExampleSimple';
import radioButtonCode from '!raw!material-ui/RadioButton/RadioButton';
import radioButtonGroupCode from '!raw!material-ui/RadioButton/RadioButtonGroup';
const description = 'The second button is selected by default using the `defaultSelected` property of ' +
'`RadioButtonGroup`. The third button is disabled using the `disabled` property of `RadioButton`. The final ' +
'example uses the `labelPosition` property to position the label on the left. ';
const RadioButtonPage = () => (
<div>
<Title render={(previousTitle) => `Radio Button - ${previousTitle}`} />
<MarkdownElement text={radioButtonReadmeText} />
<CodeExample
title="Examples"
description={description}
code={radioButtonExampleSimpleCode}
>
<RadioButtonExampleSimple />
</CodeExample>
<PropTypeDescription header="### RadioButton Properties" code={radioButtonCode} />
<PropTypeDescription header="### RadioButtonGroup Properties" code={radioButtonGroupCode} />
</div>
);
export default RadioButtonPage;
|
addons/themes/solid-state/layouts/Home.js | rendact/rendact | import $ from 'jquery'
import React from 'react';
import gql from 'graphql-tag';
import {graphql} from 'react-apollo';
import moment from 'moment';
import {Link} from 'react-router';
import Menu from '../includes/Menu';
let Home = React.createClass({
componentDidMount(){
require('../assets/css/main.css')
},
handleShowMenu(){
document.body.className = "is-menu-visible";
},
render(){
let {
theConfig,
data,
thePagination,
loadDone
} = this.props
// debugger
return (
<div>
<div id="page-wrapper">
{/* <header id="header" className="alt">*/}
<header id="header" className="">
<h1>
<strong>
<Link to="/">
{theConfig ? theConfig.name : "Rendact"}
</Link>
</strong>
</h1>
<nav id="nav">
<a href="#menu" className="menuToggle" onClick={this.handleShowMenu}><span>Menu</span></a>
</nav>
</header>
<section id="banner">
<div className="inner">
<div className="logo"><img src={ require('images/logo-128.png') } alt="" /></div>
<p>{theConfig ? theConfig.tagline: "hello"}</p>
</div>
</section>
<section id="wrapper">
<div className="wrapper">
<div className="inner">
<section className="features">
{data && data.map((post, index) => (
<article>
<Link className="image" to={"/post/" + post.id}>
<img src={post.imageFeatured ? post.imageFeatured.blobUrl: require('images/logo-128.png') } alt="" />
</Link>
<h3>
<Link className="major" to={"/post/" + post.id}>{post.title && post.title}</Link>
</h3>
<p dangerouslySetInnerHTML={{__html: post.content ? post.content.slice(0, 150):""}} />
<Link className="special" to={"/post/" + post.id}>Continue Reading</Link>
</article>
))}
</section>
<h4 className="major"></h4>
<h2 style={{textAlign: "center"}}>
{this.props.thePagination}
</h2>
</div>
</div>
{/*
{data && data.map((post, index) => (
<section id="one" className={index%2===0 ? "wrapper spotlight style1":"wrapper alt spotlight style2" }>
<div className="inner">
<Link className="image" to={"/post/" + post.id}>
<img src={post.imageFeatured ? post.imageFeatured.blobUrl: require('images/logo-128.png') } alt="" />
</Link>
<div className="content">
<h2>
<Link className="major" to={"/post/" + post.id}>{post.title && post.title}</Link>
</h2>
<p dangerouslySetInnerHTML={{__html: post.content ? post.content.slice(0, 200):""}} />
<Link className="special" to={"/post/" + post.id}>Continue Reading</Link>
</div>
</div>
</section>
))}
*/}
</section>
<section id="footer">
<div className="inner">
<h2 className="major"></h2>
<div className="row">
{this.props.footerWidgets.map((fw, i) => (
<div className="4u 12u$(medium)" key={i}>{fw}</div>
))}
</div>
<ul className="copyright">
<li>© Story based theme</li><li>html5up</li><li>converted by Rendact Team</li>
</ul>
</div>
</section>
</div>
<Menu {...this.props}/>
</div>
)
}
});
export default Home; |
src/renderer/controllers/preferences.js | marcus-sa/Venobo | import {ipcRenderer} from 'electron'
import React from 'react'
import {dispatch} from '../lib/dispatcher'
import PreferencesPage from '../pages/preferences'
// Controls the Preferences page
export default class PreferencesController extends React.Component {
constructor(props) {
super(props)
this.state = {
isMounted: false
}
}
componentWillMount() {
const {state, props} = this
if (state.isMounted) return
// initialize preferences
props.state.window.title = 'Preferences'
props.state.unsaved = Object.assign(props.state.unsaved || {}, {
prefs: Object.assign({}, props.state.saved.prefs)
})
ipcRenderer.send('setAllowNav', false)
callback(null)
this.setState({
isMounted: true
})
}
componentWillUnmount() {
console.log('Preferences controller unmounted')
ipcRenderer.send('setAllowNav', true)
this.save()
}
render() {
return (<PreferencesPage {...this.props} />)
}
// Updates a single property in the UNSAVED prefs
// For example: updatePreferences('foo.bar', 'baz')
// Call save() to save to config.json
update(property, value) {
const path = property.split('.')
let obj = this.props.state.unsaved.prefs
for (let i = 0; i < path.length - 1; i++) {
if (typeof obj[path[i]] === 'undefined') {
obj[path[i]] = {}
}
obj = obj[path[i]]
}
obj[path[i]] = value
}
// All unsaved prefs take effect atomically, and are saved to config.json
save() {
const {unsaved, saved} = this.props.state
if (unsaved.prefs.isFileHandler !== saved.prefs.isFileHandler) {
ipcRenderer.send('setDefaultFileHandler', unsaved.prefs.isFileHandler)
}
if (unsaved.prefs.startup !== saved.prefs.startup) {
ipcRenderer.send('setStartup', unsaved.prefs.startup)
}
saved.prefs = Object.assign(saved.prefs || {}, unsaved.prefs)
dispatch('stateSaveImmediate')
dispatch('checkDownloadPath')
}
}
|
components/base/TopNavigation/TopNavigation.js | CarbonStack/carbonstack | import React from 'react'
import { connect } from 'react-redux'
import { bindActionCreators } from 'redux'
import {
actions as sessionActions
} from '../../../lib/redux/modules/session'
import NewButton from './NewButton'
import LogoLink from './LogoLink'
import Profile from './Profile'
import SignInButton from './SignInButton'
class TopNavigation extends React.PureComponent {
onSignInViaGithubButtonClick = () => {
this.props.actions.requestSignIn('github')
}
onSignOutButtonClick = () => {
this.props.actions.requestSignOut()
}
renderLeft () {
const {
route
} = this.props
switch (route.pathname) {
case '/issues/show':
case '/issues/new':
case '/issues/edit':
return (
<div className='left'>
<LogoLink
href={{
pathname: '/groups/show',
query: {
groupUniqueName: route.query.groupUniqueName
}
}}
as={`/g/${route.query.groupUniqueName}`}
>
/g/{route.query.groupUniqueName}
</LogoLink>
</div>
)
}
return (
<div className='left'>
<LogoLink href='/'>
Carbon Stack
</LogoLink>
</div>
)
}
render () {
const {
route,
session
} = this.props
return <nav>
<div className='container'>
{this.renderLeft()}
<div className='right'>
{(route.pathname === '/groups/show' || route.pathname === '/issues') &&
<NewButton route={route} />
}
{this.props.session.user == null ||
<Profile
user={this.props.session.user}
onSignOutButtonClick={this.onSignOutButtonClick}
/>
}
{this.props.session.user == null &&
<SignInButton
onClick={this.onSignInViaGithubButtonClick}
isSigningIn={session.isSigningIn}
/>
}
</div>
</div>
<style jsx>{`
nav {
position: fixed;
top: 0;
left: 0;
right: 0;
z-index: 10;
background-color: rgba(255,255,255,0.8);
height: 50px;
width: 100%;
}
.container {
display: flex;
justify-content: space-between;
}
.right {
display: flex;
}
`}</style>
</nav>
}
}
const mapStateToProps = ({session, route}) => {
return {
session,
route
}
}
const mapDispatchToProps = dispatch => {
return {
actions: bindActionCreators(sessionActions, dispatch)
}
}
export default connect(mapStateToProps, mapDispatchToProps)(TopNavigation)
|
ui/src/pages/Results_test.js | google/personfinder | /*
* Copyright 2019 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import Enzyme from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import toJson from 'enzyme-to-json';
import {createMemoryHistory} from 'history';
import React from 'react';
import {MemoryRouter} from 'react-router';
import Results from './Results';
import RepoHeader from '../components/RepoHeader';
import SearchBar from '../components/SearchBar';
import {mountWithIntl} from '../testing/enzyme-intl-helper';
import {flushPromises} from '../testing/utils';
Enzyme.configure({adapter: new Adapter()});
const REPO_DATA = {repoId: 'albany', title: 'Albany', recordCount: 100,};
const RESULTS_DATA = [
{
personId: '123',
fullNames: ['Fred Fredricks'],
alternateNames: ['Freddy'],
timestampType: 'creation',
timestamp: '2019-05-15T17:12:23.936282Z',
localPhotoUrl: null,
},
{
personId: '321',
fullNames: ['Alan Smith', 'Alan Herbert Smith'],
alternateNames: [],
timestampType: 'update',
timestamp: '2019-05-16T16:35:23.936282Z',
localPhotoUrl: 'http://www.example.com/notevenreallylocal.jpg',
},
]
function setupPageWrapper() {
fetch.mockResponseOnce(JSON.stringify(REPO_DATA));
fetch.mockResponseOnce(JSON.stringify(RESULTS_DATA));
const history = createMemoryHistory('/albany');
const locationValue = {search: 'query_name=th%C3%A1tcher'};
const matchValue = {params: {repoId: 'albany'}};
const wrapper = mountWithIntl(
<MemoryRouter>
<Results
history={history}
location={locationValue}
match={matchValue} />
</MemoryRouter>
);
return [wrapper, history];
}
describe('testing Results', () => {
beforeEach(() => {
fetch.resetMocks();
});
test('Results calls to correct API URLs', () => {
const [wrapper] = setupPageWrapper();
return flushPromises().then(() => {
wrapper.update();
expect(fetch.mock.calls.length).toBe(2);
expect(fetch.mock.calls[0][0]).toBe('/albany/d/repo');
expect(fetch.mock.calls[1][0]).toBe(
'/albany/d/results?query=th%C3%A1tcher');
wrapper.unmount();
});
});
test('RepoHeader configured correctly', () => {
const [wrapper] = setupPageWrapper();
return flushPromises().then(() => {
wrapper.update();
const actualRepoHeader = wrapper.find(RepoHeader).get(0);
expect(actualRepoHeader.props.repo).toEqual(REPO_DATA);
expect(actualRepoHeader.props.backButtonTarget).toBe('/albany');
wrapper.unmount();
});
});
test('SearchBar configured correctly', () => {
const [wrapper, history] = setupPageWrapper();
return flushPromises().then(() => {
wrapper.update();
const actualSearchBar = wrapper.find(SearchBar).get(0);
expect(actualSearchBar.props.repoId).toBe('albany');
expect(actualSearchBar.props.initialValue).toBe('thรกtcher');
actualSearchBar.props.onSearch('frรณdo');
expect(history.entries[1].pathname).toBe('/albany/results');
expect(history.entries[1].search).toBe('?query_name=fr%C3%B3do');
wrapper.unmount();
});
});
test('"Add Person" FAB points to create page', () => {
const [wrapper, history] = setupPageWrapper();
return flushPromises().then(() => {
wrapper.update();
wrapper.find('.results-addfab').at(0).simulate('click');
expect(history.entries[1].pathname).toBe('/albany/create');
wrapper.unmount();
});
});
test('snapshot test for Results', () => {
// We don't use setupPageWrapper here because we want to avoid passing a
// history object and need to specify initialEntries, to avoid generating
// random keys that mess up the snapshot.
fetch.mockResponseOnce(JSON.stringify(REPO_DATA));
fetch.mockResponseOnce(JSON.stringify(RESULTS_DATA));
const locationValue = {search: 'query_name=th%C3%A1tcher'};
const matchValue = {params: {repoId: 'albany'}};
const wrapper = mountWithIntl(
<MemoryRouter
initialEntries={[{pathname: '/albany/results', key: 'abc123'}]}>
<Results
location={locationValue}
match={matchValue} />
</MemoryRouter>
);
return flushPromises().then(() => {
wrapper.update();
expect(toJson(wrapper.find(Results).at(0))).toMatchSnapshot();
wrapper.unmount();
});
});
});
|
app/components/Contact.js | leckman/chapterbot | import React from 'react';
import { connect } from 'react-redux'
import { submitContactForm } from '../actions/contact';
import Messages from './Messages';
class Contact extends React.Component {
constructor(props) {
super(props);
this.state = { name: '', email: '', message: '' };
}
handleChange(event) {
this.setState({ [event.target.name]: event.target.value });
}
handleSubmit(event) {
event.preventDefault();
this.props.dispatch(submitContactForm(this.state.name, this.state.email, this.state.message));
}
render() {
return (
<div className="container">
<div className="panel">
<div className="panel-heading">
<h3 className="panel-title">Contact Form</h3>
</div>
<div className="panel-body">
<Messages messages={this.props.messages}/>
<form onSubmit={this.handleSubmit.bind(this)} className="form-horizontal">
<div className="form-group">
<label htmlFor="name" className="col-sm-2">Name</label>
<div className="col-sm-8">
<input type="text" name="name" id="name" className="form-control" value={this.state.name} onChange={this.handleChange.bind(this)} autoFocus/>
</div>
</div>
<div className="form-group">
<label htmlFor="email" className="col-sm-2">Email</label>
<div className="col-sm-8">
<input type="email" name="email" id="email" className="form-control" value={this.state.email} onChange={this.handleChange.bind(this)}/>
</div>
</div>
<div className="form-group">
<label htmlFor="message" className="col-sm-2">Body</label>
<div className="col-sm-8">
<textarea name="message" id="message" rows="7" className="form-control" value={this.state.message} onChange={this.handleChange.bind(this)}></textarea>
</div>
</div>
<div className="form-group">
<div className="col-sm-offset-2 col-sm-8">
<button type="submit" className="btn btn-success">Send</button>
</div>
</div>
</form>
</div>
</div>
</div>
);
}
}
const mapStateToProps = (state) => {
return {
messages: state.messages
};
};
export default connect(mapStateToProps)(Contact);
|
src/components/svg/Goose.js | JoeTheDave/onitama | import PropTypes from 'prop-types';
import React from 'react';
export const Goose = ({ fillColor }) => (
<svg width="210px" height="130px" viewBox="0 0 380 229" preserveAspectRatio="xMidYMid meet">
<g transform="translate(0, 229) scale(0.1, -0.1)" fill={fillColor} stroke="none">
<path d="M2775 2260 c-3 -5 2 -24 11 -42 14 -28 16 -53 11 -173 -3 -77 -10
-153 -15 -170 l-8 -30 -209 -26 c-142 -18 -219 -24 -240 -18 -16 5 -49 9 -72
9 -39 0 -43 -2 -43 -24 0 -14 10 -64 22 -113 21 -81 23 -110 22 -368 -1 -280
-12 -472 -39 -638 -19 -118 -9 -163 53 -245 37 -48 49 -41 61 36 24 144 32
295 38 765 3 268 6 487 7 487 1 0 82 11 180 25 99 14 185 25 193 25 9 0 6 -17
-12 -66 -33 -88 -76 -161 -153 -262 -65 -86 -102 -141 -102 -154 0 -41 171 78
251 174 27 33 58 77 69 99 11 21 24 39 29 39 5 0 69 -39 143 -86 157 -101 225
-137 244 -130 20 8 18 83 -4 126 -31 62 -118 95 -279 106 -51 4 -93 9 -93 12
0 3 14 41 32 83 37 91 13 81 253 109 274 32 317 27 335 -42 37 -136 67 -638
56 -948 -9 -249 -13 -277 -44 -298 -23 -15 -32 -15 -126 1 -55 9 -111 17 -123
17 -43 0 -23 -30 55 -82 115 -79 160 -126 168 -177 12 -77 52 -92 105 -39 44
44 78 122 96 221 21 110 22 567 3 897 -19 334 -19 380 3 413 33 51 21 70 -105
155 -52 36 -74 38 -135 17 -46 -16 -469 -82 -477 -74 -3 2 6 59 19 124 38 195
38 193 9 220 -45 42 -172 72 -189 45z"
/>
<path d="M1565 2200 c-3 -5 -3 -31 0 -57 8 -62 -1 -85 -88 -216 l-72 -108 -74
3 c-98 4 -104 -5 -71 -104 24 -71 25 -82 25 -353 0 -269 -1 -282 -22 -325 -12
-25 -32 -57 -44 -71 -20 -25 -20 -28 -5 -57 17 -33 61 -72 81 -72 7 0 37 11
67 25 61 28 185 55 385 85 237 34 266 28 276 -62 13 -110 -19 -369 -65 -516
l-19 -62 -39 0 c-21 0 -74 11 -117 24 -158 50 -167 38 -49 -64 93 -79 107 -98
128 -170 12 -40 16 -45 40 -43 37 2 94 47 123 97 52 91 102 300 135 573 18
145 24 173 47 205 24 36 25 39 9 63 -23 36 -107 94 -134 95 -13 0 -44 -7 -70
-15 -64 -20 -428 -67 -532 -69 l-85 -1 -3 365 -2 366 189 32 c105 17 197 29
205 26 13 -5 16 -24 16 -98 0 -98 -22 -271 -41 -324 -15 -44 -37 -53 -124 -51
-42 1 -79 -2 -83 -6 -4 -4 8 -19 27 -34 68 -52 101 -89 101 -114 0 -59 54 -59
114 0 75 75 105 166 126 383 14 142 23 174 61 201 16 11 29 26 29 34 0 32
-150 125 -201 125 -15 0 -47 -9 -73 -20 -37 -17 -199 -59 -229 -60 -4 0 51 57
123 128 87 85 130 134 130 149 0 47 -172 129 -195 93z"
/>
<path d="M684 2135 c-7 -16 -5 -24 21 -94 10 -29 19 -103 25 -210 5 -91 12
-212 16 -267 l7 -101 -74 -17 c-41 -9 -84 -19 -96 -22 -22 -6 -23 -4 -23 70 0
70 -2 77 -25 92 -28 18 -33 34 -11 34 26 0 106 39 112 55 9 23 -39 89 -77 108
-40 19 -69 8 -69 -28 0 -40 -39 -73 -150 -129 -65 -32 -106 -59 -108 -70 -3
-15 1 -16 35 -10 21 4 65 15 98 25 32 10 60 17 61 16 2 -1 4 -47 6 -101 l3
-99 -135 -34 c-74 -20 -139 -38 -143 -42 -4 -4 1 -18 11 -31 26 -32 96 -37
200 -12 l82 19 0 -116 0 -117 -126 -63 c-94 -48 -140 -65 -178 -68 -84 -7 -96
-11 -96 -36 0 -29 41 -89 73 -106 38 -20 65 -9 202 84 69 47 125 81 125 77 0
-34 -23 -239 -31 -284 -16 -79 -30 -90 -107 -80 -97 13 -105 -7 -27 -67 35
-26 49 -46 66 -92 31 -83 42 -90 85 -48 80 77 98 156 109 465 l7 190 47 30
c63 40 111 83 111 101 0 17 -19 13 -99 -23 -30 -13 -56 -22 -58 -20 -2 2 -1
49 3 103 l7 100 94 23 c108 25 112 24 113 -45 0 -22 9 -112 19 -200 l19 -160
-32 -33 c-17 -19 -65 -61 -108 -94 -73 -56 -96 -83 -80 -91 15 -8 70 14 152
61 l85 49 22 -101 c49 -218 114 -383 191 -486 72 -94 77 -91 117 63 14 51 34
116 45 145 20 51 26 102 13 102 -3 0 -32 -25 -64 -55 -32 -30 -64 -55 -73 -55
-31 0 -115 218 -142 372 l-17 96 85 91 c46 49 97 108 112 130 25 36 27 43 17
73 -23 71 -103 137 -115 96 -29 -97 -43 -132 -73 -181 -19 -32 -38 -56 -41
-53 -5 5 -31 262 -32 314 0 13 6 22 15 22 33 0 206 62 212 76 9 23 -17 44 -53
44 -18 0 -65 -7 -105 -15 -40 -9 -75 -13 -78 -10 -3 3 -6 135 -7 293 -3 323 5
293 -89 338 -59 28 -74 29 -81 9z"
/>
<path d="M941 1826 c-29 -34 41 -107 138 -146 43 -17 56 -18 68 -8 21 17 11
93 -16 122 -39 42 -165 63 -190 32z"
/>
<path d="M1503 1623 c-7 -3 -13 -16 -13 -31 0 -44 144 -162 168 -138 13 13 6
83 -10 108 -17 26 -120 69 -145 61z"
/>
<path d="M2733 1359 c-8 -8 -8 -19 3 -44 12 -29 11 -40 -2 -87 -37 -124 -132
-272 -249 -388 -70 -69 -93 -110 -62 -110 20 0 144 76 212 130 66 52 122 114
170 187 l27 43 142 -136 c192 -185 223 -211 244 -197 10 5 23 27 31 47 29 77
-28 167 -147 229 -72 37 -189 77 -228 77 -13 0 -24 2 -24 4 0 2 11 29 25 60
39 88 35 109 -27 150 -61 40 -98 52 -115 35z"
/>
<path d="M1557 730 c-70 -15 -187 -35 -260 -44 -72 -10 -145 -21 -162 -25
l-30 -7 28 -26 c56 -52 153 -55 407 -12 52 8 155 19 227 23 139 7 167 16 147
49 -5 9 -35 29 -65 44 -70 35 -124 35 -292 -2z"
/>
</g>
</svg>
);
Goose.propTypes = {
fillColor: PropTypes.string.isRequired,
};
export default Goose;
|
src/web/components/Footer.js | TeodorKolev/Help | import React from 'react';
import { Row, Col } from 'reactstrap';
const Footer = () => (
<footer className="mt-5">
<Row>
<Col sm="12" className="text-right pt-3">
<p>
Learn More on the <a target="_blank" rel="noopener noreferrer" href="https://github.com/mcnamee/react-native-starter-kit">Github Repo</a> | Written and Maintained by <a target="_blank" rel="noopener noreferrer" href="https://mcnam.ee">Matt Mcnamee</a>.
</p>
</Col>
</Row>
</footer>
);
export default Footer;
|
src/index.js | jsk7/personal-web | /* eslint-disable import/default */
import React from 'react';
import {render} from 'react-dom';
import { Provider } from 'react-redux';
import { Router, browserHistory } from 'react-router';
import routes from './routes';
import configureStore from './store/configureStore';
require('./favicon.ico'); // Tell webpack to load favicon.ico
import './styles/styles.scss'; // Yep, that's right. You can import SASS/CSS files too! Webpack will run the associated loader and plug this into the page.
import { syncHistoryWithStore } from 'react-router-redux';
const store = configureStore();
// Create an enhanced history that syncs navigation events with the store
const history = syncHistoryWithStore(browserHistory, store);
render(
<Provider store={store}>
<Router history={history} routes={routes} />
</Provider>, document.getElementById('app')
);
|
features/apimgt/org.wso2.carbon.apimgt.publisher.feature/src/main/resources/publisher/source/src/app/components/Base/Footer/Footer.js | lakmali/carbon-apimgt | /*
* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import React from 'react'
export const Footer = () => (
<footer className="footer">
<div className="container-fluid">
<p>WSO2 APIM Publisher v3.0.0 | ยฉ 2017 <a href="http://wso2.com/" target="_blank"><i
className="icon fw fw-wso2"/> Inc</a>.</p>
</div>
</footer>
);
export default Footer
|
webpack/containers/Application/index.js | johnpmitsch/katello | import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { BrowserRouter as Router } from 'react-router-dom';
import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
import { orgId } from '../../services/api';
import * as actions from '../../scenes/Organizations/OrganizationActions';
import reducer from '../../scenes/Organizations/OrganizationReducer';
import Routes from './Routes';
import './overrides.scss';
const mapStateToProps = state => ({ organization: state.organization });
const mapDispatchToProps = dispatch => bindActionCreators(actions, dispatch);
export const organization = reducer;
class Application extends Component {
componentDidMount() {
this.loadData();
}
loadData() {
if (orgId()) {
this.props.loadOrganization();
}
}
render() {
return (
<Router>
<Routes />
</Router>
);
}
}
Application.propTypes = {
loadOrganization: PropTypes.func.isRequired,
};
export default connect(mapStateToProps, mapDispatchToProps)(Application);
|
src/__tests__/ArrayCapture-test.js | networknt/react-schema-form | import React from 'react'
import { render, configure } from 'enzyme'
import Adapter from 'enzyme-adapter-react-16'
import utils from '../utils'
import SchemaForm from '../SchemaForm'
configure({ adapter: new Adapter() })
jest.dontMock('../ComposedComponent')
jest.dontMock('../utils')
jest.dontMock('lodash')
function onModelChange(key, val, type) {
const { model } = this.state
const newModel = model
utils.selectOrSet(key, newModel, val, type)
this.setState({ model: newModel })
}
describe('Composed component test', () => {
it('Output from model with 3 comps must have length 3: ', () => {
const cfg = {
form: [
{
key: 'comments',
add: 'New',
style: {
add: 'btn-success'
},
items: ['comments[].name']
}
],
schema: {
type: 'object',
title: 'Comment',
required: ['comments'],
properties: {
comments: {
type: 'array',
maxItems: 2,
items: {
type: 'object',
properties: {
name: {
title: 'Name',
type: 'string'
}
},
required: ['name']
}
}
}
},
model: {
comments: [
{
name: 'some value'
},
{
name: 'some next value'
},
{
name: 'some other value'
}
]
}
}
const display = render(
<SchemaForm
form={cfg.form}
schema={cfg.schema}
model={cfg.model}
onModelChange={onModelChange}
/>
)
expect(display.find('input').length).toEqual(3)
})
})
|
src/interface/icons/ViralContent.js | yajinni/WoWAnalyzer | import React from 'react';
// Viral Content by Edwin Prayogi M from the Noun Project
const Icon = ({ ...other }) => (
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" className="icon" {...other}>
<g>
<path d="M49.9931641,18.8754883c0.6904297,0,1.25-0.5595703,1.25-1.25V12.5c0-0.6904297-0.5595703-1.25-1.25-1.25 s-1.25,0.5595703-1.25,1.25v5.1254883C48.7431641,18.315918,49.3027344,18.8754883,49.9931641,18.8754883z" />
<path d="M32.7236328,22.5913086c0.2324219,0.4008789,0.6523438,0.625,1.0839844,0.625 c0.2119141,0,0.4267578-0.0537109,0.6240234-0.1674805c0.5976563-0.3452148,0.8027344-1.109375,0.4580078-1.7075195 l-2.5625-4.4389648c-0.3466797-0.5976563-1.109375-0.8037109-1.7080078-0.4575195 c-0.5976563,0.3452148-0.8027344,1.109375-0.4580078,1.7075195L32.7236328,22.5913086z" />
<path d="M16.8955078,32.3383789l4.4394531,2.5629883c0.1972656,0.1137695,0.4121094,0.1674805,0.6240234,0.1674805 c0.4316406,0,0.8515625-0.2241211,1.0839844-0.625c0.3447266-0.5976563,0.1396484-1.3623047-0.4580078-1.7075195 l-4.4394531-2.5629883c-0.5996094-0.3447266-1.3613281-0.1401367-1.7080078,0.4575195 C16.0927734,31.2285156,16.2978516,31.9931641,16.8955078,32.3383789z" />
<path d="M18.8759766,50.0068359c0-0.6904297-0.5595703-1.25-1.25-1.25H12.5c-0.6904297,0-1.25,0.5595703-1.25,1.25 s0.5595703,1.25,1.25,1.25h5.1259766C18.3164063,51.2568359,18.8759766,50.6972656,18.8759766,50.0068359z" />
<path d="M21.3417969,65.1103516l-4.4394531,2.5629883c-0.5976563,0.3452148-0.8027344,1.1098633-0.4580078,1.7075195 c0.2324219,0.4008789,0.6523438,0.625,1.0839844,0.625c0.2119141,0,0.4267578-0.0537109,0.6240234-0.1674805l4.4394531-2.5629883 c0.5976563-0.3452148,0.8027344-1.1098633,0.4580078-1.7075195C22.703125,64.9702148,21.9404297,64.7641602,21.3417969,65.1103516z " />
<path d="M34.4433594,76.9580078c-0.5996094-0.3457031-1.3613281-0.1396484-1.7080078,0.4575195l-2.5625,4.4389648 c-0.3447266,0.5981445-0.1396484,1.3623047,0.4580078,1.7075195c0.1972656,0.1137695,0.4121094,0.1674805,0.6240234,0.1674805 c0.4316406,0,0.8515625-0.2241211,1.0839844-0.625l2.5625-4.4389648 C35.2460938,78.0673828,35.0410156,77.3032227,34.4433594,76.9580078z" />
<path d="M50.0068359,81.1245117c-0.6904297,0-1.25,0.5595703-1.25,1.25V87.5c0,0.6904297,0.5595703,1.25,1.25,1.25 s1.25-0.5595703,1.25-1.25v-5.1254883C51.2568359,81.684082,50.6972656,81.1245117,50.0068359,81.1245117z" />
<path d="M67.2763672,77.4086914c-0.3466797-0.5976563-1.109375-0.8022461-1.7080078-0.4575195 c-0.5976563,0.3452148-0.8027344,1.109375-0.4580078,1.7075195l2.5625,4.4389648 c0.2324219,0.4008789,0.6523438,0.625,1.0839844,0.625c0.2119141,0,0.4267578-0.0537109,0.6240234-0.1674805 c0.5976563-0.3452148,0.8027344-1.109375,0.4580078-1.7075195L67.2763672,77.4086914z" />
<path d="M83.1044922,67.6616211l-4.4394531-2.5629883c-0.5986328-0.3461914-1.3613281-0.1401367-1.7080078,0.4575195 c-0.3447266,0.5976563-0.1396484,1.3623047,0.4580078,1.7075195l4.4394531,2.5629883 c0.1972656,0.1137695,0.4121094,0.1674805,0.6240234,0.1674805c0.4316406,0,0.8515625-0.2241211,1.0839844-0.625 C83.9072266,68.7714844,83.7021484,68.0068359,83.1044922,67.6616211z" />
<path d="M87.5,48.7431641h-5.1259766c-0.6904297,0-1.25,0.5595703-1.25,1.25s0.5595703,1.25,1.25,1.25H87.5 c0.6904297,0,1.25-0.5595703,1.25-1.25S88.1904297,48.7431641,87.5,48.7431641z" />
<path d="M78.0341797,35.0571289c0.2119141,0,0.4267578-0.0537109,0.6240234-0.1674805l4.4394531-2.5629883 c0.5976563-0.3452148,0.8027344-1.1098633,0.4580078-1.7075195c-0.3466797-0.5976563-1.1083984-0.8027344-1.7080078-0.4575195 l-4.4394531,2.5629883c-0.5976563,0.3452148-0.8027344,1.1098633-0.4580078,1.7075195 C77.1826172,34.8330078,77.6025391,35.0571289,78.0341797,35.0571289z" />
<path d="M65.5566406,23.0419922c0.1972656,0.1137695,0.4121094,0.1674805,0.6240234,0.1674805 c0.4316406,0,0.8515625-0.2241211,1.0839844-0.625l2.5625-4.4389648c0.3447266-0.5981445,0.1396484-1.3623047-0.4580078-1.7075195 c-0.5986328-0.3452148-1.3613281-0.1401367-1.7080078,0.4575195l-2.5625,4.4389648 C64.7539063,21.9326172,64.9589844,22.6967773,65.5566406,23.0419922z" />
<path d="M56.9118652,26.5949097c-0.1091309-0.0378418-0.2199707-0.0599365-0.335083-0.0667114 c-0.0233154-0.0013428-0.0444336-0.0135498-0.0679932-0.0135498H33.4414063c-0.6904297,0-1.25,0.5595703-1.25,1.25v44.4726563 c0,0.6904297,0.5595703,1.25,1.25,1.25h33.1123047c0.6904297,0,1.25-0.5595703,1.25-1.25V37.8183594 c0-0.0131226-0.0075684-0.0250854-0.0079346-0.038208c-0.00354-0.1530151-0.0336914-0.3015137-0.0917969-0.4432373 c-0.0002441-0.0006714-0.0003662-0.0012817-0.0006104-0.0018921c-0.0617676-0.1498413-0.1418457-0.2926025-0.2609863-0.4116821 l-8.965332-8.9575195l-1.0834961-1.0844727c-0.0028076-0.0028076-0.0068359-0.0037231-0.0096436-0.0064697 c-0.1055908-0.1044922-0.2287598-0.1800537-0.3590088-0.2398682C56.987915,26.618103,56.9504395,26.6081543,56.9118652,26.5949097z M63.5268555,36.5576172h-5.7719727v-5.7768555L63.5268555,36.5576172z M34.6914063,70.9873047V29.0146484h20.5634766v8.7929688 c0,0.6904297,0.5595703,1.25,1.25,1.25h8.7988281v31.9296875H34.6914063z" />
<path d="M51.2431641,41.1494141c0-3.9272461-3.1953125-7.1225586-7.1230469-7.1225586 c-3.9267578,0-7.1220703,3.1953125-7.1220703,7.1225586s3.1953125,7.1225586,7.1220703,7.1225586 C48.0478516,48.2719727,51.2431641,45.0766602,51.2431641,41.1494141z M39.4980469,41.1494141 c0-2.5488281,2.0732422-4.6225586,4.6220703-4.6225586s4.6230469,2.0737305,4.6230469,4.6225586 s-2.0742188,4.6225586-4.6230469,4.6225586S39.4980469,43.6982422,39.4980469,41.1494141z" />
<path d="M59.9033203,45.0673828h-7.5175781c-0.6904297,0-1.25,0.5595703-1.25,1.25s0.5595703,1.25,1.25,1.25h7.5175781 c0.6904297,0,1.25-0.5595703,1.25-1.25S60.59375,45.0673828,59.9033203,45.0673828z" />
<path d="M59.9033203,51.8012695H41.8935547c-0.6904297,0-1.25,0.5595703-1.25,1.25s0.5595703,1.25,1.25,1.25h18.0097656 c0.6904297,0,1.25-0.5595703,1.25-1.25S60.59375,51.8012695,59.9033203,51.8012695z" />
<path d="M59.9033203,56.8911133H41.8935547c-0.6904297,0-1.25,0.5595703-1.25,1.25s0.5595703,1.25,1.25,1.25h18.0097656 c0.6904297,0,1.25-0.5595703,1.25-1.25S60.59375,56.8911133,59.9033203,56.8911133z" />
<path d="M59.9033203,61.980957H41.8935547c-0.6904297,0-1.25,0.5595703-1.25,1.25s0.5595703,1.25,1.25,1.25h18.0097656 c0.6904297,0,1.25-0.5595703,1.25-1.25S60.59375,61.980957,59.9033203,61.980957z" />
</g>
</svg>
);
export default Icon;
|
src/components/Todo/Form.js | elemus/react-redux-todo-example | import React, { Component } from 'react';
import PropTypes from 'prop-types';
class Form extends Component {
constructor(props) {
super(props);
this.state = { description: '' };
this.onInput = this.onInput.bind(this);
this.onSubmit = this.onSubmit.bind(this);
}
onInput(e) {
this.setState({ description: e.target.value });
}
onSubmit(e) {
e.preventDefault();
this.props.onTaskAdd(this.state.description.trim());
this.setState({ description: '' });
}
render() {
return (
<form onSubmit={this.onSubmit}>
<div className="row">
<div className="form-group col-9">
<input
type="text"
className="form-control"
placeholder="Do something..."
value={this.state.description}
onInput={this.onInput}
required
/>
</div>
<div className="col-3">
<button type="submit" className="btn btn-primary w-100">Add</button>
</div>
</div>
</form>
);
}
}
Form.propTypes = {
onTaskAdd: PropTypes.func.isRequired,
};
export default Form;
|
client/app/components/Input/index.js | bryanph/Geist | import _ from 'lodash'
import React from 'react'
import './styles.css'
export function controlled(InputComponent) {
/*
* HOF for creating a controlled input
* // TODO: should this also merge in value prop if set? - 2016-08-05
*/
class ControlledInput extends React.Component {
constructor(props) {
super(props)
this.onChange = this.onChange.bind(this)
this.state = { value: props.value || '' }
}
// componentWillReceiveProps(nextProps) {
// if (nextProps.value !== this.state.value) {
// this.setState({ value: nextProps.value })
// }
// }
onChange(event) {
event.persist()
if (this.props.onChange) {
this.props.onChange(event)
}
this.setState({value: event.target.value})
}
render() {
return (
<InputComponent
{...this.props}
value={this.state.value}
onChange={this.onChange}
/>
)
}
}
return ControlledInput
}
export function debounced(Component, timeout=1000) {
/*
* HOF for creating a debounced onChange method
*/
class DebouncedComponent extends React.Component {
constructor(props) {
super(props)
this.onChange = this.onChange.bind(this)
this.debounced = _.debounce(props.debouncedOnChange, timeout)
}
cancel() {
/*
* Public method to cancel debounce
*/
this.debounced.cancel()
}
onChange(event) {
event.persist()
if (this.props.onChange) {
this.props.onChange(event)
}
this.debounced(event)
}
render() {
const { debouncedOnChange, ...restProps } = this.props
return (
<Component {...restProps} onChange={this.onChange} />
)
}
}
return DebouncedComponent
}
const Input = (props) => <input {...props} />
export const InputText = (props) => (
<Input type='text' className={"input"} {...props} />
)
export const InputNumber = (props) => (
<Input type="number" {...props} />
)
import TextField from 'material-ui/TextField'
export TextField from 'material-ui/TextField'
export const ControlledTextField = controlled(TextField)
export const DebouncedTextField = debounced(controlled(TextField))
export const DebouncedTextField500 = debounced(controlled(TextField), 500)
|
examples/search-form/modules/SearchForm.js | alexeyraspopov/react-coroutine | import React from 'react';
import Coroutine from 'react-coroutine';
import SearchAPI from './SearchAPI';
/* A coroutine becomes a React component via this wrapper. */
export default Coroutine.create(SearchForm);
/* Async generator is used as a component that represents a stateful component
with search results. The same rules are applicable as to functional component.
The main difference comparing to plain functional component is that async generator
yields particular UI state and then performs additional actions (awaitg for data)
to create and yield new UI state. */
/* If you don't know what the thing is async generator, check the TC39 proposal:
https://github.com/tc39/proposal-async-iteration#async-generator-functions */
async function* SearchForm({ query }) {
/* Not really important. There is nothing to show if query is empty. */
if (query.length === 0) return null;
/* This call does not finish the execution of the component. It just provides a
state of UI and then doing another stuff. */
yield <p>Searching {query}...</p>;
try {
/* This piece is the same as with async functions. Some data is fetched and
used with another plain functional component. */
let { results } = await SearchAPI.retrieve(query);
return <SearchResults results={results} />;
} catch (error) {
return <ErrorMessage error={error} />;
}
}
function SearchResults({ results }) {
return results.length === 0 ? (
<p>No results</p>
) : (
<ul>
{results.map((result) => (
<li key={result.package.name}>
<h3 className="package-name"><a href={result.package.links.npm} target="_blank">{result.package.name}</a> <small className="package-version">({result.package.version})</small></h3>
<p className="package-description">{result.package.description}</p>
</li>
))}
</ul>
);
}
function ErrorMessage({ error }) {
return (
<details>
<summary>Something went wrong!</summary>
<p>{error.message}</p>
</details>
);
}
|
pages/showcase.js | styled-components/styled-components-website | import { withRouter } from 'next/router';
import React from 'react';
import { CSSTransition, TransitionGroup } from 'react-transition-group';
import styled, { css, keyframes } from 'styled-components';
import { sortedProjects } from '../companies-manifest';
import Footer from '../components/Footer';
import Image from '../components/Image';
import Nav from '../components/Nav';
import SeoHead from '../components/SeoHead';
import Navigation from '../components/Slider/Navigation';
import ShowcaseBody from '../components/Slider/ShowcaseBody';
import { generateShowcaseUrl } from '../components/Slider/ShowcaseLink';
import WithIsScrolled from '../components/WithIsScrolled';
import { blmGrey, blmMetal } from '../utils/colors';
import { headerFont } from '../utils/fonts';
import { mobile, phone } from '../utils/media';
const Container = styled.div`
overflow-x: hidden;
* {
font-family: ${headerFont};
}
h1,
h2,
h3,
h4,
h5,
h6,
p {
margin-top: 0;
}
h1 {
font-size: 2.5rem;
margin-bottom: 0;
${phone(css`
font-size: 2rem;
`)}
}
h2 {
font-size: 1.75rem;
line-height: 1.5;
${phone(css`
font-size: 1.5rem;
`)}
}
h5 {
margin-bottom: 0;
font-size: 1rem;
font-weight: 400;
opacity: 0.6;
}
p {
opacity: 0.6;
}
`;
const Header = styled.header`
position: relative;
height: 512px;
padding-top: 48px;
background-color: #daa357;
background: linear-gradient(20deg, ${blmGrey}, ${blmMetal});
overflow: hidden;
${mobile(css`
padding-top: 92px;
`)}
`;
const HeaderContent = styled.div`
width: 100%;
padding: 48px 0;
display: grid;
justify-content: space-between;
grid-template-columns: minmax(0px, 512px) minmax(128px, 192px);
grid-column-gap: 24px;
color: #ffffff;
${phone(css`
grid-template-columns: 1fr;
`)}
`;
const Wrapper = styled.div`
max-width: 1280px;
width: 100%;
margin: 0 auto;
padding: 0 80px;
${phone(css`
padding: 0 16px;
`)}
`;
const InsetWrapper = styled.div`
padding: 0 64px;
${mobile(css`
padding: 0;
`)}
`;
const Body = styled.div`
position: relative;
`;
const BodyWrapper = styled.div`
position: relative;
top: -192px;
${mobile(css`
top: -96px;
`)}
`;
const Slide = styled(Image)`
border-radius: 12px;
box-shadow: 0 32px 48px rgba(0, 0, 0, 0.12);
`;
const getSlide = (childIndex) => keyframes`
from {
transform: translateX(${childIndex * 105}%);
}
to {
transform: translateX(${-105 + 105 * childIndex}%);
}
`;
const HeaderDecoration = styled.div`
position: absolute;
bottom: 0;
left: 0;
font-family: Avenir Next;
font-size: 16rem;
line-height: 16rem;
font-weight: 800;
color: rgba(0, 0, 0, 0.1);
mix-blend-mode: overlay;
pointer-events: none;
animation: ${({ offset }) => getSlide(offset || 0)} 30s linear infinite;
`;
const NativeSelect = styled.select`
border: 1px solid #ffffff;
color: #ffffff;
text-align-last: center;
appearance: none;
padding: 0 8px;
background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' width='24' fill='white'><path d='M7 10l5 5 5-5z'/></svg>");
background-position: 98% 50%;
&::after {
content: '';
height: 10px;
width: 10px;
border: 8px solid black;
}
`;
const HeaderActions = styled.div`
width: 100%;
${phone(css`
display: grid;
grid-template-columns: 1fr 1fr;
grid-column-gap: 24px;
`)}
* {
display: block;
width: 100%;
margin-top: 20px;
}
button,
a,
${NativeSelect} {
height: 50px;
border-radius: 4px;
font-family: Avenir Next;
font-weight: 500;
font-size: 1rem;
line-height: 50px;
${phone(css`
height: 40px;
line-height: 40px;
`)}
}
button,
a {
display: block;
text-align: center;
background-color: #ffffff;
color: rgb(219, 112, 147);
border: none;
transition: 200ms;
padding: 0;
&:hover {
background-color: #f3f3f3;
}
}
`;
function normalizeSlideIndex(arr, index, fn) {
const result = fn(index);
if (result > arr.length - 1) {
return 0;
}
if (result < 0) {
return arr.length - 1;
}
return result;
}
// Since objects don't allow for a sort order we have to map an array to the object
function mapIndexToRoute(index) {
const route = Object.keys(sortedProjects)[index];
return sortedProjects[route];
}
function calculateSlides(sortOrder, route) {
let currentSlideIndex = sortOrder.indexOf(route);
if (currentSlideIndex === -1) {
currentSlideIndex = 0;
}
const previousSlideIndex = normalizeSlideIndex(sortOrder, currentSlideIndex, (x) => x - 1);
const nextSlideIndex = normalizeSlideIndex(sortOrder, currentSlideIndex, (x) => x + 1);
return {
currentSlide: mapIndexToRoute(currentSlideIndex),
previousSlide: mapIndexToRoute(previousSlideIndex),
nextSlide: mapIndexToRoute(nextSlideIndex),
};
}
class ArrowEvents extends React.Component {
handleKeyDown = (event) => {
const isLeft = event.keyCode === 37;
const isRight = event.keyCode === 39;
const { router, previousSlide, nextSlide } = this.props;
if (!isLeft && !isRight) return;
const { href, as } = generateShowcaseUrl(isLeft ? previousSlide : nextSlide);
router.replace(href, as);
return;
};
componentDidMount() {
document.addEventListener('keydown', this.handleKeyDown);
}
componentWillUnmount() {
document.removeEventListener('keydown', this.handleKeyDown);
}
render() {
return null;
}
}
const Showcase = ({ router }) => {
const { item } = router.query;
const { currentSlide, previousSlide, nextSlide } = calculateSlides(Object.keys(sortedProjects), item);
const { title, src, owner, link, repo, description } = currentSlide;
return (
<>
<SeoHead title={`styled-components: Showcase ${title}`}>
<meta name="robots" content="noodp" />
</SeoHead>
<WithIsScrolled>{({ isScrolled }) => <Nav showSideNav={false} transparent={!isScrolled} />}</WithIsScrolled>
<ArrowEvents router={router} previousSlide={previousSlide} nextSlide={nextSlide} />
<Container>
<Header>
<Wrapper>
<InsetWrapper>
<HeaderContent>
<div>
<h2>Awesome websites, by awesome humans beings.</h2>
<h5>
Styled components is used by teams all around the world to create beautiful websites, like these
ones:
</h5>
</div>
<HeaderActions>
<NativeSelect name="category" id="categorySelect" value="all">
<option value="all">All</option>
</NativeSelect>
<a
href="https://github.com/styled-components/styled-components-website/issues/new?template=company-showcase-request.md&title=Add+%5Bproject%5D+by+%5Bcompany%5D+to+showcase"
target="_blank"
rel="noopener noreferrer"
>
Share yours!
</a>
</HeaderActions>
</HeaderContent>
</InsetWrapper>
</Wrapper>
<HeaderDecoration>Showcase</HeaderDecoration>
<HeaderDecoration offset={1}>Showcase</HeaderDecoration>
<HeaderDecoration offset={2}>Showcase</HeaderDecoration>
</Header>
<Body>
<Wrapper>
<BodyWrapper>
<Slide
width={1920}
height={1080}
src={src}
margin={0}
renderImage={(props) => {
return (
<TransitionGroup>
<CSSTransition key={src} timeout={500} classNames="fade">
<img src={src} {...props} />
</CSSTransition>
</TransitionGroup>
);
}}
/>
</BodyWrapper>
<Navigation prev={previousSlide} next={nextSlide} />
<BodyWrapper>
<InsetWrapper>
<ShowcaseBody title={title} description={description} owner={owner} link={link} repo={repo} />
</InsetWrapper>
</BodyWrapper>
</Wrapper>
</Body>
</Container>
<Footer />
</>
);
};
export default withRouter(Showcase);
|
client/src/components/post/EditPost.js | adityasharat/react-readable | import _ from 'lodash';
import React, { Component } from 'react';
import { connect } from 'react-redux';
import { Link } from 'react-router-dom';
import { fetchAllPosts, updatePost } from '../../actions/PostActions';
import { fetchCommentForPost } from '../../actions/CommentActions';
class EditPost extends Component {
componentDidMount() {
this.props.fetchAllPosts();
this.props.fetchCommentForPost(this.props.match.params.postId);
}
editPost = (e) => {
e.preventDefault();
const postId = this.props.post.id;
const title = e.target.title.value;
const body = e.target.body.value;
if (body === "" || title === "") {
alert("Both fields are mandatory");
} else {
this.props.updatePost(postId, title, body ,() => this.props.history.push('/'));
}
}
render() {
const { post } = this.props;
if (!post) {
return (<h3 className="error">404 Post Not Found</h3>);
}
return (
<form className="form create-post" onSubmit={ this.editPost }>
<h4>Edit post by {post.author}</h4>
<div className="form-group">
<label htmlFor="title">Title</label>
<input defaultValue={ post.title } type="text" className="form-control" name="title" id="title" placeholder="Enter title for the post" required/>
</div>
<div className="form-group">
<label htmlFor="body">Content</label>
<textarea defaultValue={ post.body } type="text" className="form-control" name="body" id="body" placeholder="Enter contents for the post" rows="10" required/>
</div>
<div className="btn-group">
<button type="submit" className="btn btn-primary">Update</button>
<Link className="btn btn-secondary" role="button" to={`/post/${post.id}`}>Cancel</Link>
</div>
</form>
);
}
}
function mapStateToProps({ posts, comments }, { match }) {
return {
post: _.find(posts, { id: match.params.postId }),
comments: comments[match.params.postId]
};
}
export default connect(mapStateToProps, { fetchAllPosts, updatePost, fetchCommentForPost })(EditPost);
|
example/App.js | ksincennes/react-native-maps | import React from 'react';
import {
Platform,
View,
StyleSheet,
TouchableOpacity,
ScrollView,
Text,
Switch,
} from 'react-native';
import { PROVIDER_GOOGLE, PROVIDER_DEFAULT } from 'react-native-maps';
import DisplayLatLng from './examples/DisplayLatLng';
import ViewsAsMarkers from './examples/ViewsAsMarkers';
import EventListener from './examples/EventListener';
import MarkerTypes from './examples/MarkerTypes';
import DraggableMarkers from './examples/DraggableMarkers';
import PolygonCreator from './examples/PolygonCreator';
import PolylineCreator from './examples/PolylineCreator';
import AnimatedViews from './examples/AnimatedViews';
import AnimatedMarkers from './examples/AnimatedMarkers';
import Callouts from './examples/Callouts';
import Overlays from './examples/Overlays';
import DefaultMarkers from './examples/DefaultMarkers';
import CustomMarkers from './examples/CustomMarkers';
import CachedMap from './examples/CachedMap';
import LoadingMap from './examples/LoadingMap';
import TakeSnapshot from './examples/TakeSnapshot';
import FitToSuppliedMarkers from './examples/FitToSuppliedMarkers';
import FitToCoordinates from './examples/FitToCoordinates';
import LiteMapView from './examples/LiteMapView';
import CustomTiles from './examples/CustomTiles';
import ZIndexMarkers from './examples/ZIndexMarkers';
import StaticMap from './examples/StaticMap';
import MapStyle from './examples/MapStyle';
const IOS = Platform.OS === 'ios';
const ANDROID = Platform.OS === 'android';
function makeExampleMapper(useGoogleMaps) {
if (useGoogleMaps) {
return example => [
example[0],
[example[1], example[3]].filter(Boolean).join(' '),
];
}
return example => example;
}
class App extends React.Component {
constructor(props) {
super(props);
this.state = {
Component: null,
useGoogleMaps: ANDROID,
};
}
renderExample([Component, title]) {
return (
<TouchableOpacity
key={title}
style={styles.button}
onPress={() => this.setState({ Component })}
>
<Text>{title}</Text>
</TouchableOpacity>
);
}
renderBackButton() {
return (
<TouchableOpacity
style={styles.back}
onPress={() => this.setState({ Component: null })}
>
<Text style={{ fontWeight: 'bold', fontSize: 30 }}>←</Text>
</TouchableOpacity>
);
}
renderGoogleSwitch() {
return (
<View>
<Text>Use GoogleMaps?</Text>
<Switch
onValueChange={(value) => this.setState({ useGoogleMaps: value })}
style={{ marginBottom: 10 }}
value={this.state.useGoogleMaps}
/>
</View>
);
}
renderExamples(examples) {
const {
Component,
useGoogleMaps,
} = this.state;
return (
<View style={styles.container}>
{Component && <Component provider={useGoogleMaps ? PROVIDER_GOOGLE : PROVIDER_DEFAULT} />}
{Component && this.renderBackButton()}
{!Component &&
<ScrollView
style={StyleSheet.absoluteFill}
contentContainerStyle={styles.scrollview}
showsVerticalScrollIndicator={false}
>
{IOS && this.renderGoogleSwitch()}
{examples.map(example => this.renderExample(example))}
</ScrollView>
}
</View>
);
}
render() {
return this.renderExamples([
// [<component>, <component description>, <Google compatible>, <Google add'l description>]
[StaticMap, 'StaticMap', true],
[DisplayLatLng, 'Tracking Position', true, '(incomplete)'],
[ViewsAsMarkers, 'Arbitrary Views as Markers', true],
[EventListener, 'Events', true, '(incomplete)'],
[MarkerTypes, 'Image Based Markers', true],
[DraggableMarkers, 'Draggable Markers', true],
[PolygonCreator, 'Polygon Creator', true],
[PolylineCreator, 'Polyline Creator', true],
[AnimatedViews, 'Animating with MapViews'],
[AnimatedMarkers, 'Animated Marker Position'],
[Callouts, 'Custom Callouts', true],
[Overlays, 'Circles, Polygons, and Polylines', true],
[DefaultMarkers, 'Default Markers', true],
[CustomMarkers, 'Custom Markers', true],
[TakeSnapshot, 'Take Snapshot', true, '(incomplete)'],
[CachedMap, 'Cached Map'],
[LoadingMap, 'Map with loading'],
[FitToSuppliedMarkers, 'Focus Map On Markers', true],
[FitToCoordinates, 'Fit Map To Coordinates', true],
[LiteMapView, 'Android Lite MapView'],
[CustomTiles, 'Custom Tiles', true],
[ZIndexMarkers, 'Position Markers with Z-index', true],
[MapStyle, 'Customize the style of the map', true],
]
// Filter out examples that are not yet supported for Google Maps on iOS.
.filter(example => ANDROID || (IOS && (example[2] || !this.state.useGoogleMaps)))
.map(makeExampleMapper(IOS && this.state.useGoogleMaps))
);
}
}
const styles = StyleSheet.create({
container: {
...StyleSheet.absoluteFillObject,
justifyContent: 'flex-end',
alignItems: 'center',
},
scrollview: {
alignItems: 'center',
paddingVertical: 40,
},
button: {
flex: 1,
marginTop: 10,
backgroundColor: 'rgba(220,220,220,0.7)',
paddingHorizontal: 18,
paddingVertical: 12,
borderRadius: 20,
},
back: {
position: 'absolute',
top: 20,
left: 12,
backgroundColor: 'rgba(255,255,255,0.4)',
padding: 12,
borderRadius: 20,
width: 80,
alignItems: 'center',
justifyContent: 'center',
},
});
module.exports = App;
|
docs/src/stories/implementations.js | rhalff/storybook | import React from 'react';
import { values } from 'lodash';
import Homepage from '../components/Homepage';
import Header from '../components/Header';
import Heading from '../components/Homepage/Heading';
import Demo from '../components/Homepage/Demo';
import Platforms from '../components/Homepage/Platforms';
import MainLinks from '../components/Homepage/MainLinks';
import Featured from '../components/Homepage/Featured';
import UsedBy from '../components/Homepage/UsedBy';
import Footer from '../components/Footer';
import Docs from '../components/Docs';
import DocsContainer from '../components/Docs/Container';
import DocsContent from '../components/Docs/Content';
import DocsNav from '../components/Docs/Nav';
import GridItem from '../components/Grid/GridItem';
import Grid from '../components/Grid/Grid';
import Examples from '../components/Grid/Examples';
import { docsData } from './data';
import users from './_users.yml';
import exampleData from './_examples.yml';
export default {
'Homepage.page': (
<Homepage featuredStorybooks={docsData.featuredStorybooks} users={values(users)} />
),
'Homepage.header': <Header />,
'Homepage.heading': <Heading />,
'Homepage.demo': <Demo />,
'Homepage.built-for': <Platforms />,
'Homepage.main-links': <MainLinks />,
'Homepage.featured-storybooks': <Featured featuredStorybooks={docsData.featuredStorybooks} />,
'Homepage.used-by': <UsedBy users={values(users)} />,
'Homepage.footer': <Footer />,
'Docs.page': (
<Docs
sections={docsData.sections}
selectedItem={docsData.selectedItem}
categories={docsData.categories}
selectedCatId="cat-2"
/>
),
'Docs.docs-container': (
<DocsContainer
sections={docsData.sections}
selectedItem={docsData.selectedItem}
categories={docsData.categories}
selectedCatId="cat-2"
/>
),
'Docs.docs-content': (
<DocsContent title={docsData.selectedItem.title} content={docsData.selectedItem.content} />
),
'Docs.docs-nav': (
<DocsNav
sections={docsData.sections}
selectedSection={docsData.selectedItem.sectionId}
selectedItem={docsData.selectedItem.id}
/>
),
'Grid.grid-item': <GridItem {...values(exampleData)[0]} />,
'Grid.grid': <Grid items={values(exampleData)} columnWidth={300} />,
'Grid.examples': <Examples items={values(exampleData)} />,
};
|
src/components/Reset/Reset.js | Zoomdata/nhtsa-dashboard | import React, { Component } from 'react';
import Circle from '../Circle/Circle';
import Label from '../Label/Label';
export default class Reset extends Component {
render() {
return (
<button className="reset">
<Circle />
<Label />
</button>
);
}
}
|
src/common/Socket/Schedule.js | Syncano/syncano-dashboard | import React from 'react';
import { colors as Colors } from 'material-ui/styles/';
import SocketWrapper from './SocketWrapper';
export default React.createClass({
displayName: 'ScheduleSocket',
getDefaultProps() {
return {
tooltip: 'Create a Schedule Socket'
};
},
getStyles() {
return {
iconStyle: {
color: Colors.lime400
}
};
},
render() {
const styles = this.getStyles();
const {
style,
iconStyle,
...other
} = this.props;
return (
<SocketWrapper
{...other}
iconClassName="synicon-socket-schedule"
style={style}
iconStyle={{ ...styles.iconStyle, ...iconStyle }}
/>
);
}
});
|
src/App.js | wescleymatos/iRango | import React, { Component } from 'react';
import { BrowserRouter as Router, Route } from 'react-router-dom';
import Home from './components/Home';
import Restaurantes from './components/Restaurantes';
import Sobre from './components/Sobre';
import Login from './components/Login';
import NovoRestaurante from './components/NovoRestaurante';
import CriarUsuario from './components/CriarUsuario';
class App extends Component {
render() {
return (
<Router>
<div>
<Route exact path="/" component={ Home } />
<Route exact path="/restaurantes" component={ Restaurantes } />
<Route exact path="/sobre" component={ Sobre } />
<Route exact path="/login" component={ Login } />
<Route exact path="/add-restaurante" component={ NovoRestaurante } />
<Route exact path="/add-usuario" component={ CriarUsuario } />
</div>
</Router>
);
}
}
export default App;
|
client/src/app/components/forms/inputs/MaskedInput.js | zraees/sms-project | import React from 'react'
import 'script-loader!jquery.maskedinput/src/jquery.maskedinput.js'
export default class MaskedInput extends React.Component {
componentDidMount() {
var options = {};
if (this.props.maskPlaceholder) options.placeholder = this.props.maskPlaceholder;
$(this.refs.input).mask(this.props.mask, options);
}
render() {
const {maskPlaceholder, mask, ...props} = {...this.props}
return (
<input ref="input" {...props}/>
)
}
} |
actor-apps/app-web/src/app/components/common/MentionDropdown.react.js | WangCrystal/actor-platform | import React from 'react';
import classnames from 'classnames';
import ReactMixin from 'react-mixin';
import addons from 'react/addons';
import { KeyCodes } from 'constants/ActorAppConstants';
import AvatarItem from 'components/common/AvatarItem.react';
const {addons: { PureRenderMixin }} = addons;
const DROPDOWN_ITEM_HEIGHT = 38; // is this right?
let scrollIndex = 0;
@ReactMixin.decorate(PureRenderMixin)
class MentionDropdown extends React.Component {
static propTypes = {
mentions: React.PropTypes.array,
className: React.PropTypes.string,
onSelect: React.PropTypes.func.isRequired,
onClose: React.PropTypes.func
};
constructor(props) {
super(props);
const { mentions } = props;
this.state = {
isShown: mentions && mentions.length > 0,
selectedIndex: 0
};
}
componentWillUnmount() {
this.cleanListeners();
}
componentWillUpdate(nextProps, nextState) {
if (nextState.isShown && !this.state.isShown) {
this.setListeners();
} else if (!nextState.isShown && this.state.isShown) {
this.cleanListeners();
}
}
componentWillReceiveProps(props) {
const { mentions } = props;
this.setState({
isShown: mentions && mentions.length > 0,
selectedIndex: 0
});
}
setListeners() {
document.addEventListener('keydown', this.onKeyDown, false);
document.addEventListener('click', this.closeMentions, false);
}
cleanListeners() {
//console.info('cleanListeners');
document.removeEventListener('keydown', this.onKeyDown, false);
document.removeEventListener('click', this.closeMentions, false);
}
closeMentions = () => {
this.setState({isShown: false});
};
onSelect = (value) => {
const { onSelect } = this.props;
onSelect(value);
};
handleScroll = (top) => {
const menuListNode = React.findDOMNode(this.refs.mentionList);
menuListNode.scrollTop = top;
};
onKeyDown = (event) => {
const { mentions, onClose } = this.props;
const { selectedIndex } = this.state;
const visibleItems = 6;
let index = selectedIndex;
if (index !== null) {
switch (event.keyCode) {
case KeyCodes.ENTER:
event.stopPropagation();
event.preventDefault();
this.onSelect(mentions[selectedIndex]);
break;
case KeyCodes.ARROW_UP:
event.stopPropagation();
event.preventDefault();
if (index > 0) {
index -= 1;
} else if (index === 0) {
index = mentions.length - 1;
}
if (scrollIndex > index) {
scrollIndex = index;
} else if (index === mentions.length - 1) {
scrollIndex = mentions.length - visibleItems;
}
this.handleScroll(scrollIndex * DROPDOWN_ITEM_HEIGHT);
this.setState({selectedIndex: index});
break;
case KeyCodes.ARROW_DOWN:
case KeyCodes.TAB:
event.stopPropagation();
event.preventDefault();
if (index < mentions.length - 1) {
index += 1;
} else if (index === mentions.length - 1) {
index = 0;
}
if (index + 1 > scrollIndex + visibleItems) {
scrollIndex = index + 1 - visibleItems;
} else if (index === 0) {
scrollIndex = 0;
}
this.handleScroll(scrollIndex * DROPDOWN_ITEM_HEIGHT);
this.setState({selectedIndex: index});
break;
default:
}
}
if (event.keyCode === KeyCodes.ESC) {
this.closeMentions();
if (onClose) onClose();
}
};
render() {
const { className, mentions } = this.props;
const { isShown, selectedIndex } = this.state;
const mentionClassName = classnames('mention', {
'mention--opened': isShown
}, className);
const mentionsElements = _.map(mentions, (mention, index) => {
const itemClassName = classnames('mention__list__item', {
'mention__list__item--active': selectedIndex === index
});
const title = mention.isNick ?
[
<span className="nickname">{mention.mentionText}</span>,
<span className="name">{mention.secondText}</span>
]
:
<span className="name">{mention.mentionText}</span>;
return (
<li className={itemClassName}
key={index}
onClick={() => this.onSelect(mention)}
onMouseOver={() => this.setState({selectedIndex: index})}>
<AvatarItem image={mention.peer.avatar}
placeholder={mention.peer.placeholder}
size="tiny"
title={mention.peer.title}/>
<div className="title">{title}</div>
</li>
);
});
if (isShown) {
return (
<div className={mentionClassName}>
<div className="mention__wrapper">
<header className="mention__header">
<div className="pull-left"><strong>tab</strong> or <strong>โ</strong><strong>โ</strong> to navigate</div>
<div className="pull-left"><strong>โต</strong> to select</div>
<div className="pull-right"><strong>esc</strong> to close</div>
</header>
<ul className="mention__list" ref="mentionList">
{mentionsElements}
</ul>
</div>
</div>
);
} else {
return null;
}
}
}
export default MentionDropdown;
|
src/pages/system/index.js | pprimm/ds-contest-material | import React from 'react'
import {Divider} from 'material-ui'
import AppWrapper from '../../components/AppWrapper'
import SystemTitleBar from '../../components/SystemTitleBar'
import StatusList from '../../components/StatusList'
import StatusPanel from '../../components/StatusPanel'
import SystemButtonPanel from '../../components/SystemButtonPanel'
export default function SystemPage() {
return (
<AppWrapper>
<SystemTitleBar />
<div>
<StatusPanel />
<SystemButtonPanel />
<Divider />
<StatusList />
</div>
</AppWrapper>
)
} |
docs/app/Examples/collections/Table/States/TableExampleActive.js | clemensw/stardust | import React from 'react'
import { Table } from 'semantic-ui-react'
const TableExampleActive = () => {
return (
<Table celled>
<Table.Header>
<Table.Row>
<Table.HeaderCell>Name</Table.HeaderCell>
<Table.HeaderCell>Status</Table.HeaderCell>
<Table.HeaderCell>Notes</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
<Table.Row>
<Table.Cell>Jamie</Table.Cell>
<Table.Cell>Approved</Table.Cell>
<Table.Cell>Requires call</Table.Cell>
</Table.Row>
<Table.Row active>
<Table.Cell>John</Table.Cell>
<Table.Cell>Selected</Table.Cell>
<Table.Cell>None</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>Jamie</Table.Cell>
<Table.Cell>Approved</Table.Cell>
<Table.Cell>Requires call</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell active>Jill</Table.Cell>
<Table.Cell>Approved</Table.Cell>
<Table.Cell>None</Table.Cell>
</Table.Row>
</Table.Body>
</Table>
)
}
export default TableExampleActive
|
geonode/contrib/monitoring/frontend/src/components/organisms/error-list/index.js | kartoza/geonode | import React from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import HoverPaper from '../../atoms/hover-paper';
import {
Table,
TableBody,
TableHeader,
TableHeaderColumn,
TableRow,
TableRowColumn,
} from 'material-ui/Table';
import styles from './styles';
import actions from './actions';
const mapStateToProps = (state) => ({
errorList: state.errorList.response,
interval: state.interval.interval,
timestamp: state.interval.timestamp,
});
@connect(mapStateToProps, actions)
class ErrorList extends React.Component {
static contextTypes = {
router: PropTypes.object.isRequired,
}
static propTypes = {
errorList: PropTypes.object,
get: PropTypes.func.isRequired,
interval: PropTypes.number,
timestamp: PropTypes.instanceOf(Date),
}
constructor(props) {
super(props);
this.handleClick = (row, column, event) => {
this.context.router.push(`/errors/${event.target.dataset.id}`);
};
}
componentWillMount() {
this.props.get(this.props.interval);
}
componentWillReceiveProps(nextProps) {
if (nextProps && nextProps.interval) {
if (this.props.timestamp !== nextProps.timestamp) {
this.props.get(nextProps.interval);
}
}
}
render() {
const errorList = this.props.errorList;
const errors = this.props.errorList
? errorList.exceptions.map(
error => <TableRow key={error.id}>
<TableRowColumn data-id={error.id}>{error.id}</TableRowColumn>
<TableRowColumn data-id={error.id}>{error.error_type}</TableRowColumn>
<TableRowColumn data-id={error.id}>{error.service.name}</TableRowColumn>
<TableRowColumn data-id={error.id}>{error.created}</TableRowColumn>
</TableRow>
) : '';
return (
<HoverPaper style={styles.content}>
<div style={styles.header}>
<h3 style={styles.title}>Errors</h3>
</div>
<Table onCellClick={this.handleClick}>
<TableHeader displaySelectAll={false}>
<TableRow>
<TableHeaderColumn>ID</TableHeaderColumn>
<TableHeaderColumn>Type</TableHeaderColumn>
<TableHeaderColumn>Service</TableHeaderColumn>
<TableHeaderColumn>Date</TableHeaderColumn>
</TableRow>
</TableHeader>
<TableBody showRowHover stripedRows displayRowCheckbox={false}>
{errors}
</TableBody>
</Table>
</HoverPaper>
);
}
}
export default ErrorList;
|
src/components/card.js | nfcortega89/nikkotoonaughty | import React from 'react';
export default function Card(props) {
return (
<div className="card pic-card">
<div className="image">
<img src={props.image.images.standard_resolution.url} />
</div>
<div className="card-details">
</div>
</div>
)
}
|
src/containers/organizations/components/IntegrationConfigGenerator.js | dataloom/gallery | import React from 'react';
import styled from 'styled-components';
import StyledInput from '../../../components/controls/StyledInput';
import StyledSelect from '../../../components/controls/StyledSelect';
import InfoButton from '../../../components/buttons/InfoButton';
import { DATA_SQL_TYPES, exportTemplate } from '../utils/IntegrationYamlUtils';
type Props = {
orgId :string,
orgName :string,
orgUsername :string,
orgPassword :string
}
const Container = styled.div`
display: flex;
flex-direction: column;
`;
const InputRow = styled.div`
display: flex;
flex-direction: column;
align-items: center;
font-family: 'Open Sans', sans-serif;
margin: 10px 0;
div {
font-size: 16px;
font-weight: 600;
line-height: normal;
margin: 0 20px 0 0;
}
span {
color: #8e929b;
margin: 10px 0;
}
`;
export default class IntegrationConfigGenerator extends React.Component {
constructor(props) {
super(props);
this.state = {
dataSqlType: '',
server: '',
port: '',
dbName: ''
};
}
onSubmit = () => {
const {
dataSqlType,
server,
port,
dbName
} = this.state;
const {
orgId,
orgName,
orgUsername,
orgPassword
} = this.props;
exportTemplate({
dataSqlType,
server,
port,
dbName,
orgId,
orgName,
orgUsername,
orgPassword
});
}
getOnChange = field => ({ target }) => {
this.setState({ [field]: target.value });
}
onSQLTypeChange = ({ target }) => {
const { port } = this.state;
this.setState({
dataSqlType: target.value,
port: target.value ? DATA_SQL_TYPES[target.value].defaultPort : port
});
}
isReadyToSubmit = () => {
const {
dataSqlType,
server,
port,
dbName
} = this.state;
return dataSqlType && server && port && dbName;
}
render() {
const {
dataSqlType,
server,
port,
dbName
} = this.state;
return (
<Container>
<InputRow>
<div>Target Server</div>
<span>ex. PD database hostname</span>
<StyledInput value={server} onChange={this.getOnChange('server')} />
</InputRow>
<InputRow>
<div>Target Database</div>
<span>ex. PD SQL database name</span>
<StyledInput value={dbName} onChange={this.getOnChange('dbName')} />
</InputRow>
<InputRow>
<div>Target Database SQL Type</div>
<StyledSelect value={dataSqlType} onChange={this.onSQLTypeChange}>
<option value="" />
{
Object.keys(DATA_SQL_TYPES).map(name => <option value={name}>{name}</option>)
}
</StyledSelect>
</InputRow>
<InputRow>
<div>Target Port</div>
<span>ex. PD database port</span>
<StyledInput value={port} onChange={this.getOnChange('port')} />
</InputRow>
<InfoButton disabled={!this.isReadyToSubmit()} onClick={this.onSubmit}>Export</InfoButton>
</Container>
);
}
}
|
src/index.js | easyCZ/react-2048 | import React from 'react';
import { render } from 'react-dom';
import { App } from './App';
render(<App />, document.getElementById('root'));
|
packages/icons/src/md/image/CropPortrait.js | suitejs/suitejs | import React from 'react';
import IconBase from '@suitejs/icon-base';
function MdCropPortrait(props) {
return (
<IconBase viewBox="0 0 48 48" {...props}>
<path d="M34 6c2.21 0 4 1.79 4 4v28c0 2.21-1.79 4-4 4H14c-2.21 0-4-1.79-4-4V10c0-2.21 1.79-4 4-4h20zm0 32V10H14v28h20z" />
</IconBase>
);
}
export default MdCropPortrait;
|
src/components/App.js | Tori1810/Task3 | /**
* React Starter Kit (https://www.reactstarterkit.com/)
*
* Copyright ยฉ 2014-present Kriasoft, LLC. All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE.txt file in the root directory of this source tree.
*/
import React from 'react';
import PropTypes from 'prop-types';
import { IntlProvider } from 'react-intl';
import { Provider as ReduxProvider } from 'react-redux';
const ContextType = {
// Enables critical path CSS rendering
// https://github.com/kriasoft/isomorphic-style-loader
insertCss: PropTypes.func.isRequired,
// Universal HTTP client
fetch: PropTypes.func.isRequired,
// Integrate Redux
// http://redux.js.org/docs/basics/UsageWithReact.html
...ReduxProvider.childContextTypes,
// Apollo Client
client: PropTypes.object.isRequired,
};
/**
* The top-level React component setting context (global) variables
* that can be accessed from all the child components.
*
* https://facebook.github.io/react/docs/context.html
*
* Usage example:
*
* const context = {
* history: createBrowserHistory(),
* store: createStore(),
* };
*
* ReactDOM.render(
* <App context={context}>
* <Layout>
* <LandingPage />
* </Layout>
* </App>,
* container,
* );
*/
class App extends React.PureComponent {
static propTypes = {
context: PropTypes.shape(ContextType).isRequired,
children: PropTypes.element.isRequired,
};
static childContextTypes = ContextType;
getChildContext() {
return this.props.context;
}
componentDidMount() {
const store = this.props.context && this.props.context.store;
if (store) {
this.lastLocale = store.getState().intl.locale;
this.unsubscribe = store.subscribe(() => {
const state = store.getState();
const { newLocale, locale } = state.intl;
if (!newLocale && this.lastLocale !== locale) {
this.lastLocale = locale;
this.forceUpdate();
}
});
}
}
componentWillUnmount() {
if (this.unsubscribe) {
this.unsubscribe();
this.unsubscribe = null;
}
}
render() {
// NOTE: If you need to add or modify header, footer etc. of the app,
// please do that inside the Layout component.
const store = this.props.context && this.props.context.store;
const state = store && store.getState();
this.intl = (state && state.intl) || {};
const { initialNow, locale, messages } = this.intl;
const localeMessages = (messages && messages[locale]) || {};
return (
<IntlProvider
initialNow={initialNow}
locale={locale}
messages={localeMessages}
defaultLocale="en-US"
>
{React.Children.only(this.props.children)}
</IntlProvider>
);
}
}
export default App;
|
src/js/components/EndButton.js | BavoG/onesupportdocu | import React from 'react';
import Up from 'grommet/components/icons/base/Up';
import Button from 'grommet/components/Button';
import Box from 'grommet/components/Box';
const CLASS_ROOT = 'infographic__button';
export default function EndButton (props) {
return (
<Button plain={true} className={`${CLASS_ROOT} ${CLASS_ROOT}--end`} onClick={props.onClick}>
<Box direction="column" align="center" justify="center">
<span className={`${CLASS_ROOT}-icon`}>
<Up a11yTitle={'Scroll to top'} onClick={props.onClick} />
</span>
</Box>
</Button>
);
}
|
packages/lore-hook-forms-material-ui/src/blueprints/update/Wizard/index.js | lore/lore-forms | import React from 'react';
import createReactClass from 'create-react-class';
import Wizard from './Wizard';
export default createReactClass({
render: function() {
const { modelName } = this.props;
const {
model,
schema,
fieldMap,
actionMap,
steps,
data,
validators,
fields,
actions,
...other
} = this.props;
return (
<Wizard
modelName={modelName}
model={model}
schema={schema}
fieldMap={fieldMap}
actionMap={actionMap}
data={data}
steps={steps || [
{
form: 'step',
// steps: [
// 'Enter Data'
// ],
// activeStep: 0,
validators: validators || {},
fields: fields || [
{
key: 'question',
type: 'custom',
props: {
render: (form) => {
return (
<p>
No fields have been provided.
</p>
);
}
}
}
],
actions: actions || [
{
type: 'raised',
props: (form) => {
return {
label: 'Update',
primary: true,
disabled: form.hasError,
onClick: () => {
form.callbacks.onSubmit(form.data)
}
}
}
}
]
},
{
form: 'confirmation'
}
]}
{...other}
/>
);
}
});
|
app/components/Common/PageLoader/index.js | VineRelay/VineRelayStore | import React from 'react';
import styled from 'styled-components';
const Wrapper = styled.div`
`;
const PageLoader = () => (
<Wrapper>
Loading ...
</Wrapper>
);
PageLoader.propTypes = {
};
export default PageLoader;
|
src/containers/Header/index.js | Guseff/services-on-map-demo | import React, { Component } from 'react';
import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
import PropTypes from 'prop-types';
import { Link } from 'react-router-dom';
import LoginMenu from '../../components/LoginMenu';
import {
showLoginMenu,
closeLoginMenu,
} from '../../actions/MarkerActions';
import {
checkLogin,
logOutUser,
loginUser,
} from '../../actions/LoginActions';
import {
showUserModal,
showEditUser,
findOfferer,
} from '../../actions/ModalActions';
import './style.css';
class Header extends Component {
constructor() {
super();
this.photoClick = this.photoClick.bind(this);
}
componentDidMount() {
this.props.checkLogin(localStorage.getItem('token'));
}
photoClick() {
this.props.showLoginMenu();
}
renderUserMenu() {
if (!this.props.loggedUser) {
return null;
}
return (
<div className='user-photo'>
<img alt='' title={`Logged as ${this.props.loggedUser.name}`} src={this.props.loggedUser.photoURL} onClick={this.photoClick} />
</div>
);
}
renderLoginLI() {
if (!this.props.loggedUser) {
return (
<li>
<button href='#' onClick={this.photoClick}>
Log In
</button>
</li>
);
}
return null;
}
render() {
const {
showLogMenu, loggedUser,
closeLoginMenu, logOutUser, loginUser, showUserModal, showEditUser, findOfferer,
} = this.props;
return (
<div className="head">
<div className="logo">
Welcome to Brest service offer App
</div>
{this.renderUserMenu()}
<div className="menu">
<ul>
<li><Link to="/">Home</Link></li>
<li><Link to="/about">About</Link></li>
{this.renderLoginLI()}
</ul>
</div>
<LoginMenu
loggedUser={loggedUser}
showLogMenu={showLogMenu}
closeLoginMenu={closeLoginMenu}
logOutUser={logOutUser}
loginUser={loginUser}
showUserModal={showUserModal}
showEditUser={showEditUser}
findOfferer={findOfferer}
/>
</div>
);
}
}
function mapStateToProps(state) {
return {
loggedUser: state.login.loggedUser,
showLogMenu: state.login.showLogMenu,
}
}
function mapDispatchToProps(dispatch) {
return {
loginUser: bindActionCreators(loginUser, dispatch),
showLoginMenu: bindActionCreators(showLoginMenu, dispatch),
closeLoginMenu: bindActionCreators(closeLoginMenu, dispatch),
logOutUser: bindActionCreators(logOutUser, dispatch),
checkLogin: bindActionCreators(checkLogin, dispatch),
showUserModal: bindActionCreators(showUserModal, dispatch),
showEditUser: bindActionCreators(showEditUser, dispatch),
findOfferer: bindActionCreators(findOfferer, dispatch),
};
}
Header.propTypes = {
loggedUser: PropTypes.object,
showLogMenu: PropTypes.bool.isRequired,
loginUser: PropTypes.func.isRequired,
showLoginMenu: PropTypes.func.isRequired,
closeLoginMenu: PropTypes.func.isRequired,
logOutUser: PropTypes.func.isRequired,
checkLogin: PropTypes.func.isRequired,
showUserModal: PropTypes.func.isRequired,
showEditUser: PropTypes.func.isRequired,
findOfferer: PropTypes.func.isRequired,
}
export default connect(mapStateToProps, mapDispatchToProps)(Header);
|
examples/LinkingExample/__tests__/index.ios.js | half-shell/react-navigation | import 'react-native';
import React from 'react';
import Index from '../index.ios.js';
// Note: test renderer must be required after react-native.
import renderer from 'react-test-renderer';
it('renders correctly', () => {
const tree = renderer.create(
<Index />
);
});
|
src/components/slider/slide/templates/video-overlay.js | adrienhobbs/redux-glow | import React from 'react';
import styles from './video-slide.css';
import {primaryColor} from 'constants/colors';
const VideoOverlay = () => {
return (
<div id='video-home-overlay'>
<div className={styles.video_intro}></div>
<div className={styles.copy_wrap}>
<div className={styles.featured_headline}>
<svg style={{fill: primaryColor}} id='Layer_1' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 500.3 60.5'>
<path d='M33 33.1l-8.1 25.2H14.7L0 18.8h12.9l7.3 23.5 7-23.5h11.6l7 23.5L53 18.8h13L51.2 58.3H41l-8-25.2zm42.1 8.5c.2 4.8 2.2 8.8 8.8 8.8 4.3 0 6.5-2 7.3-4.5h12.3c-1.1 7.5-8.2 13.5-19.5 13.5-13.8 0-21.3-8.6-21.3-20.8 0-11.6 7.3-20.8 21-20.8 12.4 0 20.3 8.4 20.3 18 0 1.6 0 3.4-.4 5.8H75.1zm0-7.2h16.5c0-5.1-3.4-8.3-8.1-8.3-4.8 0-8.4 2.9-8.4 8.3zm90.5-15.6v39.5h-12.5v-5.6c-1.9 3.6-7 6.6-12 6.6-11.4 0-19.3-8.9-19.3-20.7 0-11.8 7.9-20.7 19.3-20.7 5.1 0 10.2 3 12 6.6v-5.7h12.5zm-12.5 19.7c0-5.4-3.8-10.1-9.4-10.1-5.7 0-9.4 4.7-9.4 10.1 0 5.5 3.8 10.1 9.4 10.1 5.6 0 9.4-4.6 9.4-10.1zm45.8-8.3c-1.7-.4-2.7-.6-4.4-.6-6.9 0-11.4 3.6-11.4 13.3v15.4h-12.5V18.8H183v6.4c1.8-3.7 6.6-7 12-7 1.6 0 2.6.2 3.8.7v11.3zm12.4 11.4c.2 4.8 2.2 8.8 8.8 8.8 4.3 0 6.5-2 7.3-4.5h12.3c-1.1 7.5-8.2 13.5-19.5 13.5-13.8 0-21.3-8.6-21.3-20.8 0-11.6 7.3-20.8 21-20.8 12.4 0 20.3 8.4 20.3 18 0 1.6 0 3.4-.4 5.8h-28.5zm0-7.2h16.6c0-5.1-3.4-8.3-8.1-8.3-5 0-8.5 2.9-8.5 8.3zM291.8 27.1h26.7v11.2c-2.1 13.2-12 22.1-28.9 22.1-19.7 0-30.6-13.8-30.6-30.2C259 14.5 270.2 0 289.5 0c16.6 0 27.4 9.8 28.5 21.5h-18.8c-.6-3.3-3.8-6.9-9.8-6.9-9.2 0-12.9 7.8-12.9 15.9 0 8.9 4.6 16 14 16 6.4 0 10-3.6 10.8-8.1h-9.5V27.1zM354.7 44.3v14.6h-32V1.6h17v42.8h15zM354.3 30.2c0-15.8 11.4-30.2 31.1-30.2 19.7 0 31.1 14.4 31.1 30.2s-11.4 30.2-31.1 30.2c-19.7.1-31.1-14.4-31.1-30.2zm44.9 0c0-7.6-5.1-14.7-13.8-14.7-8.7 0-13.8 7-13.8 14.7s5.2 14.7 13.8 14.7c8.8 0 13.8-7 13.8-14.7zM455.3 27.7l-9.6 31.2h-14.8L410.2 1.6h18l10.2 34.2 10.1-34.2h13.6l10 34.2 10.2-34.2h18L479.7 59h-14.9l-9.5-31.3z'/>
</svg>
</div>
<p>We provide real solutions covering the full spectrum of social and digital marketing.</p>
</div>
</div>
);
};
export default VideoOverlay;
|
Native/Learn_TextInput/__tests__/index.ios.js | renxlWin/React-Native_Demo | import 'react-native';
import React from 'react';
import Index from '../index.ios.js';
// Note: test renderer must be required after react-native.
import renderer from 'react-test-renderer';
it('renders correctly', () => {
const tree = renderer.create(
<Index />
);
});
|
Realization/frontend/czechidm-core/src/components/advanced/Icon/ContractGuaranteeRemoveIcon.js | bcvsolutions/CzechIdMng | import React from 'react';
import { faUserTie, faMinusSquare } from '@fortawesome/free-solid-svg-icons';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
//
import AbstractIcon from './AbstractIcon';
import Icon from '../../basic/Icon/Icon';
/**
* Remove assigned identity role.
*
* @author Ondrej Husnik
* @since 10.8.0
*/
export default class ContractGuaranteeRemoveIcon extends AbstractIcon {
renderIcon() {
const { disabled } = this.props;
//
return (
<span className={ this.getClassName('fa-layers fa-fw') }>
<FontAwesomeIcon icon={ faUserTie } transform="left-2"/>
<Icon
level={ disabled ? 'default' : 'danger' }
icon={
<FontAwesomeIcon icon={ faMinusSquare } transform="up-3 right-7 shrink-6"/>
}/>
</span>
);
}
}
|
src/svg-icons/image/flash-off.js | hwo411/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let ImageFlashOff = (props) => (
<SvgIcon {...props}>
<path d="M3.27 3L2 4.27l5 5V13h3v9l3.58-6.14L17.73 20 19 18.73 3.27 3zM17 10h-4l4-8H7v2.18l8.46 8.46L17 10z"/>
</SvgIcon>
);
ImageFlashOff = pure(ImageFlashOff);
ImageFlashOff.displayName = 'ImageFlashOff';
ImageFlashOff.muiName = 'SvgIcon';
export default ImageFlashOff;
|
examples/real-world/routes.js | gajus/redux | import React from 'react'
import { Route } from 'react-router'
import App from './containers/App'
import UserPage from './containers/UserPage'
import RepoPage from './containers/RepoPage'
export default (
<Route path="/" component={App}>
<Route path="/:login/:name"
component={RepoPage} />
<Route path="/:login"
component={UserPage} />
</Route>
)
|
information/blendle-frontend-react-source/app/modules/timeline/components/UpgradeBulletin/Message.js | BramscoChill/BlendleParser | import React from 'react';
import { string, number } from 'prop-types';
function Message({ name, daysLeft }) {
// Last day, with name
if (daysLeft === 0 && name) {
return (
<div className={CSS.message}>
<strong>{name}</strong>, let op! Dit is je <strong>laatste dag</strong> gratis Blendle
Premium. Ook na vandaag toegang houden?
</div>
);
}
// Countdown with name
if (daysLeft === 1 && name) {
return (
<div className={CSS.message}>
<strong>{name}</strong>, je leest Blendle Premium nog <strong>{daysLeft} dag</strong>{' '}
gratis. Ook daarna toegang houden?
</div>
);
}
// Countdown without name
if (daysLeft === 1) {
return (
<div className={CSS.message}>
Je leest Blendle Premium nog <strong>{daysLeft} dag</strong> gratis. Ook daarna
toegang houden?
</div>
);
}
// Last day, without name
if (daysLeft === 0) {
return (
<div className={CSS.message}>
Let op! Dit is je <strong>laatste dag</strong> gratis Blendle Premium. Ook na vandaag
toegang houden?
</div>
);
}
// Expired
if (daysLeft < 0) {
return (
<div className={CSS.message}>
Onbeperkt toegang tot al deze artikelen? Dat kan met Blendle Premium.
</div>
);
}
// Generic countdown with name
if (name) {
return (
<div className={CSS.message}>
<strong>{name}</strong>, je leest Blendle Premium nog <strong>{daysLeft} dagen</strong>{' '}
gratis. Ook daarna toegang houden?
</div>
);
}
// Generic Countdown
return (
<div className={CSS.message}>
Je leest Blendle Premium nog <strong>{daysLeft} dagen</strong> gratis. Ook daarna
toegang houden?
</div>
);
}
Message.propTypes = {
name: string,
daysLeft: number.isRequired,
};
Message.defaultProps = {
name: '',
};
export default Message;
// WEBPACK FOOTER //
// ./src/js/app/modules/timeline/components/UpgradeBulletin/Message.js |
app/Resources/js/containers/home.js | ryota-murakami/daily-tweet | import React from 'react'
import { connect } from 'react-redux'
import ImportModal from '../components/import/importModal'
import Timeline from '../components/timeline'
import Header from '../components/header'
import '../../sass/common/common.scss'
import '../../sass/page/home.scss'
class App extends React.Component {
render() {
return (
<div>
<ImportModal/>
<Header/>
<Timeline/>
</div>
)
}
}
export default connect()(App)
|
packages/frint-react/src/components/getMountableComponent.js | Travix-International/frint | /* eslint-disable import/no-extraneous-dependencies */
import React from 'react';
import Provider from './Provider';
export default function getMountableComponent(app) {
const Component = app.get('component');
const providerProps = { app };
const ComponentInProvider = (componentProps) => {
return (
<Provider {...providerProps}>
<Component {...componentProps} />
</Provider>
);
};
return (props) => {
return <ComponentInProvider {...props} />;
};
}
|
src/components/EmployeeList.js | amir5000/react-native-manager-app | import _ from 'lodash';
import React, { Component } from 'react';
import { ListView } from 'react-native';
import { connect } from 'react-redux';
import { employeeFetch } from '../actions';
import ListItem from './ListItem';
class EmployeeList extends Component {
componentWillMount() {
this.props.employeeFetch();
this.createDataSource(this.props);
}
componentWillReceiveProps(nextProps) {
this.createDataSource(nextProps);
}
createDataSource( { employees } ) {
const ds = new ListView.DataSource({
rowHasChanged: (r1, r2) => r1 !== r2
});
this.dataSource = ds.cloneWithRows(employees);
}
renderRow(employee) {
return <ListItem employee={employee} />;
}
render() {
return (
<ListView
enableEmptySections
dataSource={this.dataSource}
renderRow={this.renderRow}
/>
);
}
}
const mapStateToProps = state => {
const employees = _.map(state.employees, (val, uid) => {
return { ...val, uid };
});
return { employees };
};
export default connect(mapStateToProps, { employeeFetch })(EmployeeList);
|
docs/src/app/components/pages/components/TimePicker/ExampleSimple.js | matthewoates/material-ui | import React from 'react';
import TimePicker from 'material-ui/TimePicker';
const TimePickerExampleSimple = () => (
<div>
<TimePicker
hintText="12hr Format"
/>
<TimePicker
format="24hr"
hintText="24hr Format"
/>
<TimePicker
disabled={true}
format="24hr"
hintText="Disabled TimePicker"
/>
</div>
);
export default TimePickerExampleSimple;
|
src/Stepper/StepLabel.spec.js | manchesergit/material-ui | /* eslint-env mocha */
import React from 'react';
import {shallow} from 'enzyme';
import {assert} from 'chai';
import StepLabel from './StepLabel';
import getMuiTheme from '../styles/getMuiTheme';
describe('<StepLabel />', () => {
const muiTheme = getMuiTheme();
const shallowWithContext = (node, context = {}) => {
return shallow(node, {
context: {
muiTheme,
stepper: {
orientation: 'horizontal',
},
...context,
},
});
};
it('merges styles and other props into the root node', () => {
const wrapper = shallowWithContext(
<StepLabel
style={{paddingRight: 200, color: 'purple', border: '1px solid tomato'}}
data-myProp="hello"
/>
);
const props = wrapper.props();
assert.strictEqual(props.style.paddingRight, 200);
assert.strictEqual(props.style.color, 'purple');
assert.strictEqual(props.style.border, '1px solid tomato');
assert.strictEqual(props['data-myProp'], 'hello');
});
describe('label content', () => {
it('renders the label from children', () => {
const childWrapper = shallowWithContext(
<StepLabel>Step One</StepLabel>
);
assert.ok(childWrapper.contains('Step One'));
});
it('renders the icon from a number with the disabled color', () => {
const wrapper = shallowWithContext(
<StepLabel disabled={true} icon={1}>Step One</StepLabel>
);
const icon = wrapper.find('SvgIcon');
assert.strictEqual(icon.length, 1, 'should have an <SvgIcon />');
assert.strictEqual(
icon.props().color,
muiTheme.stepper.inactiveIconColor,
'should pass the inactive icon color'
);
});
it('renders the custom icon', () => {
const wrapper = shallowWithContext(
<StepLabel icon={<span className="my-icon" />}>Step One</StepLabel>
);
assert.strictEqual(wrapper.find('.my-icon').length, 1, 'should have the custom icon');
});
});
describe('prop: active = false', () => {
it('renders text with no specific font weight', () => {
const wrapper = shallowWithContext(
<StepLabel active={false}>Step One</StepLabel>
);
assert.strictEqual(typeof wrapper.props().style.fontWeight, 'undefined');
});
});
describe('prop: active = true', () => {
it('renders the label text bold', () => {
const wrapper = shallowWithContext(
<StepLabel active={true}>Step One</StepLabel>
);
assert.strictEqual(wrapper.props().style.fontWeight, 500);
});
it('renders with the standard coloring', () => {
const wrapper = shallowWithContext(
<StepLabel active={true} icon={1}>Step One</StepLabel>
);
assert.strictEqual(
wrapper.props().style.color,
muiTheme.stepper.textColor,
'should have the standard text color'
);
const icon = wrapper.find('SvgIcon');
assert.strictEqual(
icon.props().color,
muiTheme.stepper.iconColor,
'should pass the standard icon color'
);
});
});
describe('prop: completed = true', () => {
it('renders the label text with no specific font weight', () => {
const wrapper = shallowWithContext(
<StepLabel completed={true}>Step One</StepLabel>
);
assert.strictEqual(typeof wrapper.props().style.fontWeight, 'undefined');
});
it('renders a check circle with the standard coloring', () => {
const wrapper = shallowWithContext(
<StepLabel completed={true} icon={1}>Step One</StepLabel>
);
assert.strictEqual(
wrapper.props().style.color,
muiTheme.stepper.textColor,
'should have the standard text color'
);
});
});
describe('prop: iconContainerStyle', () => {
it('merges values into the icon container node style prop', () => {
const wrapper = shallowWithContext(
<StepLabel
iconContainerStyle={{width: 64, color: 'lime', paddingBottom: 300, border: '3px solid teal'}}
icon={1}
>
Step One
</StepLabel>
);
const iconContainerStyle = wrapper.find('span').at(1).props().style;
assert.strictEqual(iconContainerStyle.width, 64);
assert.strictEqual(iconContainerStyle.color, 'lime');
assert.strictEqual(iconContainerStyle.paddingBottom, 300);
assert.strictEqual(iconContainerStyle.border, '3px solid teal');
});
});
describe('prop combinations', () => {
it('renders with active styling when active', () => {
const wrapper = shallowWithContext(
<StepLabel icon={1} active={true}>Step One</StepLabel>
);
assert.strictEqual(
wrapper.props().style.color,
muiTheme.stepper.textColor,
'should have the standard text color'
);
const icon = wrapper.find('SvgIcon');
assert.strictEqual(
icon.props().color,
muiTheme.stepper.iconColor,
'should pass the standard icon color'
);
});
it('renders with inactive styling when inactive and not complete', () => {
const wrapper = shallowWithContext(
<StepLabel icon={1}>Step One</StepLabel>
);
assert.strictEqual(
wrapper.props().style.color,
muiTheme.stepper.textColor,
'should have the standard text color'
);
const icon = wrapper.find('SvgIcon');
assert.strictEqual(
icon.props().color,
muiTheme.stepper.inactiveIconColor,
'should pass the inactive icon color'
);
});
it('renders with disabled styling when disabled', () => {
const wrapper = shallowWithContext(
<StepLabel icon={1} disabled={true}>Step One</StepLabel>
);
assert.strictEqual(
wrapper.props().style.color,
muiTheme.stepper.disabledTextColor,
'should have the disabled text color'
);
const icon = wrapper.find('SvgIcon');
assert.strictEqual(
icon.props().color,
muiTheme.stepper.inactiveIconColor,
'should pass the inactive icon color'
);
});
it('renders with a check icon and active styling when completed', () => {
const wrapper = shallowWithContext(
<StepLabel icon={1} completed={true}>Step One</StepLabel>
);
assert.strictEqual(
wrapper.props().style.color,
muiTheme.stepper.textColor,
'should have the standard text color'
);
const icon = wrapper.find('ActionCheckCircle');
assert.strictEqual(
icon.props().color,
muiTheme.stepper.iconColor,
'should pass the standard icon color'
);
});
it('renders with a check icon and disabled when disabled and completed', () => {
const wrapper = shallowWithContext(
<StepLabel icon={1} disabled={true} completed={true}>Step One</StepLabel>
);
assert.strictEqual(
wrapper.props().style.color,
muiTheme.stepper.disabledTextColor,
'should have the disabled text color'
);
const icon = wrapper.find('ActionCheckCircle');
assert.strictEqual(
icon.props().color,
muiTheme.stepper.inactiveIconColor,
'should pass the inactive icon color'
);
});
describe('ID handling', () => {
it('should use the supplied id without overriding', () => {
const id = '12345';
const wrapper = shallowWithContext(
<StepLabel id={id} />
);
assert.strictEqual(wrapper.prop('id'), id, 'should use provided id');
});
it('should generate an id if one not supplied', () => {
const wrapper = shallowWithContext(
<StepLabel />
);
assert.ok(wrapper.props('id'), 'should generate an id if not supplied');
});
it('should have a reference to ID in returned aria-labelledby tag', () => {
const labelledById = '12345';
const wrapper = shallowWithContext(<StepLabel labelledById={labelledById} />);
assert.strictEqual(wrapper.prop('aria-labelledby'),
labelledById, 'aria-labelledby should be the value provided');
});
});
});
});
|
client/fragments/quizzes/debris/index.js | yeoh-joer/synapse | /**
* External dependencies
*/
import React from 'react'
import PropTypes from 'prop-types'
import page from 'page'
/**
* Internal dependencies
*/
import './style.scss'
import Button from 'client/components/button'
import Card from 'client/components/card'
export default class Debris extends React.Component {
static propTypes = {
quizId: PropTypes.string.isRequired,
sections: PropTypes.array.isRequired
}
render() {
const { sections, quizId } = this.props
return (
<div className='debris'>
{ sections.map(function (row, i) {
return (
<Card className='debris__item' key={i}>
<section className='mdc-card__primary'>
<h1 className='mdc-card__title'>{ row.name }</h1>
</section>
<section className='mdc-card__supporting-text cc-color-text--grey-500'>
<div className='cc-ui__ellipsis'>
{ row.description }
</div>
</section>
<section className='mdc-card__actions mdc-card__actions--divider'>
{
row.completed === 0
? <Button compact primary className='mdc-card__action' onClick={() => page(`/quizzes/${quizId}/${row.id}`)}>
Start
</Button>
: <Button compact primary className='mdc-card__action' onClick={() => page(`/quizzes/${quizId}/${row.id}/result`)}>
View
</Button>
}
</section>
</Card>
)
}) }
</div>
)
}
} |
src/main/js/builder/assets/containers/MediBotInput.js | Bernardo-MG/dreadball-toolkit-webpage | import React from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import { setMediBot } from 'builder/assets/actions';
import ObservableNumberInput from 'components/ObservableNumberInput';
import { selectMediBots } from 'builder/assets/selectors';
const MediBotInput = (props) =>
<ObservableNumberInput id={props.id} name={props.name} value={props.value} min={props.min} max={props.max} onChange={props.onChange} />;
MediBotInput.propTypes = {
onChange: PropTypes.func.isRequired,
id: PropTypes.string,
name: PropTypes.string,
min: PropTypes.number,
max: PropTypes.number,
value: PropTypes.number
};
const mapStateToProps = (state) => {
return {
value: selectMediBots(state)
};
};
const mapDispatchToProps = (dispatch) => {
return {
onChange: bindActionCreators(setMediBot, dispatch)
};
};
export default connect(
mapStateToProps,
mapDispatchToProps
)(MediBotInput);
|
spec/javascripts/jsx/blueprint_courses/components/BlueprintModalSpec.js | djbender/canvas-lms | /*
* Copyright (C) 2017 - present Instructure, Inc.
*
* This file is part of Canvas.
*
* Canvas is free software: you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License as published by the Free
* Software Foundation, version 3 of the License.
*
* Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import React from 'react'
import * as enzyme from 'enzyme'
import BlueprintModal from 'jsx/blueprint_courses/components/BlueprintModal'
QUnit.module('BlueprintModal component', {
setup() {
const appElement = document.createElement('div')
appElement.id = 'application'
document.getElementById('fixtures').appendChild(appElement)
},
teardown() {
document.getElementById('fixtures').innerHTML = ''
}
})
const defaultProps = () => ({
isOpen: true
})
const render = (props = defaultProps(), children = <p>content</p>) => (
<BlueprintModal {...props}>{children}</BlueprintModal>
)
test('renders the BlueprintModal component', () => {
const tree = enzyme.shallow(render())
const node = tree.find('ModalBody')
ok(node.exists())
tree.unmount()
})
test('renders the Done button when there are no changes', () => {
const wrapper = enzyme.shallow(render())
const buttons = wrapper.find('ModalFooter').find('Button')
equal(buttons.length, 1)
equal(buttons.at(0).prop('children'), 'Done')
})
test('renders the Checkbox, Save, and Cancel buttons when there are changes', () => {
const props = {
...defaultProps(),
hasChanges: true,
willAddAssociations: true,
canAutoPublishCourses: true
}
const wrapper = enzyme.shallow(render(props))
const buttons = wrapper.find('ModalFooter').find('Button')
equal(buttons.length, 2)
ok(
wrapper
.find('ModalFooter')
.find('Checkbox')
.exists()
)
equal(buttons.at(0).prop('children'), 'Cancel')
equal(buttons.at(1).prop('children'), 'Save')
})
test('renders the Done button when there are changes, but is in the process of saving', () => {
const props = {
...defaultProps(),
hasChanges: true,
isSaving: true
}
const wrapper = enzyme.shallow(render(props))
const buttons = wrapper.find('ModalFooter').find('Button')
equal(buttons.length, 1)
equal(buttons.at(0).prop('children'), 'Done')
})
|
packages/react/components/block.js | iamxiaoma/Framework7 | import React from 'react';
import Utils from '../utils/utils';
import Mixins from '../utils/mixins';
import __reactComponentDispatchEvent from '../runtime-helpers/react-component-dispatch-event.js';
import __reactComponentSlots from '../runtime-helpers/react-component-slots.js';
import __reactComponentSetProps from '../runtime-helpers/react-component-set-props.js';
class F7Block extends React.Component {
constructor(props, context) {
super(props, context);
this.__reactRefs = {};
(() => {
Utils.bindMethods(this, ['onTabShow', 'onTabHide']);
})();
}
onTabShow(el) {
if (this.eventTargetEl !== el) return;
this.dispatchEvent('tabShow tab:show', el);
}
onTabHide(el) {
if (this.eventTargetEl !== el) return;
this.dispatchEvent('tabHide tab:hide', el);
}
render() {
const self = this;
const props = self.props;
const {
className,
inset,
xsmallInset,
smallInset,
mediumInset,
largeInset,
xlargeInset,
strong,
accordionList,
accordionOpposite,
tabs,
tab,
tabActive,
noHairlines,
noHairlinesIos,
noHairlinesMd,
noHairlinesAurora,
id,
style
} = props;
const classes = Utils.classNames(className, 'block', {
inset,
'xsmall-inset': xsmallInset,
'small-inset': smallInset,
'medium-inset': mediumInset,
'large-inset': largeInset,
'xlarge-inset': xlargeInset,
'block-strong': strong,
'accordion-list': accordionList,
'accordion-opposite': accordionOpposite,
tabs,
tab,
'tab-active': tabActive,
'no-hairlines': noHairlines,
'no-hairlines-md': noHairlinesMd,
'no-hairlines-ios': noHairlinesIos,
'no-hairlines-aurora': noHairlinesAurora
}, Mixins.colorClasses(props));
return React.createElement('div', {
id: id,
style: style,
className: classes,
ref: __reactNode => {
this.__reactRefs['el'] = __reactNode;
}
}, this.slots['default']);
}
componentWillUnmount() {
const el = this.refs.el;
if (!el || !this.$f7) return;
this.$f7.off('tabShow', this.onTabShow);
this.$f7.off('tabHide', this.onTabHide);
delete this.eventTargetEl;
}
componentDidMount() {
const self = this;
const el = self.refs.el;
if (!el) return;
self.eventTargetEl = el;
self.$f7ready(f7 => {
f7.on('tabShow', self.onTabShow);
f7.on('tabHide', self.onTabHide);
});
}
get slots() {
return __reactComponentSlots(this.props);
}
dispatchEvent(events, ...args) {
return __reactComponentDispatchEvent(this, events, ...args);
}
get refs() {
return this.__reactRefs;
}
set refs(refs) {}
}
__reactComponentSetProps(F7Block, Object.assign({
id: [String, Number],
className: String,
style: Object,
inset: Boolean,
xsmallInset: Boolean,
smallInset: Boolean,
mediumInset: Boolean,
largeInset: Boolean,
xlargeInset: Boolean,
strong: Boolean,
tabs: Boolean,
tab: Boolean,
tabActive: Boolean,
accordionList: Boolean,
accordionOpposite: Boolean,
noHairlines: Boolean,
noHairlinesMd: Boolean,
noHairlinesIos: Boolean,
noHairlinesAurora: Boolean
}, Mixins.colorProps));
F7Block.displayName = 'f7-block';
export default F7Block; |
web/src/components/Button/Button.js | gianksp/warbots | import React from 'react'
import PropTypes from 'prop-types'
import 'bulma/css/bulma.css'
export const Button = (props) => {
var throwAlert = () => alert("Copy and paste is a design error")
return (
<div>
<div className="columns">
<div className="column is-half">
<a className="button is-danger" onClick={throwAlert}>{props.btnName}</a>
</div>
</div>
</div>
)
}
Button.propTypes = {
btnName: PropTypes.string
} |
src/views/discover/Feedback.js | airloy/objective | /**
* Created by Layman(http://github.com/anysome) on 16/3/4.
*/
import React from 'react';
import {StyleSheet, ScrollView, View, Text, TouchableOpacity, ListView, LayoutAnimation} from 'react-native';
import Button from 'react-native-button';
import moment from 'moment';
import {styles, colors, airloy, api, L, toast} from '../../app';
import util from '../../libs/Util';
import TextArea from '../../widgets/TextArea';
import FeedbackDetail from './FeedbackDetail';
export default class Feedback extends React.Component {
constructor(props) {
super(props);
this.state = {
input: '',
dataSource: new ListView.DataSource({
rowHasChanged: (row1, row2) => true
})
};
this.list = [];
this._input = null;
this._renderRow = this._renderRow.bind(this);
}
componentWillUpdate(props, state) {
if (this.state.dataSource !== state.dataSource) {
LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut);
}
}
componentDidMount() {
this.reload();
}
async reload() {
let result = await airloy.net.httpGet(api.feedback.list);
if (result.success) {
this.list = result.info;
this.setState({
dataSource: this.state.dataSource.cloneWithRows(this.list)
});
} else {
toast(L(result.message));
}
}
async _send() {
if (this.state.input) {
let result = await airloy.net.httpPost(api.feedback.add, {
content: this.state.input,
from: 'Objective'
});
if (result.success) {
this.list.unshift(result.info);
this.setState({
input: '',
dataSource: this.state.dataSource.cloneWithRows(this.list)
});
} else {
toast(L(result.message));
}
} else {
this._input.focus();
}
}
_toReply(rowData) {
this.props.navigator.push({
title: 'ๅๅคๅ้ฆ',
component: FeedbackDetail,
rightButtonIcon: require('../../../resources/icons/trash.png'),
onRightButtonPress: () => this.removeRow(rowData),
navigationBarHidden: false,
passProps: {
data: rowData,
onFeedback: (feedback) => this.updateRow(feedback)
}
});
}
async removeRow(rowData) {
let result = await airloy.net.httpGet(api.feedback.remove, {id: rowData.id});
if (result.success) {
util.removeFromArray(this.list, rowData);
this.setState({
dataSource: this.state.dataSource.cloneWithRows(this.list)
});
this.props.navigator.pop();
} else {
toast(L(result.message));
}
}
updateRow(rowData) {
this.setState({
dataSource: this.state.dataSource.cloneWithRows(this.list)
});
}
_renderRow(rowData, sectionId, rowId) {
return (
<TouchableOpacity style={style.row} onPress={() => this._toReply(rowData)}>
<Text style={styles.navText}>{rowData.content}</Text>
<View style={styles.containerF}>
<Text style={styles.hint}>{rowData.answers + ' ๅๅค'}</Text>
<Text style={styles.hint}>{moment(rowData.createTime).fromNow()}</Text>
</View>
</TouchableOpacity>
);
}
_renderSeparator(sectionId, rowId, adjacentRowHighlighted) {
return <View key={rowId + '_separator'} style={styles.separator}></View>
}
render() {
return (
<ScrollView style={styles.container} keyboardDismissMode='on-drag' keyboardShouldPersistTaps>
<TextArea
ref={(c)=> this._input = c}
defaultValue={this.state.input}
onChangeText={text => this.setState({input:text})}
placeholder="่กไบๆ๏ผๅ ไฝ ๆด็พๅฅฝ๏ผ"
autoFocus={true}/>
<Button
style={styles.buttonText}
containerStyle={styles.button}
activeOpacity={0.5}
onPress={()=>this._send()}>
ๅ้ฆ
</Button>
<ListView style={style.list} initialListSize={10}
enableEmptySections={true}
dataSource={this.state.dataSource}
renderRow={this._renderRow}
renderSeparator={this._renderSeparator}
/>
</ScrollView>
);
}
}
const style = StyleSheet.create({
list: {
marginTop: 20
},
row: {
flexDirection: 'column',
flex: 1,
paddingTop: 5,
paddingBottom: 5
}
});
|
es6/Radio/Radio.js | yurizhang/ishow | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
import React from 'react';
import PropTypes from 'prop-types';
import { default as Component } from '../Common/plugs/index.js'; //ๆไพstyle, classnameๆนๆณ
import '../Common/css/radio.css';
var Radio = function (_Component) {
_inherits(Radio, _Component);
function Radio(props) {
_classCallCheck(this, Radio);
var _this = _possibleConstructorReturn(this, (Radio.__proto__ || Object.getPrototypeOf(Radio)).call(this, props));
_this.state = {
checked: _this.getChecked(props)
};
return _this;
}
_createClass(Radio, [{
key: 'componentWillReceiveProps',
value: function componentWillReceiveProps(props) {
var checked = this.getChecked(props);
if (this.state.checked !== checked) {
this.setState({ checked: checked });
}
}
}, {
key: 'onChange',
value: function onChange(e) {
var checked = e.target.checked;
if (checked) {
if (this.props.onChange) {
this.props.onChange(this.props.value);
}
}
this.setState({ checked: checked });
}
}, {
key: 'onFocus',
value: function onFocus() {
this.setState({
focus: true
});
}
}, {
key: 'onBlur',
value: function onBlur() {
this.setState({
focus: false
});
}
}, {
key: 'getChecked',
value: function getChecked(props) {
return props.model === props.value || Boolean(props.checked);
}
}, {
key: 'render',
value: function render() {
var _state = this.state,
checked = _state.checked,
focus = _state.focus;
var _props = this.props,
disabled = _props.disabled,
value = _props.value,
children = _props.children;
return React.createElement(
'label',
{ style: this.style(), className: this.className('ishow-radio') },
React.createElement(
'span',
{ className: this.classNames({
'ishow-radio__input': true,
'is-checked': checked,
'is-disabled': disabled,
'is-focus': focus
}) },
React.createElement('span', { className: 'ishow-radio__inner' }),
React.createElement('input', {
type: 'radio',
className: 'ishow-radio__original',
checked: checked,
disabled: disabled,
onChange: this.onChange.bind(this),
onFocus: this.onFocus.bind(this),
onBlur: this.onBlur.bind(this)
})
),
React.createElement(
'span',
{ className: 'ishow-radio__label' },
children || value
)
);
}
}]);
return Radio;
}(Component);
Radio.elementType = 'Radio';
export default Radio;
Radio.propTypes = {
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
onChange: PropTypes.func,
disabled: PropTypes.bool,
checked: PropTypes.bool
}; |
modules/components/Students/components/Student/index.js | hmltnbrn/classroom-library | import React from 'react';
import {Link} from 'react-router';
import DocumentTitle from 'react-document-title';
import Paper from 'material-ui/Paper';
import {Table, TableBody, TableHeader, TableHeaderColumn, TableRow, TableRowColumn} from 'material-ui/Table';
import Divider from 'material-ui/Divider';
import moment from "moment";
import * as libraryService from './../../../../services/library-service';
class Student extends React.Component {
constructor(props) {
super(props);
this.state = {
student: {},
current_books: [],
history_books: []
}
}
componentDidMount() {
if (this.props.signedIn === true) {
this.findStudents();
}
else {
this.props.setPageTitle("Student");
}
}
componentWillReceiveProps(nextProps) {
if (this.props.signedIn === false && nextProps.signedIn === true) {
this.findStudents();
}
else if (this.props.signedIn === true && nextProps.signedIn === false) {
this.props.setPageTitle("Student");
}
}
findStudents() {
libraryService.findStudentHistoryById({studentId: this.props.params.studentId})
.then(data => {
this.setState({
student: data.student[0],
current_books: data.out_books,
history_books: data.in_books
}, this.setTitle);
});
}
setTitle() {
let title = this.state.student !== undefined ? this.state.student.name + " " + this.state.student.class : 'Student';
this.props.setPageTitle(title);
}
render() {
let listCurrentBooks = this.state.current_books.map(book => {
let date_out = moment(book.date_out).format('dddd, MMMM D, YYYY');
return (
<TableRow key={book.id}>
<TableRowColumn>{book.title}</TableRowColumn>
<TableRowColumn>{book.level}</TableRowColumn>
<TableRowColumn>{date_out}</TableRowColumn>
</TableRow>
);
});
let listHistoryBooks = this.state.history_books.map(book => {
let date_out = moment(book.date_out).format('dddd, MMMM D, YYYY');
let date_in = moment(book.date_in).format('dddd, MMMM D, YYYY');
return (
<TableRow key={book.id}>
<TableRowColumn>{book.title}</TableRowColumn>
<TableRowColumn>{book.level}</TableRowColumn>
<TableRowColumn>{date_out}</TableRowColumn>
<TableRowColumn>{date_in}</TableRowColumn>
</TableRow>
);
});
if (this.props.signedIn === true) {
return (
<DocumentTitle title={"Library | " + this.state.student.name}>
<div className="students flex flex-column align-center">
<div className="student-active" style={this.state.student.active === true ? {color:'#2E7D32'} : {color:'#C62828'}}>
{this.state.student.active === true ? "Active" : "Inactive"}
</div>
<Divider style={{width:'70%',marginBottom:18}}/>
<Paper className="student-current-paper">
<Table
style={{tableLayout:'auto'}}
bodyStyle={{overflow:'auto'}}
>
<TableHeader
displaySelectAll={false}
adjustForCheckbox={false}
>
<TableRow>
<TableHeaderColumn
colSpan="7"
style={{textAlign:'center',fontSize:18}}
>
Current Books
</TableHeaderColumn>
</TableRow>
</TableHeader>
<TableBody
displayRowCheckbox={false}
>
<TableRow>
<TableHeaderColumn>Book Title</TableHeaderColumn>
<TableHeaderColumn>Level</TableHeaderColumn>
<TableHeaderColumn>Date Checked Out</TableHeaderColumn>
</TableRow>
{listCurrentBooks}
</TableBody>
</Table>
</Paper>
<Paper className="student-history-paper">
<Table
style={{tableLayout:'auto'}}
bodyStyle={{overflow:'auto'}}
>
<TableHeader
displaySelectAll={false}
adjustForCheckbox={false}
>
<TableRow>
<TableHeaderColumn
colSpan="7"
style={{textAlign:'center',fontSize:18}}
>
History
</TableHeaderColumn>
</TableRow>
</TableHeader>
<TableBody
displayRowCheckbox={false}
>
<TableRow>
<TableHeaderColumn>Book Title</TableHeaderColumn>
<TableHeaderColumn>Level</TableHeaderColumn>
<TableHeaderColumn>Date Checked Out</TableHeaderColumn>
<TableHeaderColumn>Date Checked In</TableHeaderColumn>
</TableRow>
{listHistoryBooks}
</TableBody>
</Table>
</Paper>
</div>
</DocumentTitle>
);
}
else {
return (
<DocumentTitle title="Library | Student">
<div className="students flex flex-column align-center">
<p>Sign in to view this page.</p>
</div>
</DocumentTitle>
);
}
}
};
export default Student;
|
actor-apps/app-web/src/app/components/common/State.react.js | fengshao0907/actor-platform | import React from 'react';
import { MessageContentTypes } from 'constants/ActorAppConstants';
class State extends React.Component {
static propTypes = {
message: React.PropTypes.object.isRequired
};
render() {
const { message } = this.props;
if (message.content.content === MessageContentTypes.SERVICE) {
return null;
} else {
let icon = null;
switch(message.state) {
case 'pending':
icon = <i className="status status--penging material-icons">access_time</i>;
break;
case 'sent':
icon = <i className="status status--sent material-icons">done</i>;
break;
case 'received':
icon = <i className="status status--received material-icons">done_all</i>;
break;
case 'read':
icon = <i className="status status--read material-icons">done_all</i>;
break;
case 'error':
icon = <i className="status status--error material-icons">report_problem</i>;
break;
default:
}
return (
<div className="message__status">{icon}</div>
);
}
}
}
export default State;
|
actor-apps/app-web/src/app/components/dialog/messages/Document.react.js | dut3062796s/actor-platform | import React from 'react';
import classnames from 'classnames';
class Document extends React.Component {
static propTypes = {
content: React.PropTypes.object.isRequired,
className: React.PropTypes.string
};
constructor(props) {
super(props);
}
render() {
const { content, className } = this.props;
const documentClassName = classnames(className, 'row');
let availableActions;
if (content.isUploading === true) {
availableActions = <span>Loading...</span>;
} else {
availableActions = <a href={content.fileUrl}>Download</a>;
}
return (
<div className={documentClassName}>
<div className="document row">
<div className="document__icon">
<i className="material-icons">attach_file</i>
</div>
<div className="col-xs">
<span className="document__filename">{content.fileName}</span>
<div className="document__meta">
<span className="document__meta__size">{content.fileSize}</span>
<span className="document__meta__ext">{content.fileExtension}</span>
</div>
<div className="document__actions">
{availableActions}
</div>
</div>
</div>
<div className="col-xs"></div>
</div>
);
}
}
export default Document;
|
app/components/about_page.js | laynemcnish/personal-site | import React from 'react';
import PureComponent from 'react-pure-render/component';
import ShapeTween from './shape_tween';
export default class AboutPage extends PureComponent {
render () {
return (
<div className="row">
<div className="col-md-4 shape-container">
<div id="shape-tween"></div>
<ShapeTween />
</div>
<div className="col-md-8 about-container">
<h2> About page text </h2>
<h3>
"Turmoil has engulfed the Galactic Republic. The taxation of trade routes to outlying star systems is in dispute. Hoping to resolve the matter with a blockade of deadly battleships, the greedy Trade Federation has stopped all shipping to the small planet of Naboo. While the Congress of the Republic endlessly debates this alarming chain of events, the Supreme Chancellor has secretly dispatched two Jedi Knights, the guardians of peace and justice in the galaxy, to settle the conflict...."
</h3>
<h3>
"There is unrest in the Galactic Senate. Several thousand solar systems have declared their intentions to leave the Republic. This separatist movement, under the leadership of the mysterious Count Dooku, has made it difficult for the limited number of Jedi Knights to maintain peace and order in the galaxy. Senator Amidala, the former Queen of Naboo, is returning to the Galactic Senate to vote on the critical issue of creating an ARMY OF THE REPUBLIC to assist the overwhelmed Jedi...."
</h3>
<h3>
"War! The Republic is crumbling under attacks by the ruthless Sith Lord, Count Dooku. There are heroes on both sides. Evil is everywhere. In a stunning move, the fiendish droid leader, General Grievous, has swept into the Republic capital and kidnapped Chancellor Palpatine, leader of the Galactic Senate. As the Separatist Droid Army attempts to flee the besieged capital with their valuable hostage, two Jedi Knights lead a desperate mission to rescue the captive Chancellor...."
</h3>
<h3>
"It is a period of civil war. Rebel spaceships, striking from a hidden base, have won their first victory against the evil Galactic Empire. During the battle, rebel spies managed to steal secret plans to the Empire's ultimate weapon, the DEATH STAR, an armored space station with enough power to destroy an entire planet. Pursued by the Empire's sinister agents, Princess Leia races home aboard her starship, custodian of the stolen plans that can save her people and restore freedom to the galaxy...."
</h3>
<h3>
"It is a dark time for the Rebellion. Although the Death Star has been destroyed, Imperial troops have driven the Rebel forces from their hidden base and pursued them across the galaxy. Evading the dreaded Imperial Starfleet, a group of freedom fighters led by Luke Skywalker has established a new secret base on the remote ice world of Hoth. The evil lord Darth Vader, obsessed with finding young Skywalker, has dispatched thousands of remote probes into the far reaches of space..."
</h3>
<h3>
"Luke Skywalker has returned to his home planet of Tatooine in an attempt to rescue his friend Han Solo from the clutches of the vile gangster Jabba the Hutt. Little does Luke know that the GALACTIC EMPIRE has secretly begun construction on a new armored space station even more powerful than the first dreaded Death Star. When completed, this ultimate weapon will spell certain doom for the small band of rebels struggling to restore freedom to the galaxy...."
</h3>
</div>
</div>
);
}
}
|
node_modules/react-native/Libraries/Text/Text.js | Ten-Wang/hackfoldr-android | /**
* 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.
*
* @providesModule Text
* @flow
*/
'use strict';
const NativeMethodsMixin = require('react/lib/NativeMethodsMixin');
const Platform = require('Platform');
const React = require('React');
const ReactNativeViewAttributes = require('ReactNativeViewAttributes');
const StyleSheetPropType = require('StyleSheetPropType');
const TextStylePropTypes = require('TextStylePropTypes');
const Touchable = require('Touchable');
const createReactNativeComponentClass =
require('react/lib/createReactNativeComponentClass');
const merge = require('merge');
const mergeFast = require('mergeFast');
const stylePropType = StyleSheetPropType(TextStylePropTypes);
const viewConfig = {
validAttributes: mergeFast(ReactNativeViewAttributes.UIView, {
isHighlighted: true,
numberOfLines: true,
ellipsizeMode: true,
allowFontScaling: true,
selectable: true,
adjustsFontSizeToFit: true,
minimumFontScale: true,
}),
uiViewClassName: 'RCTText',
};
/**
* A React component for displaying text.
*
* `Text` supports nesting, styling, and touch handling.
*
* In the following example, the nested title and body text will inherit the `fontFamily` from
*`styles.baseText`, but the title provides its own additional styles. The title and body will
* stack on top of each other on account of the literal newlines:
*
* ```ReactNativeWebPlayer
* import React, { Component } from 'react';
* import { AppRegistry, Text, StyleSheet } from 'react-native';
*
* class TextInANest extends Component {
* constructor(props) {
* super(props);
* this.state = {
* titleText: "Bird's Nest",
* bodyText: 'This is not really a bird nest.'
* };
* }
*
* render() {
* return (
* <Text style={styles.baseText}>
* <Text style={styles.titleText} onPress={this.onPressTitle}>
* {this.state.titleText}<br /><br />
* </Text>
* <Text numberOfLines={5}>
* {this.state.bodyText}
* </Text>
* </Text>
* );
* }
* }
*
* const styles = StyleSheet.create({
* baseText: {
* fontFamily: 'Cochin',
* },
* titleText: {
* fontSize: 20,
* fontWeight: 'bold',
* },
* });
*
* // App registration and rendering
* AppRegistry.registerComponent('TextInANest', () => TextInANest);
* ```
*/
const Text = React.createClass({
propTypes: {
/**
* This can be one of the following values:
*
* - `head` - The line is displayed so that the end fits in the container and the missing text
* at the beginning of the line is indicated by an ellipsis glyph. e.g., "...wxyz"
* - `middle` - The line is displayed so that the beginning and end fit in the container and the
* missing text in the middle is indicated by an ellipsis glyph. "ab...yz"
* - `tail` - The line is displayed so that the beginning fits in the container and the
* missing text at the end of the line is indicated by an ellipsis glyph. e.g., "abcd..."
* - `clip` - Lines are not drawn past the edge of the text container.
*
* The default is `tail`.
*
* `numberOfLines` must be set in conjunction with this prop.
*
* > `clip` is working only for iOS
*/
ellipsizeMode: React.PropTypes.oneOf(['head', 'middle', 'tail', 'clip']),
/**
* Used to truncate the text with an ellipsis after computing the text
* layout, including line wrapping, such that the total number of lines
* does not exceed this number.
*
* This prop is commonly used with `ellipsizeMode`.
*/
numberOfLines: React.PropTypes.number,
/**
* Invoked on mount and layout changes with
*
* `{nativeEvent: {layout: {x, y, width, height}}}`
*/
onLayout: React.PropTypes.func,
/**
* This function is called on press.
*
* e.g., `onPress={() => console.log('1st')}``
*/
onPress: React.PropTypes.func,
/**
* This function is called on long press.
*
* e.g., `onLongPress={this.increaseSize}>``
*/
onLongPress: React.PropTypes.func,
/**
* Lets the user select text, to use the native copy and paste functionality.
*
* @platform android
*/
selectable: React.PropTypes.bool,
/**
* When `true`, no visual change is made when text is pressed down. By
* default, a gray oval highlights the text on press down.
*
* @platform ios
*/
suppressHighlighting: React.PropTypes.bool,
style: stylePropType,
/**
* Used to locate this view in end-to-end tests.
*/
testID: React.PropTypes.string,
/**
* Specifies whether fonts should scale to respect Text Size accessibility setting on iOS. The
* default is `true`.
*
* @platform ios
*/
allowFontScaling: React.PropTypes.bool,
/**
* When set to `true`, indicates that the view is an accessibility element. The default value
* for a `Text` element is `true`.
*
* See the
* [Accessibility guide](/react-native/docs/accessibility.html#accessible-ios-android)
* for more information.
*/
accessible: React.PropTypes.bool,
/**
* Specifies whether font should be scaled down automatically to fit given style constraints.
* @platform ios
*/
adjustsFontSizeToFit: React.PropTypes.bool,
/**
* Specifies smallest possible scale a font can reach when adjustsFontSizeToFit is enabled. (values 0.01-1.0).
* @platform ios
*/
minimumFontScale: React.PropTypes.number,
},
getDefaultProps(): Object {
return {
accessible: true,
allowFontScaling: true,
ellipsizeMode: 'tail',
};
},
getInitialState: function(): Object {
return mergeFast(Touchable.Mixin.touchableGetInitialState(), {
isHighlighted: false,
});
},
mixins: [NativeMethodsMixin],
viewConfig: viewConfig,
getChildContext(): Object {
return {isInAParentText: true};
},
childContextTypes: {
isInAParentText: React.PropTypes.bool
},
contextTypes: {
isInAParentText: React.PropTypes.bool
},
/**
* Only assigned if touch is needed.
*/
_handlers: (null: ?Object),
_hasPressHandler(): boolean {
return !!this.props.onPress || !!this.props.onLongPress;
},
/**
* These are assigned lazily the first time the responder is set to make plain
* text nodes as cheap as possible.
*/
touchableHandleActivePressIn: (null: ?Function),
touchableHandleActivePressOut: (null: ?Function),
touchableHandlePress: (null: ?Function),
touchableHandleLongPress: (null: ?Function),
touchableGetPressRectOffset: (null: ?Function),
render(): ReactElement<any> {
let newProps = this.props;
if (this.props.onStartShouldSetResponder || this._hasPressHandler()) {
if (!this._handlers) {
this._handlers = {
onStartShouldSetResponder: (): bool => {
const shouldSetFromProps = this.props.onStartShouldSetResponder &&
this.props.onStartShouldSetResponder();
const setResponder = shouldSetFromProps || this._hasPressHandler();
if (setResponder && !this.touchableHandleActivePressIn) {
// Attach and bind all the other handlers only the first time a touch
// actually happens.
for (const key in Touchable.Mixin) {
if (typeof Touchable.Mixin[key] === 'function') {
(this: any)[key] = Touchable.Mixin[key].bind(this);
}
}
this.touchableHandleActivePressIn = () => {
if (this.props.suppressHighlighting || !this._hasPressHandler()) {
return;
}
this.setState({
isHighlighted: true,
});
};
this.touchableHandleActivePressOut = () => {
if (this.props.suppressHighlighting || !this._hasPressHandler()) {
return;
}
this.setState({
isHighlighted: false,
});
};
this.touchableHandlePress = (e: SyntheticEvent) => {
this.props.onPress && this.props.onPress(e);
};
this.touchableHandleLongPress = (e: SyntheticEvent) => {
this.props.onLongPress && this.props.onLongPress(e);
};
this.touchableGetPressRectOffset = function(): RectOffset {
return PRESS_RECT_OFFSET;
};
}
return setResponder;
},
onResponderGrant: function(e: SyntheticEvent, dispatchID: string) {
this.touchableHandleResponderGrant(e, dispatchID);
this.props.onResponderGrant &&
this.props.onResponderGrant.apply(this, arguments);
}.bind(this),
onResponderMove: function(e: SyntheticEvent) {
this.touchableHandleResponderMove(e);
this.props.onResponderMove &&
this.props.onResponderMove.apply(this, arguments);
}.bind(this),
onResponderRelease: function(e: SyntheticEvent) {
this.touchableHandleResponderRelease(e);
this.props.onResponderRelease &&
this.props.onResponderRelease.apply(this, arguments);
}.bind(this),
onResponderTerminate: function(e: SyntheticEvent) {
this.touchableHandleResponderTerminate(e);
this.props.onResponderTerminate &&
this.props.onResponderTerminate.apply(this, arguments);
}.bind(this),
onResponderTerminationRequest: function(): bool {
// Allow touchable or props.onResponderTerminationRequest to deny
// the request
var allowTermination = this.touchableHandleResponderTerminationRequest();
if (allowTermination && this.props.onResponderTerminationRequest) {
allowTermination = this.props.onResponderTerminationRequest.apply(this, arguments);
}
return allowTermination;
}.bind(this),
};
}
newProps = {
...this.props,
...this._handlers,
isHighlighted: this.state.isHighlighted,
};
}
if (Touchable.TOUCH_TARGET_DEBUG && newProps.onPress) {
newProps = {
...newProps,
style: [this.props.style, {color: 'magenta'}],
};
}
if (this.context.isInAParentText) {
return <RCTVirtualText {...newProps} />;
} else {
return <RCTText {...newProps} />;
}
},
});
type RectOffset = {
top: number,
left: number,
right: number,
bottom: number,
}
var PRESS_RECT_OFFSET = {top: 20, left: 20, right: 20, bottom: 30};
var RCTText = createReactNativeComponentClass(viewConfig);
var RCTVirtualText = RCTText;
if (Platform.OS === 'android') {
RCTVirtualText = createReactNativeComponentClass({
validAttributes: mergeFast(ReactNativeViewAttributes.UIView, {
isHighlighted: true,
}),
uiViewClassName: 'RCTVirtualText',
});
}
module.exports = Text;
|
src/containers/toputilizers/containers/TopUtilizersSelectionRowContainer.js | kryptnostic/gallery | import React from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import Immutable from 'immutable';
import * as actionFactory from '../TopUtilizersActionFactory';
import TopUtilizersSelectionRow from '../components/TopUtilizersSelectionRow';
class TopUtilizersSelectionRowContainer extends React.Component {
static propTypes = {
neighborTypes: PropTypes.instanceOf(Immutable.List).isRequired,
entitySetTitle: PropTypes.string.isRequired,
updateEdgeTypes: PropTypes.func.isRequired,
selectedEdges: PropTypes.instanceOf(Immutable.List).isRequired
}
updateEdgeTypes = (options) => {
const selectedEdges = options.map((option) => {
return {
associationTypeId: option.assocId,
neighborTypeIds: [option.neighborId],
utilizerIsSrc: option.src
};
});
this.props.updateEdgeTypes(Immutable.fromJS(selectedEdges));
}
render() {
return (
<TopUtilizersSelectionRow
entitySetTitle={this.props.entitySetTitle}
neighborTypes={this.props.neighborTypes}
updateEdgeTypes={this.updateEdgeTypes}
selectedEdges={this.props.selectedEdges} />
);
}
}
function mapStateToProps(state) {
const topUtilizers = state.get('topUtilizers');
return {
neighborTypes: topUtilizers.get('neighborTypes', Immutable.List()),
selectedEdges: topUtilizers.get('topUtilizersDetailsList', Immutable.List())
};
}
function mapDispatchToProps(dispatch) {
const actions = {
updateEdgeTypes: actionFactory.updateEdgeTypes
};
return bindActionCreators(actions, dispatch);
}
export default connect(mapStateToProps, mapDispatchToProps)(TopUtilizersSelectionRowContainer);
|
app/javascript/mastodon/features/ui/components/drawer_loading.js | imas/mastodon | import React from 'react';
const DrawerLoading = () => (
<div className='drawer'>
<div className='drawer__pager'>
<div className='drawer__inner' />
</div>
</div>
);
export default DrawerLoading;
|
client/src/components/HistoricElementView/HistoricElementView.js | dnadesign/silverstripe-elemental | import React from 'react';
import i18n from 'i18n';
import classnames from 'classnames';
const ElementalAreaHistoryFactory = (FieldGroup) =>
class HistoricElementView extends FieldGroup {
getClassName() {
const classlist = [super.getClassName()];
if (this.props.data.ElementID) {
classlist.unshift('elemental-area__element--historic-inner');
}
return classnames(classlist);
}
render() {
const legend = this.getLegend();
const Tag = this.props.data.tag || 'div';
const classNames = this.getClassName();
const { data } = this.props;
if (!data.ElementID) {
return super.render();
}
return (
<Tag className={classNames}>
{legend}
<div className={'elemental-preview elemental-preview--historic'}>
{data.ElementEditLink &&
<a className="elemental-preview__link" href={data.ElementEditLink}>
<span className="elemental-preview__link-text">{i18n._t('HistoricElementView.VIEW_BLOCK_HISTORY', 'Block history')}</span>
<i className="font-icon-angle-right btn--icon-lg elemental-preview__link-caret" />
</a>
}
<div className={'elemental-preview__icon'}><i className={data.ElementIcon} /></div>
<div className={'elemental-preview__detail'}>
<h3>{data.ElementTitle} <small>{data.ElementType}</small></h3>
</div>
</div>
{this.props.children}
</Tag>
);
}
};
export default ElementalAreaHistoryFactory;
|
src/svg-icons/maps/local-play.js | lawrence-yu/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let MapsLocalPlay = (props) => (
<SvgIcon {...props}>
<path d="M20 12c0-1.1.9-2 2-2V6c0-1.1-.9-2-2-2H4c-1.1 0-1.99.9-1.99 2v4c1.1 0 1.99.9 1.99 2s-.89 2-2 2v4c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2v-4c-1.1 0-2-.9-2-2zm-4.42 4.8L12 14.5l-3.58 2.3 1.08-4.12-3.29-2.69 4.24-.25L12 5.8l1.54 3.95 4.24.25-3.29 2.69 1.09 4.11z"/>
</SvgIcon>
);
MapsLocalPlay = pure(MapsLocalPlay);
MapsLocalPlay.displayName = 'MapsLocalPlay';
MapsLocalPlay.muiName = 'SvgIcon';
export default MapsLocalPlay;
|
src/components/Hero/Hero.js | webpack/analyse-tool | import React from 'react';
import styles from './Hero.scss';
import classNames from 'classnames';
export default class Hero extends React.Component {
static displayName = 'Hero';
static propTypes = {
children: React.PropTypes.node,
displayUnderNavbar: React.PropTypes.bool,
small: React.PropTypes.bool,
};
render() {
const classes = classNames({
[styles.hero]: true,
[styles['move-up']]: this.props.displayUnderNavbar,
[styles['hero-small']]: this.props.small,
});
return (
<div className={ classes }>
{this.props.children}
</div>
);
}
}
|
src/svg-icons/maps/local-gas-station.js | ichiohta/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let MapsLocalGasStation = (props) => (
<SvgIcon {...props}>
<path d="M19.77 7.23l.01-.01-3.72-3.72L15 4.56l2.11 2.11c-.94.36-1.61 1.26-1.61 2.33 0 1.38 1.12 2.5 2.5 2.5.36 0 .69-.08 1-.21v7.21c0 .55-.45 1-1 1s-1-.45-1-1V14c0-1.1-.9-2-2-2h-1V5c0-1.1-.9-2-2-2H6c-1.1 0-2 .9-2 2v16h10v-7.5h1.5v5c0 1.38 1.12 2.5 2.5 2.5s2.5-1.12 2.5-2.5V9c0-.69-.28-1.32-.73-1.77zM12 10H6V5h6v5zm6 0c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1z"/>
</SvgIcon>
);
MapsLocalGasStation = pure(MapsLocalGasStation);
MapsLocalGasStation.displayName = 'MapsLocalGasStation';
MapsLocalGasStation.muiName = 'SvgIcon';
export default MapsLocalGasStation;
|
packages/react/components/messagebar-attachment.js | AdrianV/Framework7 | import React from 'react';
import Utils from '../utils/utils';
import Mixins from '../utils/mixins';
import __reactComponentDispatchEvent from '../runtime-helpers/react-component-dispatch-event.js';
import __reactComponentSlots from '../runtime-helpers/react-component-slots.js';
import __reactComponentSetProps from '../runtime-helpers/react-component-set-props.js';
class F7MessagebarAttachment extends React.Component {
constructor(props, context) {
super(props, context);
(() => {
this.onClickBound = this.onClick.bind(this);
this.onDeleteClickBound = this.onDeleteClick.bind(this);
})();
}
onClick(e) {
this.dispatchEvent('attachment:click attachmentClick', e);
}
onDeleteClick(e) {
this.dispatchEvent('attachment:delete attachmentDelete', e);
}
render() {
const self = this;
const props = self.props;
const {
deletable,
image,
className,
id,
style
} = props;
const classes = Utils.classNames(className, 'messagebar-attachment', Mixins.colorClasses(props));
return React.createElement('div', {
id: id,
style: style,
className: classes,
onClick: self.onClickBound
}, image && React.createElement('img', {
src: image
}), deletable && React.createElement('span', {
className: 'messagebar-attachment-delete',
onClick: self.onDeleteClickBound
}), this.slots['default']);
}
get slots() {
return __reactComponentSlots(this.props);
}
dispatchEvent(events, ...args) {
return __reactComponentDispatchEvent(this, events, ...args);
}
}
__reactComponentSetProps(F7MessagebarAttachment, Object.assign({
id: [String, Number],
image: String,
deletable: {
type: Boolean,
default: true
}
}, Mixins.colorProps));
F7MessagebarAttachment.displayName = 'f7-messagebar-attachment';
export default F7MessagebarAttachment; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.