path
stringlengths 5
296
| repo_name
stringlengths 5
85
| content
stringlengths 25
1.05M
|
|---|---|---|
src/pages/404.js
|
EricSSartorius/homepage
|
import React from 'react'
const NotFoundPage = () => (
<div className="not-found">
<h1>NOT FOUND</h1>
<p>You just hit a route that doesn't exist... the sadness.</p>
</div>
)
export default NotFoundPage
|
packages/mcs-lite-mobile-web/src/containers/DeviceDetailInfo/DeviceDetailInfo.js
|
MCS-Lite/mcs-lite
|
import PropTypes from 'prop-types';
import React from 'react';
import Helmet from 'react-helmet';
import B from 'mcs-lite-ui/lib/B';
import P from 'mcs-lite-ui/lib/P';
import MobileHeader from 'mcs-lite-ui/lib/MobileHeader';
import { updatePathname } from 'mcs-lite-ui/lib/utils/routerHelper';
import IconArrowLeft from 'mcs-lite-icon/lib/IconArrowLeft';
import { Link } from 'react-router';
import { Container } from './styled-components';
class DeviceDetailInfo extends React.Component {
static propTypes = {
// React-router Params
deviceId: PropTypes.string.isRequired,
// Redux State
device: PropTypes.object,
// Redux Action
fetchDeviceDetail: PropTypes.func.isRequired,
// React-intl I18n
getMessages: PropTypes.func.isRequired,
};
componentWillMount = () => this.props.fetchDeviceDetail(this.props.deviceId);
render() {
const { deviceId, device, getMessages: t } = this.props;
return (
<div>
<Helmet>
<title>{t('deviceIntro')}</title>
</Helmet>
<MobileHeader.MobileHeader
title={t('deviceIntro')}
leftChildren={
<MobileHeader.MobileHeaderIcon
component={Link}
to={updatePathname(`/devices/${deviceId}`)}
>
<IconArrowLeft />
</MobileHeader.MobileHeaderIcon>
}
/>
<main>
{device && (
<Container>
<div>
<B>{t('deviceName')}</B>
<P>{device.deviceName}</P>
</div>
<div>
<B>{t('creator')}</B>
<P>{device.user.userName}</P>
</div>
<div>
<B>{t('version')}</B>
<P>{device.prototype.version}</P>
</div>
<div>
<B>{t('description')}</B>
<P>{device.deviceDescription}</P>
</div>
<div>
<B>DeviceId</B>
<P>{device.deviceId}</P>
</div>
<div>
<B>DeviceKey</B>
<P>{device.deviceKey}</P>
</div>
</Container>
)}
</main>
</div>
);
}
}
export default DeviceDetailInfo;
|
app/src/index.js
|
NomadGraphix/csc-final-project-2017
|
import React from 'react';
import ReactDOM from 'react-dom';
import App from './components/App';
function main() {
const app = document.createElement('div');
document.body.appendChild(app);
ReactDOM.render(<App />, app);
}
main();
|
packages/mineral-ui-icons/src/IconNaturePeople.js
|
mineral-ui/mineral-ui
|
/* @flow */
import React from 'react';
import Icon from 'mineral-ui/Icon';
import type { IconProps } from 'mineral-ui/Icon/types';
/* eslint-disable prettier/prettier */
export default function IconNaturePeople(props: IconProps) {
const iconProps = {
rtl: false,
...props
};
return (
<Icon {...iconProps}>
<g>
<path d="M22.17 9.17c0-3.87-3.13-7-7-7s-7 3.13-7 7A6.98 6.98 0 0 0 14 16.06V20H6v-3h1v-4c0-.55-.45-1-1-1H3c-.55 0-1 .45-1 1v4h1v5h16v-2h-3v-3.88a7 7 0 0 0 6.17-6.95zM4.5 11c.83 0 1.5-.67 1.5-1.5S5.33 8 4.5 8 3 8.67 3 9.5 3.67 11 4.5 11z"/>
</g>
</Icon>
);
}
IconNaturePeople.displayName = 'IconNaturePeople';
IconNaturePeople.category = 'image';
|
stories/Pagination.stories.js
|
react-materialize/react-materialize
|
import React from 'react';
import { storiesOf } from '@storybook/react';
import Pagination from '../src/Pagination';
const stories = storiesOf('Components/Pagination', module);
stories.addParameters({
info: {
text: `Add pagination links to help split up your long content into shorter, easier to understand blocks. You just have to provide the items and onSelect attribute, when clicked, the onSelect function will be called with the page number. Otherwise you can customize the page button with PaginationButton component.`
}
});
stories.add('Default', () => <Pagination items={10} maxButtons={8} />);
stories.add('with activePage', () => <Pagination items={5} activePage={3} />);
|
modules/experiences/client/components/create-experience/SubmittedInfo.js
|
Trustroots/trustroots
|
// External dependencies
import { useTranslation, Trans } from 'react-i18next';
import PropTypes from 'prop-types';
import React from 'react';
// Internal dependencies
import '@/config/client/i18n';
import { DAYS_TO_REPLY } from '../../utils/constants';
import SuccessMessage from '@/modules/core/client/components/SuccessMessage';
/**
* Info after successful submitting of a new experience.
*/
export default function SubmittedInfo({
isPublic,
isReported,
name,
username,
}) {
const { t } = useTranslation('experiences');
return (
<SuccessMessage
title={t('Thank you for sharing your experience!')}
cta={
<a
className="btn btn-primary"
href={`/profile/${username}/experiences`}
>
{t('See their experiences')}
</a>
}
>
<p>
{isPublic
? t('Your experience with {{name}} is public now.', { name })
: t(
'Your experience will become public when {{name}} shares their experience, or at most in {{count}} days.',
{ name, count: DAYS_TO_REPLY },
)}
</p>
{isReported && (
<p>
{/* @TODO remove ns (issue #1368) */}
<Trans t={t} ns="experiences">
You also reported them to us. Please do{' '}
<a href="/support">get in touch with us</a> if you have any further
info to add.
</Trans>
</p>
)}
</SuccessMessage>
);
}
SubmittedInfo.propTypes = {
isPublic: PropTypes.bool.isRequired,
isReported: PropTypes.bool.isRequired,
name: PropTypes.string.isRequired,
username: PropTypes.string.isRequired,
};
|
js/components/App.js
|
sogko/todomvc-relay-go
|
import React from 'react';
import Relay from 'react-relay';
class App extends React.Component {
render() {
return (
<div>
<h1>Widget list</h1>
<ul>
{this.props.viewer.widgets.edges.map(edge =>
<li>{edge.node.name} (ID: {edge.node.id})</li>
)}
</ul>
</div>
);
}
}
export default Relay.createContainer(App, {
fragments: {
viewer: () => Relay.QL`
fragment on User {
widgets(first: 10) {
edges {
node {
id,
name,
},
},
},
}
`,
},
});
|
docs/src/PageFooter.js
|
mcraiganthony/react-bootstrap
|
import React from 'react';
import packageJSON from '../../package.json';
let version = packageJSON.version;
if (/docs/.test(version)) {
version = version.split('-')[0];
}
const PageHeader = React.createClass({
render() {
return (
<footer className='bs-docs-footer' role='contentinfo'>
<div className='container'>
<div className='bs-docs-social'>
<ul className='bs-docs-social-buttons'>
<li>
<iframe className='github-btn'
src='http://ghbtns.com/github-btn.html?user=react-bootstrap&repo=react-bootstrap&type=watch&count=true'
width={95}
height={20}
title='Star on GitHub' />
</li>
<li>
<iframe className='github-btn'
src='http://ghbtns.com/github-btn.html?user=react-bootstrap&repo=react-bootstrap&type=fork&count=true'
width={92}
height={20}
title='Fork on GitHub' />
</li>
<li>
<iframe
src="http://platform.twitter.com/widgets/follow_button.html?screen_name=react_bootstrap&show_screen_name=true"
width={230}
height={20}
allowTransparency="true"
frameBorder='0'
scrolling='no'>
</iframe>
</li>
</ul>
</div>
<p>Code licensed under <a href='https://github.com/react-bootstrap/react-bootstrap/blob/master/LICENSE' target='_blank'>MIT</a>.</p>
<ul className='bs-docs-footer-links muted'>
<li>Currently v{version}</li>
<li>·</li>
<li><a href='https://github.com/react-bootstrap/react-bootstrap/'>GitHub</a></li>
<li>·</li>
<li><a href='https://github.com/react-bootstrap/react-bootstrap/issues?state=open'>Issues</a></li>
<li>·</li>
<li><a href='https://github.com/react-bootstrap/react-bootstrap/releases'>Releases</a></li>
</ul>
</div>
</footer>
);
}
});
export default PageHeader;
|
src/inputs/components/input-types/select-input.js
|
juttle/juttle-client-library
|
import React, { Component } from 'react';
import Select from 'react-select';
class SelectInput extends Component {
handleChange(chosenOption) {
this.props.inputUpdate(chosenOption.value);
}
render() {
let { value, options } = this.props.input;
return (
<div className="form-group">
<Select
name="form-field-name"
value={value}
options={options.items}
clearable={false}
onChange={this.handleChange.bind(this)}
/>
</div>
);
}
}
export default SelectInput;
|
fields/types/email/EmailColumn.js
|
codevlabs/keystone
|
import React from 'react';
import ItemsTableCell from '../../../admin/client/components/ItemsTableCell';
import ItemsTableValue from '../../../admin/client/components/ItemsTableValue';
var EmailColumn = React.createClass({
displayName: 'EmailColumn',
propTypes: {
col: React.PropTypes.object,
data: React.PropTypes.object,
},
renderValue () {
let value = this.props.data.fields[this.props.col.path];
if (!value) return;
return (
<ItemsTableValue href={'mailto:'+ value} padded exterior field={this.props.col.type}>
{value}
</ItemsTableValue>
);
},
render () {
let value = this.props.data.fields[this.props.col.path];
return (
<ItemsTableCell>
{this.renderValue()}
</ItemsTableCell>
);
}
});
module.exports = EmailColumn;
|
examples/sidebar/app.js
|
okcoker/react-router
|
import React from 'react';
import { Router, Route, Link } from 'react-router';
import data from './data';
var Category = React.createClass({
render() {
var category = data.lookupCategory(this.props.params.category);
return (
<div>
<h1>{category.name}</h1>
{this.props.children || (
<p>{category.description}</p>
)}
</div>
);
}
});
var CategorySidebar = React.createClass({
render() {
var category = data.lookupCategory(this.props.params.category);
return (
<div>
<Link to="/">◀︎ Back</Link>
<h2>{category.name} Items</h2>
<ul>
{category.items.map((item, index) => (
<li key={index}>
<Link to={`/category/${category.name}/${item.name}`}>{item.name}</Link>
</li>
))}
</ul>
</div>
);
}
});
var Item = React.createClass({
render() {
var { category, item } = this.props.params;
var menuItem = data.lookupItem(category, item);
return (
<div>
<h1>{menuItem.name}</h1>
<p>${menuItem.price}</p>
</div>
);
}
});
var Index = React.createClass({
render() {
return (
<div>
<h1>Sidebar</h1>
<p>
Routes can have multiple components, so that all portions of your UI
can participate in the routing.
</p>
</div>
);
}
});
var IndexSidebar = React.createClass({
render() {
return (
<div>
<h2>Categories</h2>
<ul>
{data.getAll().map((category, index) => (
<li key={index}>
<Link to={`/category/${category.name}`}>{category.name}</Link>
</li>
))}
</ul>
</div>
);
}
});
var App = React.createClass({
render() {
var { children } = this.props;
return (
<div>
<div className="Sidebar">
{children ? children.sidebar : <IndexSidebar />}
</div>
<div className="Content">
{children ? children.content : <Index />}
</div>
</div>
);
}
});
React.render((
<Router>
<Route path="/" component={App}>
<Route path="category/:category" components={{content: Category, sidebar: CategorySidebar}}>
<Route path=":item" component={Item} />
</Route>
</Route>
</Router>
), document.getElementById('example'));
|
src/CheckboxGroup.js
|
jsummer/react-ui
|
"use strict"
import React from 'react'
import classnames from 'classnames'
import Checkbox from './Checkbox'
import { toArray } from './utils/strings'
import { toTextValue } from './utils/objects'
class CheckboxGroup extends React.Component {
static displayName = "CheckboxGroup"
static propTypes = {
className: React.PropTypes.string,
data: React.PropTypes.oneOfType([
React.PropTypes.array,
React.PropTypes.func
]).isRequired,
inline: React.PropTypes.bool,
onChange: React.PropTypes.func,
readOnly: React.PropTypes.bool,
sep: React.PropTypes.string,
style: React.PropTypes.object,
textTpl: React.PropTypes.string,
value: React.PropTypes.any,
valueTpl: React.PropTypes.string
}
static defaultProps = {
sep: ',',
textTpl: '{text}',
valueTpl: '{id}'
}
componentWillReceiveProps (nextProps) {
if (nextProps.value !== this.props.value) {
this.setValue(nextProps.value)
}
if (nextProps.data !== this.props.data) {
this.setState({ data: this.formatData(nextProps.data) })
}
}
state = {
value: this.formatValue(this.props.value),
data: this.formatData(this.props.data)
}
formatValue (value) {
return toArray(value, this.props.sep)
}
getValue (sep) {
let value = this.state.value
if (sep === undefined) {
sep = this.props.sep
}
if (sep) {
value = value.join(sep)
}
return value
}
setValue (value) {
this.setState({ value: this.formatValue(value) })
}
formatData (data) {
if (typeof data === 'function') {
data.then(res => {
this.setState({ data: this.formatData(res) })
})()
return []
} else {
return toTextValue(data, this.props.textTpl, this.props.valueTpl)
}
}
handleChange (checked, value) {
if (typeof value !== 'string') {
value = value.toString()
}
let values = this.state.value
if (checked) {
values.push(value)
} else {
let i = values.indexOf(value)
if (i >= 0) {
values.splice(i, 1)
}
}
if (this.props.onChange) {
this.props.onChange(this.props.sep ? values.join(this.props.sep) : values)
}
this.setState({ value: values })
}
render () {
let className = classnames(
this.props.className,
'rct-checkbox-group',
{ 'rct-inline': this.props.inline }
)
let values = this.state.value
let items = this.state.data.map((item, i) => {
let value = this.props.sep ? item.$value.toString() : item.$value
let checked = values.indexOf(value) >= 0
return (
<Checkbox key={i}
index={i}
readOnly={this.props.readOnly}
checked={checked}
onChange={this.handleChange.bind(this)}
text={item.$text}
value={item.$value}
/>
)
})
return (
<div style={this.props.style} className={className}>{this.state.msg || items}</div>
)
}
}
export default CheckboxGroup
require('./FormControl').register(
'checkbox-group',
function (props) {
return <CheckboxGroup {...props} />
},
CheckboxGroup,
'array'
)
|
docs/app/Examples/collections/Form/Variations/FormExampleInverted.js
|
shengnian/shengnian-ui-react
|
import React from 'react'
import { Button, Form, Segment } from 'shengnian-ui-react'
const FormExampleInverted = () => (
<Segment inverted>
<Form inverted>
<Form.Group widths='equal'>
<Form.Input label='First name' placeholder='First name' />
<Form.Input label='Last name' placeholder='Last name' />
</Form.Group>
<Form.Checkbox label='I agree to the Terms and Conditions' />
<Button type='submit'>Submit</Button>
</Form>
</Segment>
)
export default FormExampleInverted
|
src/App/App.js
|
mdboop/francis
|
import React from 'react';
import Nav from '../Nav/Nav';
class App extends React.Component {
constructor(props) {
super(props);
this.state = {};
}
render() {
return (
<div>
<Nav />
{this.props.children}
</div>
);
}
}
App.propTypes = {
children: React.PropTypes.element,
};
export default App;
|
src/components/Portal.js
|
neontribe/gbptm
|
import React from 'react';
import ReactDOM from 'react-dom';
import PropTypes from 'prop-types';
const Portal = (props) => {
// https://github.com/facebook/react/issues/13097#issuecomment-405658104
const [isMounted, setIsMounted] = React.useState(false);
const element = document.querySelector(props.selector);
React.useEffect(() => {
setIsMounted(true);
}, []);
if (element && isMounted) {
return ReactDOM.createPortal(props.children, element);
}
return null;
};
Portal.propTypes = {
/** query selector to determine where to mount the Portal */
selector: PropTypes.string,
children: PropTypes.node,
};
Portal.defaultProps = {
selector: 'body',
};
export default Portal;
|
packages/examples/regithub/pages/home.js
|
siddharthkp/reaqt
|
import React from 'react'
import Nav from '../components/presentation/common/nav'
import ProfileInput from '../components/presentation/profile/profile-input'
export default () => (
<div>
<Nav />
<ProfileInput />
</div>
)
|
docs/src/PageHeader.js
|
collinwu/react-bootstrap
|
import React from 'react';
const PageHeader = React.createClass({
render() {
return (
<div className='bs-docs-header' id='content'>
<div className='container'>
<h1>{this.props.title}</h1>
<p>{this.props.subTitle}</p>
</div>
</div>
);
}
});
export default PageHeader;
|
packages/react-scripts/fixtures/kitchensink/src/features/syntax/Promises.js
|
GreenGremlin/create-react-app
|
/**
* Copyright (c) 2015-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import React, { Component } from 'react';
import PropTypes from 'prop-types';
function load() {
return Promise.resolve([
{ id: 1, name: '1' },
{ id: 2, name: '2' },
{ id: 3, name: '3' },
{ id: 4, name: '4' },
]);
}
export default class extends Component {
static propTypes = {
onReady: PropTypes.func.isRequired,
};
constructor(props) {
super(props);
this.state = { users: [] };
}
componentDidMount() {
load().then(users => {
this.setState({ users });
});
}
componentDidUpdate() {
this.props.onReady();
}
render() {
return (
<div id="feature-promises">
{this.state.users.map(user => (
<div key={user.id}>{user.name}</div>
))}
</div>
);
}
}
|
actor-apps/app-web/src/app/components/JoinGroup.react.js
|
lstNull/actor-platform
|
import React from 'react';
import requireAuth from 'utils/require-auth';
import DialogActionCreators from 'actions/DialogActionCreators';
import JoinGroupActions from 'actions/JoinGroupActions';
import JoinGroupStore from 'stores/JoinGroupStore'; // eslint-disable-line
class JoinGroup extends React.Component {
static propTypes = {
params: React.PropTypes.object
};
static contextTypes = {
router: React.PropTypes.func
};
constructor(props) {
super(props);
JoinGroupActions.joinGroup(props.params.token)
.then((peer) => {
this.context.router.replaceWith('/');
DialogActionCreators.selectDialogPeer(peer);
}).catch((e) => {
console.warn(e, 'User is already a group member');
this.context.router.replaceWith('/');
});
}
render() {
return null;
}
}
export default requireAuth(JoinGroup);
|
docs/app/Examples/collections/Form/Shorthand/FormExampleFieldControlId.js
|
shengnian/shengnian-ui-react
|
import React from 'react'
import { Form, Input, TextArea, Button } from 'shengnian-ui-react'
const FormExampleFieldControlId = () => (
<Form>
<Form.Group widths='equal'>
<Form.Field id='form-input-control-first-name' control={Input} label='First name' placeholder='First name' />
<Form.Field id='form-input-control-last-name' control={Input} label='Last name' placeholder='Last name' />
</Form.Group>
<Form.Field id='form-textarea-control-opinion' control={TextArea} label='Opinion' placeholder='Opinion' />
<Form.Field id='form-button-control-public' control={Button} content='Confirm' label='Label with htmlFor' />
</Form>
)
export default FormExampleFieldControlId
|
src/Row.js
|
HPate-Riptide/react-bootstrap
|
import classNames from 'classnames';
import React from 'react';
import elementType from 'react-prop-types/lib/elementType';
import { bsClass, getClassSet, splitBsProps } from './utils/bootstrapUtils';
const propTypes = {
componentClass: elementType,
};
const defaultProps = {
componentClass: 'div',
};
class Row extends React.Component {
render() {
const { componentClass: Component, className, ...props } = this.props;
const [bsProps, elementProps] = splitBsProps(props);
const classes = getClassSet(bsProps);
return (
<Component
{...elementProps}
className={classNames(className, classes)}
/>
);
}
}
Row.propTypes = propTypes;
Row.defaultProps = defaultProps;
export default bsClass('row', Row);
|
app/header.js
|
vijanny/react-native-DemoPrj
|
import React, { Component } from 'react';
import {StatusBar ,View,StyleSheet,Text,TouchableHighlight,Image} from 'react-native';
/*
*iconSrcLeft 左侧图标路径 参考iconSrcLeft = require('路径') 传参
*iconOnPressLeft 左侧图标按下响应函数
*iconSrcRight 右侧图标路径 参考iconSrcLeft = require('路径') 传参
*iconOnPressRight 右侧图标按下响应函数
*titleColor 标题演示
*title 标题
*backgroundColor 背景颜色
*height 高度
*/
export default class Header extends Component {
constructor(props) {
super(props);
}
render() {
// 根据当前showText的值决定是否显示text内容
const iconSrcLeft = this.props.iconSrcLeft?this.props.iconSrcLeft:null;
const iconSrcRight = this.props.iconSrcRight?this.props.iconSrcRight:null;
const titleColor = this.props.titleColor?this.props.titleColor:'#000'
return (
<View style={[this.props.style , {backgroundColor:this.props.backgroundColor,flexDirection:"row",height:this.props.height}]}>
<View style={{flex:1,flexDirection:'column',justifyContent:'center',paddingLeft:10}}>
<TouchableHighlight
onPress={this.props.iconOnPressLeft}
style={styles.headerIcon}
underlayColor = '#F5F5F5'
>
<View >
{iconSrcLeft
?
<Image
style={styles.headerIcon}
source={iconSrcLeft}
/>
:
null
}
</View>
</TouchableHighlight>
</View>
<View style={{flex:1,flexDirection:'column',justifyContent:'center'}}>
<View style = {{flexDirection:'row',alignItems:'center',justifyContent:'center'}}>
<Text style={{fontSize:20,color:titleColor}} >{this.props.title}</Text>
</View>
</View>
<View style={{flex:1,flexDirection:'column',justifyContent:'center'}}>
<View style = {{flexDirection:'row',alignItems:'center',justifyContent:'flex-end',paddingRight:10}}>
<TouchableHighlight
onPress={this.props.iconOnPressRight}
style={styles.headerIcon}
underlayColor = '#F5F5F5'
>
<View >
{iconSrcRight
?
<Image
style={styles.headerIcon}
source={iconSrcRight}
/>
:
null
}
</View>
</TouchableHighlight>
</View>
</View>
</View>
);
}
}
const styles = StyleSheet.create({
headerIcon:{
width:30,
height:30
},
});
|
tom-binary-tree/src/Counter.js
|
slorber/scalable-frontend-with-elm-or-redux
|
import React from 'react'
// EVENTS
export class Increment {
constructor(step) {
this.step = step
}
update(model) {
return { model: model + this.step }
}
}
// APP
export default {
init() {
return { model: 0 }
},
update(model, event) {
return event.update(model)
},
view(model) {
return <p>Count: {model}</p>
}
}
|
src/svg-icons/action/open-in-browser.js
|
jacklam718/react-svg-iconx
|
import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let ActionOpenInBrowser = (props) => (
<SvgIcon {...props}>
<path d="M19 4H5c-1.11 0-2 .9-2 2v12c0 1.1.89 2 2 2h4v-2H5V8h14v10h-4v2h4c1.1 0 2-.9 2-2V6c0-1.1-.89-2-2-2zm-7 6l-4 4h3v6h2v-6h3l-4-4z"/>
</SvgIcon>
);
ActionOpenInBrowser = pure(ActionOpenInBrowser);
ActionOpenInBrowser.displayName = 'ActionOpenInBrowser';
ActionOpenInBrowser.muiName = 'SvgIcon';
export default ActionOpenInBrowser;
|
app/components/Hypno/index.js
|
brainsandspace/ship
|
/**
*
* Hypno
*
*/
import React from 'react';
import styled from 'styled-components';
const Wrapper = styled.div`
overflow: hidden;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-orient: vertical;
-webkit-box-direction: normal;
-ms-flex-direction: column;
flex-direction: column;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
-webkit-box-pack: center;
-ms-flex-pack: center;
// height: 100vh;
.circle {
position: absolute;
height: 20vmin;
width: 20vmin;
border-radius: 50%;
opacity: 1;
background: black;
}
#c1 {
-webkit-transform-origin: center 46%;
transform-origin: center 46%;
-webkit-transform: scale(0.8) rotate(0deg);
transform: scale(0.8) rotate(0deg);
background: #edebe9;
-webkit-animation: circleAn1 10s infinite linear;
animation: circleAn1 10s infinite linear;
}
@-webkit-keyframes circleAn1 {
50% {
background: #edede9;
}
to {
background: #edebe9;
-webkit-transform: scale(0.8) rotate(360deg);
transform: scale(0.8) rotate(360deg);
}
}
@keyframes circleAn1 {
50% {
background: #edede9;
}
to {
background: #edebe9;
-webkit-transform: scale(0.8) rotate(360deg);
transform: scale(0.8) rotate(360deg);
}
}
#c2 {
-webkit-transform-origin: center 47%;
transform-origin: center 47%;
-webkit-transform: scale(0.8) rotate(0deg);
transform: scale(0.8) rotate(0deg);
background: #dcdcd4;
-webkit-animation: circleAn2 10s infinite linear;
animation: circleAn2 10s infinite linear;
}
@-webkit-keyframes circleAn2 {
50% {
background: #d8dcd4;
}
to {
background: #dcdcd4;
-webkit-transform: scale(0.8) rotate(360deg);
transform: scale(0.8) rotate(360deg);
}
}
@keyframes circleAn2 {
50% {
background: #d8dcd4;
}
to {
background: #dcdcd4;
-webkit-transform: scale(0.8) rotate(360deg);
transform: scale(0.8) rotate(360deg);
}
}
#c3 {
-webkit-transform-origin: center 48%;
transform-origin: center 48%;
-webkit-transform: scale(0.8) rotate(0deg);
transform: scale(0.8) rotate(0deg);
background: #c4cabe;
-webkit-animation: circleAn3 10s infinite linear;
animation: circleAn3 10s infinite linear;
}
@-webkit-keyframes circleAn3 {
50% {
background: #becabe;
}
to {
background: #c4cabe;
-webkit-transform: scale(0.8) rotate(360deg);
transform: scale(0.8) rotate(360deg);
}
}
@keyframes circleAn3 {
50% {
background: #becabe;
}
to {
background: #c4cabe;
-webkit-transform: scale(0.8) rotate(360deg);
transform: scale(0.8) rotate(360deg);
}
}
#c4 {
-webkit-transform-origin: center 49%;
transform-origin: center 49%;
-webkit-transform: scale(0.8) rotate(0deg);
transform: scale(0.8) rotate(0deg);
background: #a9b8a9;
-webkit-animation: circleAn4 10s infinite linear;
animation: circleAn4 10s infinite linear;
}
@-webkit-keyframes circleAn4 {
50% {
background: #a9b8b1;
}
to {
background: #a9b8a9;
-webkit-transform: scale(0.8) rotate(360deg);
transform: scale(0.8) rotate(360deg);
}
}
@keyframes circleAn4 {
50% {
background: #a9b8b1;
}
to {
background: #a9b8a9;
-webkit-transform: scale(0.8) rotate(360deg);
transform: scale(0.8) rotate(360deg);
}
}
#c5 {
-webkit-transform-origin: center 50%;
transform-origin: center 50%;
-webkit-transform: scale(0.8) rotate(0deg);
transform: scale(0.8) rotate(0deg);
background: #93a79d;
-webkit-animation: circleAn5 10s infinite linear;
animation: circleAn5 10s infinite linear;
}
@-webkit-keyframes circleAn5 {
50% {
background: #93a7a7;
}
to {
background: #93a79d;
-webkit-transform: scale(0.8) rotate(360deg);
transform: scale(0.8) rotate(360deg);
}
}
@keyframes circleAn5 {
50% {
background: #93a7a7;
}
to {
background: #93a79d;
-webkit-transform: scale(0.8) rotate(360deg);
transform: scale(0.8) rotate(360deg);
}
}
#c6 {
-webkit-transform-origin: center 51%;
transform-origin: center 51%;
-webkit-transform: scale(0.8) rotate(0deg);
transform: scale(0.8) rotate(0deg);
background: #7e9595;
-webkit-animation: circleAn6 10s infinite linear;
animation: circleAn6 10s infinite linear;
}
@-webkit-keyframes circleAn6 {
50% {
background: #7e8995;
}
to {
background: #7e9595;
-webkit-transform: scale(0.8) rotate(360deg);
transform: scale(0.8) rotate(360deg);
}
}
@keyframes circleAn6 {
50% {
background: #7e8995;
}
to {
background: #7e9595;
-webkit-transform: scale(0.8) rotate(360deg);
transform: scale(0.8) rotate(360deg);
}
}
#c7 {
-webkit-transform-origin: center 52%;
transform-origin: center 52%;
-webkit-transform: scale(0.8) rotate(0deg);
transform: scale(0.8) rotate(0deg);
background: #6a7681;
-webkit-animation: circleAn7 10s infinite linear;
animation: circleAn7 10s infinite linear;
}
@-webkit-keyframes circleAn7 {
50% {
background: #6a6a81;
}
to {
background: #6a7681;
-webkit-transform: scale(0.8) rotate(360deg);
transform: scale(0.8) rotate(360deg);
}
}
@keyframes circleAn7 {
50% {
background: #6a6a81;
}
to {
background: #6a7681;
-webkit-transform: scale(0.8) rotate(360deg);
transform: scale(0.8) rotate(360deg);
}
}
#c8 {
-webkit-transform-origin: center 53%;
transform-origin: center 53%;
-webkit-transform: scale(0.8) rotate(0deg);
transform: scale(0.8) rotate(0deg);
background: #58586c;
-webkit-animation: circleAn8 10s infinite linear;
animation: circleAn8 10s infinite linear;
}
@-webkit-keyframes circleAn8 {
50% {
background: #62586c;
}
to {
background: #58586c;
-webkit-transform: scale(0.8) rotate(360deg);
transform: scale(0.8) rotate(360deg);
}
}
@keyframes circleAn8 {
50% {
background: #62586c;
}
to {
background: #58586c;
-webkit-transform: scale(0.8) rotate(360deg);
transform: scale(0.8) rotate(360deg);
}
}
#c9 {
-webkit-transform-origin: center 54%;
transform-origin: center 54%;
-webkit-transform: scale(0.8) rotate(0deg);
transform: scale(0.8) rotate(0deg);
background: #4e4756;
-webkit-animation: circleAn9 10s infinite linear;
animation: circleAn9 10s infinite linear;
}
@-webkit-keyframes circleAn9 {
50% {
background: #564756;
}
to {
background: #4e4756;
-webkit-transform: scale(0.8) rotate(360deg);
transform: scale(0.8) rotate(360deg);
}
}
@keyframes circleAn9 {
50% {
background: #564756;
}
to {
background: #4e4756;
-webkit-transform: scale(0.8) rotate(360deg);
transform: scale(0.8) rotate(360deg);
}
}
#c10 {
-webkit-transform-origin: center 55%;
transform-origin: center 55%;
-webkit-transform: scale(0.8) rotate(0deg);
transform: scale(0.8) rotate(0deg);
background: #413541;
-webkit-animation: circleAn10 10s infinite linear;
animation: circleAn10 10s infinite linear;
}
@-webkit-keyframes circleAn10 {
50% {
background: #41353b;
}
to {
background: #413541;
-webkit-transform: scale(0.8) rotate(360deg);
transform: scale(0.8) rotate(360deg);
}
}
@keyframes circleAn10 {
50% {
background: #41353b;
}
to {
background: #413541;
-webkit-transform: scale(0.8) rotate(360deg);
transform: scale(0.8) rotate(360deg);
}
}
#c11 {
-webkit-transform-origin: center 56%;
transform-origin: center 56%;
-webkit-transform: scale(0.8) rotate(0deg);
transform: scale(0.8) rotate(0deg);
background: #2b2327;
-webkit-animation: circleAn11 10s infinite linear;
animation: circleAn11 10s infinite linear;
}
@-webkit-keyframes circleAn11 {
50% {
background: #2b2323;
}
to {
background: #2b2327;
-webkit-transform: scale(0.8) rotate(360deg);
transform: scale(0.8) rotate(360deg);
}
}
@keyframes circleAn11 {
50% {
background: #2b2323;
}
to {
background: #2b2327;
-webkit-transform: scale(0.8) rotate(360deg);
transform: scale(0.8) rotate(360deg);
}
}
#c12 {
-webkit-transform-origin: center 57%;
transform-origin: center 57%;
-webkit-transform: scale(0.8) rotate(0deg);
transform: scale(0.8) rotate(0deg);
background: #161212;
-webkit-animation: circleAn12 10s infinite linear;
animation: circleAn12 10s infinite linear;
}
@-webkit-keyframes circleAn12 {
50% {
background: #161412;
}
to {
background: #161212;
-webkit-transform: scale(0.8) rotate(360deg);
transform: scale(0.8) rotate(360deg);
}
}
@keyframes circleAn12 {
50% {
background: #161412;
}
to {
background: #161212;
-webkit-transform: scale(0.8) rotate(360deg);
transform: scale(0.8) rotate(360deg);
}
}
#c13 {
-webkit-transform-origin: center 58%;
transform-origin: center 58%;
-webkit-transform: scale(0.8) rotate(0deg);
transform: scale(0.8) rotate(0deg);
background: black;
-webkit-animation: circleAn13 10s infinite linear;
animation: circleAn13 10s infinite linear;
}
@-webkit-keyframes circleAn13 {
50% {
background: black;
}
to {
background: black;
-webkit-transform: scale(0.8) rotate(360deg);
transform: scale(0.8) rotate(360deg);
}
}
@keyframes circleAn13 {
50% {
background: black;
}
to {
background: black;
-webkit-transform: scale(0.8) rotate(360deg);
transform: scale(0.8) rotate(360deg);
}
}
`;
function Hypno() {
return (
<Wrapper>
<div className="circle" id="c1">
<div className="circle" id="c2">
<div className="circle" id="c3">
<div className="circle" id="c4">
<div className="circle" id="c5">
<div className="circle" id="c6">
<div className="circle" id="c7">
<div className="circle" id="c8">
<div className="circle" id="c9">
<div className="circle" id="c10">
<div className="circle" id="c11">
<div className="circle" id="c12">
<div className="circle" id="c13"></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</Wrapper>
);
}
Hypno.propTypes = {
};
export default Hypno;
|
frontend/component/TopicList.js
|
ivernaloo/practice-node-project
|
import React from 'react';
import {Link} from 'react-router';
import {getTopicList} from '../lib/client';
export default class TopicList extends React.Component {
constructor(props) {
super(props);
this.state = {};
}
componentDidMount() {
getTopicList({})
.then(ret => this.setState({list: ret.list}))
.catch(err => console.error(err));
}
render() {
const list = Array.isArray(this.state.list) ? this.state.list : [];
return (
<div>
<ul className="list-group">
{list.map((item, i) => {
return (
<Link to={`/topic/${item._id}`} className="list-group-item" key={i}>{item.title}</Link>
)
})}
</ul>
</div>
)
}
}
|
react/features/toolbox/components/web/JitsiPortal.js
|
jitsi/jitsi-meet
|
// @flow
import React from 'react';
import DialogPortal from './DialogPortal';
type Props = {
/**
* The component(s) to be displayed within the drawer portal.
*/
children: React$Node,
/**
* Class name used to add custom styles to the portal.
*/
className?: string
};
/**
* Component meant to render a drawer at the bottom of the screen,
* by creating a portal containing the component's children.
*
* @returns {ReactElement}
*/
function JitsiPortal({ children, className }: Props) {
return (
<DialogPortal className = { `drawer-portal ${className ?? ''}` }>
{ children }
</DialogPortal>
);
}
export default JitsiPortal;
|
src/svg-icons/image/hdr-off.js
|
jacklam718/react-svg-iconx
|
import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let ImageHdrOff = (props) => (
<SvgIcon {...props}>
<path d="M17.5 15v-2h1.1l.9 2H21l-.9-2.1c.5-.2.9-.8.9-1.4v-1c0-.8-.7-1.5-1.5-1.5H16v4.9l1.1 1.1h.4zm0-4.5h2v1h-2v-1zm-4.5 0v.4l1.5 1.5v-1.9c0-.8-.7-1.5-1.5-1.5h-1.9l1.5 1.5h.4zm-3.5-1l-7-7-1.1 1L6.9 9h-.4v2h-2V9H3v6h1.5v-2.5h2V15H8v-4.9l1.5 1.5V15h3.4l7.6 7.6 1.1-1.1-12.1-12z"/>
</SvgIcon>
);
ImageHdrOff = pure(ImageHdrOff);
ImageHdrOff.displayName = 'ImageHdrOff';
ImageHdrOff.muiName = 'SvgIcon';
export default ImageHdrOff;
|
App.js
|
emilianoeloi/React
|
import React from 'react';
class App extends React.Component {
constructor(){
super();
this.state = {
input: '/* add your jsx here */',
output: '',
err: ''
}
this.update = this.update.bind(this);
}
update(e){
let code = e.target.value;
try{
this.setState({
output: babel.transform(code, {
stage: 0,
loose: 'all'
}).code
})
}catch(err){
this.setState({err: err.message});
}
}
render(){
return (
<div>
<header>
{this.state.err}
</header>
<div className="container">
<textarea onChange={this.update}
defaultValue={this.state.input}></textarea>
<pre>{this.state.output}</pre>
</div>
</div>
)
}
}
export default App
|
src/test.js
|
matanasa/react-dropzone
|
/* eslint no-unused-expressions: 0 */
import React from 'react';
import { expect } from 'chai';
import { spy } from 'sinon';
import TestUtils from 'react-testutils-additions';
import semver from 'semver';
const Dropzone = require(process.env.NODE_ENV === 'production' ? '../dist/index' : './index');
const itConditional = semver.satisfies(React.version, '>=15.2.1') ? it : it.skip;
describe('Dropzone', () => {
let files = [];
let images = [];
beforeEach(() => {
files = [{
name: 'file1.pdf',
size: 1111,
type: 'application/pdf'
}];
images = [{
name: 'cats.gif',
size: 1234,
type: 'image/gif'
}, {
name: 'dogs.jpg',
size: 2345,
type: 'image/jpeg'
}];
});
it('renders the content', () => {
const dropzone = TestUtils.renderIntoDocument(
<Dropzone>
<div className="dropzone-content">some content</div>
</Dropzone>
);
const content = TestUtils.findRenderedDOMComponentWithClass(dropzone, 'dropzone-content');
expect(content.textContent).to.equal('some content');
});
it('renders the input element', () => {
const dropzone = TestUtils.renderIntoDocument(
<Dropzone>
<div className="dropzone-content">some content</div>
</Dropzone>
);
const input = TestUtils.find(dropzone, 'input');
expect(input.length).to.equal(1);
});
it('returns the url of the preview', () => {
const dropSpy = spy();
const dropzone = TestUtils.renderIntoDocument(
<Dropzone onDrop={dropSpy}>
<div className="dropzone-content">some content</div>
</Dropzone>
);
const content = TestUtils.findRenderedDOMComponentWithClass(dropzone, 'dropzone-content');
TestUtils.Simulate.drop(content, { dataTransfer: { files } });
expect(dropSpy.callCount).to.equal(1);
expect(dropSpy.firstCall.args[0][0]).to.have.property('preview');
});
it('does not throw an error when html is dropped instead of files and multiple is false', () => {
const dropzone = TestUtils.renderIntoDocument(
<Dropzone multiple={false}>
<div className="dropzone-content">some content</div>
</Dropzone>
);
const content = TestUtils.findRenderedDOMComponentWithClass(dropzone, 'dropzone-content');
const fn = () => TestUtils.Simulate.drop(content, { dataTransfer: { files: [] } });
expect(fn).not.to.throw();
});
describe('ref', () => {
it('sets ref properly', () => {
const dropzone = TestUtils.renderIntoDocument(<Dropzone />);
const input = TestUtils.find(dropzone, 'input')[0];
expect(dropzone.fileInputEl).to.not.be.undefined;
expect(dropzone.fileInputEl).to.eql(input);
});
});
describe('props', () => {
it('uses the disablePreview property', () => {
const dropSpy = spy();
const dropzone = TestUtils.renderIntoDocument(
<Dropzone disablePreview onDrop={dropSpy}>
<div className="dropzone-content">some content</div>
</Dropzone>
);
const content = TestUtils.findRenderedDOMComponentWithClass(dropzone, 'dropzone-content');
TestUtils.Simulate.drop(content, { dataTransfer: { files } });
expect(dropSpy.callCount).to.equal(1);
expect(dropSpy.firstCall.args[0][0]).to.not.have.property('preview');
});
it('uses the disableClick property', () => {
const dropzone = TestUtils.renderIntoDocument(
<Dropzone disableClick>
<div className="dropzone-content">some content</div>
</Dropzone>
);
spy(dropzone, 'open');
const content = TestUtils.findRenderedDOMComponentWithClass(dropzone, 'dropzone-content');
TestUtils.Simulate.click(content);
expect(dropzone.open.callCount).to.equal(0);
});
it('calls `open` if disableClick is not provided', () => {
const dropzone = TestUtils.renderIntoDocument(
<Dropzone>
<div className="dropzone-content">some content</div>
</Dropzone>
);
spy(dropzone, 'open');
const content = TestUtils.findRenderedDOMComponentWithClass(dropzone, 'dropzone-content');
TestUtils.Simulate.click(content);
expect(dropzone.open.callCount).to.equal(1);
});
it('renders dynamic props on the root element', () => {
const component = TestUtils.renderIntoDocument(
<Dropzone hidden aria-hidden="hidden" title="Dropzone" />
);
expect(TestUtils.find(component, '[hidden][aria-hidden="hidden"][title="Dropzone"]'))
.to.have.length(1);
});
it('renders dynamic props on the input element', () => {
const component = TestUtils.renderIntoDocument(
<Dropzone inputProps={{ id: 'hiddenFileInput' }} />
);
expect(TestUtils.find(component, '#hiddenFileInput')).to.have.length(1);
});
it('applies the accept prop to the child input', () => {
const component = TestUtils.renderIntoDocument(
<Dropzone className="my-dropzone" accept="image/jpeg" />
);
expect(TestUtils.find(component, 'input[type="file"][accept="image/jpeg"]'))
.to.have.length(1);
expect(TestUtils.find(component, '[class="my-dropzone"][accept="image/jpeg"]'))
.to.have.length(0);
});
it('applies the accept prop to the dropped files', () => {
const dropSpy = spy();
const dropAcceptedSpy = spy();
const dropRejectedSpy = spy();
const dropzone = TestUtils.renderIntoDocument(
<Dropzone onDrop={dropSpy} onDropAccepted={dropAcceptedSpy} onDropRejected={dropRejectedSpy} accept="image/*">
<div className="dropzone-content">some content</div>
</Dropzone>
);
const content = TestUtils.findRenderedDOMComponentWithClass(dropzone, 'dropzone-content');
TestUtils.Simulate.drop(content, { dataTransfer: { files } });
expect(dropSpy.callCount).to.equal(1);
expect(dropSpy.firstCall.args[0]).to.have.length(0);
expect(dropSpy.firstCall.args[1]).to.have.length(1);
expect(dropAcceptedSpy.callCount).to.equal(0);
expect(dropRejectedSpy.callCount).to.equal(1);
expect(dropRejectedSpy.firstCall.args[0]).to.have.length(1);
});
it('applies the accept prop to the dropped images', () => {
const dropSpy = spy();
const dropAcceptedSpy = spy();
const dropRejectedSpy = spy();
const dropzone = TestUtils.renderIntoDocument(
<Dropzone onDrop={dropSpy} onDropAccepted={dropAcceptedSpy} onDropRejected={dropRejectedSpy} accept="image/*">
<div className="dropzone-content">some content</div>
</Dropzone>
);
const content = TestUtils.findRenderedDOMComponentWithClass(dropzone, 'dropzone-content');
TestUtils.Simulate.drop(content, { dataTransfer: { files: images } });
expect(dropSpy.callCount).to.equal(1);
expect(dropSpy.firstCall.args[0]).to.have.length(2);
expect(dropSpy.firstCall.args[1]).to.have.length(0);
expect(dropAcceptedSpy.callCount).to.equal(1);
expect(dropAcceptedSpy.firstCall.args[0]).to.have.length(2);
expect(dropRejectedSpy.callCount).to.equal(0);
});
it('accepts all dropped files and images when no accept prop is specified', () => {
const dropSpy = spy();
const dropAcceptedSpy = spy();
const dropRejectedSpy = spy();
const dropzone = TestUtils.renderIntoDocument(
<Dropzone onDrop={dropSpy} onDropAccepted={dropAcceptedSpy} onDropRejected={dropRejectedSpy}>
<div className="dropzone-content">some content</div>
</Dropzone>
);
const content = TestUtils.findRenderedDOMComponentWithClass(dropzone, 'dropzone-content');
TestUtils.Simulate.drop(content, { dataTransfer: { files: files.concat(images) } });
expect(dropSpy.callCount).to.equal(1);
expect(dropSpy.firstCall.args[0]).to.have.length(3);
expect(dropSpy.firstCall.args[1]).to.have.length(0);
expect(dropAcceptedSpy.callCount).to.equal(1);
expect(dropAcceptedSpy.firstCall.args[0]).to.have.length(3);
expect(dropRejectedSpy.callCount).to.equal(0);
});
it('applies the maxSize prop to the dropped files', () => {
const dropSpy = spy();
const dropAcceptedSpy = spy();
const dropRejectedSpy = spy();
const dropzone = TestUtils.renderIntoDocument(
<Dropzone onDrop={dropSpy} onDropAccepted={dropAcceptedSpy} onDropRejected={dropRejectedSpy} maxSize={1111}>
<div className="dropzone-content">some content</div>
</Dropzone>
);
const content = TestUtils.findRenderedDOMComponentWithClass(dropzone, 'dropzone-content');
TestUtils.Simulate.drop(content, { dataTransfer: { files } });
expect(dropSpy.callCount).to.equal(1);
expect(dropSpy.firstCall.args[0]).to.have.length(1);
expect(dropSpy.firstCall.args[1]).to.have.length(0);
expect(dropAcceptedSpy.callCount).to.equal(1);
expect(dropAcceptedSpy.firstCall.args[0]).to.have.length(1);
expect(dropRejectedSpy.callCount).to.equal(0);
});
it('applies the maxSize prop to the dropped images', () => {
const dropSpy = spy();
const dropAcceptedSpy = spy();
const dropRejectedSpy = spy();
const dropzone = TestUtils.renderIntoDocument(
<Dropzone onDrop={dropSpy} onDropAccepted={dropAcceptedSpy} onDropRejected={dropRejectedSpy} maxSize={1111}>
<div className="dropzone-content">some content</div>
</Dropzone>
);
const content = TestUtils.findRenderedDOMComponentWithClass(dropzone, 'dropzone-content');
TestUtils.Simulate.drop(content, { dataTransfer: { files: images } });
expect(dropSpy.callCount).to.equal(1);
expect(dropSpy.firstCall.args[0]).to.have.length(0);
expect(dropSpy.firstCall.args[1]).to.have.length(2);
expect(dropAcceptedSpy.callCount).to.equal(0);
expect(dropRejectedSpy.callCount).to.equal(1);
expect(dropRejectedSpy.firstCall.args[0]).to.have.length(2);
});
it('applies the minSize prop to the dropped files', () => {
const dropSpy = spy();
const dropAcceptedSpy = spy();
const dropRejectedSpy = spy();
const dropzone = TestUtils.renderIntoDocument(
<Dropzone onDrop={dropSpy} onDropAccepted={dropAcceptedSpy} onDropRejected={dropRejectedSpy} minSize={1112}>
<div className="dropzone-content">some content</div>
</Dropzone>
);
const content = TestUtils.findRenderedDOMComponentWithClass(dropzone, 'dropzone-content');
TestUtils.Simulate.drop(content, { dataTransfer: { files } });
expect(dropSpy.callCount).to.equal(1);
expect(dropSpy.firstCall.args[0]).to.have.length(0);
expect(dropSpy.firstCall.args[1]).to.have.length(1);
expect(dropAcceptedSpy.callCount).to.equal(0);
expect(dropRejectedSpy.callCount).to.equal(1);
expect(dropRejectedSpy.firstCall.args[0]).to.have.length(1);
});
it('applies the minSize prop to the dropped images', () => {
const dropSpy = spy();
const dropAcceptedSpy = spy();
const dropRejectedSpy = spy();
const dropzone = TestUtils.renderIntoDocument(
<Dropzone onDrop={dropSpy} onDropAccepted={dropAcceptedSpy} onDropRejected={dropRejectedSpy} minSize={1112}>
<div className="dropzone-content">some content</div>
</Dropzone>
);
const content = TestUtils.findRenderedDOMComponentWithClass(dropzone, 'dropzone-content');
TestUtils.Simulate.drop(content, { dataTransfer: { files: images } });
expect(dropSpy.callCount).to.equal(1);
expect(dropSpy.firstCall.args[0]).to.have.length(2);
expect(dropSpy.firstCall.args[1]).to.have.length(0);
expect(dropAcceptedSpy.callCount).to.equal(1);
expect(dropAcceptedSpy.firstCall.args[0]).to.have.length(2);
expect(dropRejectedSpy.callCount).to.equal(0);
});
it('accepts all dropped files and images when no size prop is specified', () => {
const dropSpy = spy();
const dropAcceptedSpy = spy();
const dropRejectedSpy = spy();
const dropzone = TestUtils.renderIntoDocument(
<Dropzone onDrop={dropSpy} onDropAccepted={dropAcceptedSpy} onDropRejected={dropRejectedSpy}>
<div className="dropzone-content">some content</div>
</Dropzone>
);
const content = TestUtils.findRenderedDOMComponentWithClass(dropzone, 'dropzone-content');
TestUtils.Simulate.drop(content, { dataTransfer: { files: files.concat(images) } });
expect(dropSpy.callCount).to.equal(1);
expect(dropSpy.firstCall.args[0]).to.have.length(3);
expect(dropSpy.firstCall.args[1]).to.have.length(0);
expect(dropAcceptedSpy.callCount).to.equal(1);
expect(dropAcceptedSpy.firstCall.args[0]).to.have.length(3);
expect(dropRejectedSpy.callCount).to.equal(0);
});
it('applies the name prop to the child input', () => {
const component = TestUtils.renderIntoDocument(
<Dropzone className="my-dropzone" name="test-file-input" />
);
expect(TestUtils.find(component, 'input[type="file"][name="test-file-input"]'))
.to.have.length(1);
expect(TestUtils.find(component, '[class="my-dropzone"][name="test-file-input"]'))
.to.have.length(0);
});
itConditional('does not apply the name prop if name is falsey', () => {
const component = TestUtils.renderIntoDocument(
<Dropzone className="my-dropzone" name="" />
);
expect(TestUtils.find(component, 'input[type="file"][name]')).to.have.length(0);
});
it('overrides onClick', () => {
const clickSpy = spy();
const component = TestUtils.renderIntoDocument(
<Dropzone id="example" onClick={clickSpy} />
);
const content = TestUtils.find(component, '#example')[0];
TestUtils.Simulate.click(content);
expect(clickSpy).to.not.be.called;
});
it('overrides onDragStart', () => {
const dragStartSpy = spy();
const component = TestUtils.renderIntoDocument(
<Dropzone id="drag-example" onDragStart={dragStartSpy} />
);
const content = TestUtils.find(component, '#drag-example')[0];
TestUtils.Simulate.dragStart(content);
expect(dragStartSpy.callCount).to.equal(1);
});
it('overrides onDragEnter', () => {
const dragEnterSpy = spy();
const component = TestUtils.renderIntoDocument(
<Dropzone id="drag-example" onDragEnter={dragEnterSpy} />
);
const content = TestUtils.find(component, '#drag-example')[0];
TestUtils.Simulate.dragEnter(content, { dataTransfer: { items: files } });
expect(dragEnterSpy.callCount).to.equal(1);
});
it('do not invoke onCancel prop everytime document body receives focus', (done) => {
const onCancelSpy = spy();
TestUtils.renderIntoDocument(
<Dropzone id="on-cancel-example" onFileDialogCancel={onCancelSpy} />
);
// Simulated DOM event - onfocus
document.body.addEventListener('focus', () => {});
const evt = document.createEvent('HTMLEvents');
evt.initEvent('focus', false, true);
document.body.dispatchEvent(evt);
// setTimeout to match the event callback from actual Component
setTimeout(() => {
expect(onCancelSpy.callCount).to.equal(0);
done();
}, 300);
});
it('invoke onFileDialogCancel prop when document body receives focus via cancel button', (done) => {
const onCancelSpy = spy();
const component = TestUtils.renderIntoDocument(
<Dropzone className="dropzone-content" onFileDialogCancel={onCancelSpy} />
);
// Test / invoke the click event
spy(component, 'open');
const content = TestUtils.findRenderedDOMComponentWithClass(component, 'dropzone-content');
TestUtils.Simulate.click(content);
expect(component.open.callCount).to.equal(1);
// Simulated DOM event - onfocus
document.body.addEventListener('focus', () => {});
const evt = document.createEvent('HTMLEvents');
evt.initEvent('focus', false, true);
document.body.dispatchEvent(evt);
// setTimeout to match the event callback from actual Component
setTimeout(() => {
expect(onCancelSpy.callCount).to.equal(1);
done();
}, 300);
});
});
});
|
tests/react/ref.js
|
facebook/flow
|
// @flow
import React from 'react';
class Foo extends React.Component<{}, void> {}
class Bar extends React.Component<{}, void> {}
<Foo />; // OK
<Foo ref="foo" />; // OK
<Foo ref={null} />; // OK
<Foo ref={undefined} />; // OK
<Foo ref={(foo: number) => {}} />; // Error: `Foo` is not a `number`.
<Foo ref={foo => (foo: Foo)} />; // Error: `Foo` may be null.
<Foo ref={foo => (foo: Foo | null)} />; // OK
<Foo ref={foo => (foo: Bar | null)} />; // Error: `Foo` is not `Bar`.
class FooExact extends React.Component<{||}, void> {}
<FooExact />; // OK
<FooExact ref="foo" />; // OK
<FooExact ref={null} />; // OK
<FooExact ref={undefined} />; // OK
<FooExact ref={(foo: number) => {}} />; // Error: `FooExact` is not a `number`.
<FooExact ref={foo => (foo: FooExact)} />; // Error: `FooExact` may be null.
<FooExact ref={foo => (foo: FooExact | null)} />; // OK
<FooExact ref={foo => (foo: Bar | null)} />; // Error: `FooExact` is not `Bar`.
class NumRefs extends React.Component<{}> {
getChild(i: number) {
return this.refs[i];
}
render() {
var children = [];
for (var i = 0; i < 10; i++) {
children.push(<div ref={i} />);
}
return children;
}
}
|
node_modules/react-router/modules/Link.js
|
yomolify/cs-webserver
|
import React from 'react';
var { object, string, func } = React.PropTypes;
function isLeftClickEvent(event) {
return event.button === 0;
}
function isModifiedEvent(event) {
return !!(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey);
}
/**
* <Link> components are used to create an <a> element that links to a route.
* When that route is active, the link gets an "active" class name (or the
* value of its `activeClassName` prop).
*
* For example, assuming you have the following route:
*
* <Route name="showPost" path="/posts/:postID" handler={Post}/>
*
* You could use the following component to link to that route:
*
* <Link to="showPost" params={{ postID: "123" }} />
*
* In addition to params, links may pass along query string parameters
* using the `query` prop.
*
* <Link to="showPost" params={{ postID: "123" }} query={{ show:true }}/>
*/
export var Link = React.createClass({
contextTypes: {
router: object
},
propTypes: {
activeStyle: object,
activeClassName: string,
to: string.isRequired,
query: object,
state: object,
onClick: func
},
getDefaultProps() {
return {
className: '',
activeClassName: 'active',
style: {}
};
},
handleClick(event) {
var allowTransition = true;
var clickResult;
if (this.props.onClick)
clickResult = this.props.onClick(event);
if (isModifiedEvent(event) || !isLeftClickEvent(event))
return;
if (clickResult === false || event.defaultPrevented === true)
allowTransition = false;
event.preventDefault();
if (allowTransition)
this.context.router.transitionTo(this.props.to, this.props.query, this.props.state);
},
render() {
var { router } = this.context;
var { to, query } = this.props;
var props = Object.assign({}, this.props, {
href: router.makeHref(to, query),
onClick: this.handleClick
});
// ignore if rendered outside of the context of a router, simplifies unit testing
if (router && router.isActive(to, query)) {
if (props.activeClassName)
props.className += ` ${props.activeClassName}`;
if (props.activeStyle)
Object.assign(props.style, props.activeStyle);
}
return React.createElement('a', props);
}
});
export default Link;
|
app/src/components/Footer/index.js
|
karatechops/bhamc
|
import React from 'react';
import Anchor from 'grommet/components/Anchor';
import Box from 'grommet/components/Box';
import Button from 'grommet/components/Button';
import Heading from 'grommet/components/Heading';
import Paragraph from 'grommet/components/Paragraph';
import MapIcon from 'grommet/components/icons/base/Map';
import SocialTwitterIcon from 'grommet/components/icons/base/SocialTwitter';
import SocialFacebookIcon from 'grommet/components/icons/base/SocialFacebookOption';
import { FooterLogo, Divider, FooterColumn, StyledFooter } from './styles';
import aahaLogo from './aaha.jpg';
export const Footer = () =>
<StyledFooter
pad={{
horizontal: 'medium',
vertical: 'medium',
between: 'large',
}}
colorIndex="neutral-1"
align="start"
justify="center"
full="horizontal"
>
<FooterColumn>
<Heading tag="h3" margin="small">
Hospital Hours
</Heading>
<Divider />
<Paragraph margin="none">
Monday - Friday: 7:30 am - 7:30 pm
</Paragraph>
<Paragraph margin="none">
Saturday: 7:30 am - 1:30 pm
</Paragraph>
<Paragraph margin="none">
Appointments Preferred
</Paragraph>
</FooterColumn>
<FooterColumn>
<Heading tag="h3" margin="small">
Location
</Heading>
<Divider />
<Paragraph margin="none">
1221 Belle Haven Road
</Paragraph>
<Paragraph margin="none">
Alexandria, VA 22307
</Paragraph>
<Anchor
reverse
icon={<MapIcon />}
label="View Map"
target="_blank"
href="https://www.google.com/maps/place/Belle+Haven+Animal+Medical+Centre/@38.785937,-77.057076,12z/data=!4m13!1m7!3m6!1s0x89b7b034a51a741d:0x386950d364cdc491!2s1221+Belle+Haven+Rd,+Alexandria,+VA+22307!3b1!8m2!3d38.7804665!4d-77.0554556!3m4!1s0x89b7b034988ea74f:0x846f6f9f2ddc75b!8m2!3d38.780339!4d-77.054958"
style={{
fontWeight: 100,
paddingTop: '6px',
fontSize: '16px',
}}
/>
</FooterColumn>
<FooterColumn>
<Heading tag="h3" margin="small">
Contact
</Heading>
<Divider />
<Paragraph margin="none">
Phone: (703) 721 - 0088
</Paragraph>
<Paragraph margin="none">
E-mail: info@bhamc.com
</Paragraph>
</FooterColumn>
<FooterColumn>
<Heading tag="h3" margin="small">
Social
</Heading>
<Divider />
<Box pad={{ between: 'small' }}>
<Button href="https://twitter.com/bhamcvet" rel="noopener noreferer">
<Box
direction="row"
responsive={false}
pad={{
between: 'small',
horizontal: 'small',
}}
>
<SocialTwitterIcon style={{ verticalAlign: 'middle' }} />
<Paragraph margin="none">
Twitter
</Paragraph>
</Box>
</Button>
<Button href="https://www.facebook.com/BHAMC" rel="noopener noreferer">
<Box
direction="row"
responsive={false}
pad={{
between: 'small',
horizontal: 'small',
}}
>
<SocialFacebookIcon style={{ verticalAlign: 'middle' }} />
<Paragraph margin="none">
Facebook
</Paragraph>
</Box>
</Button>
</Box>
</FooterColumn>
<FooterColumn alignSelf="center">
{ typeof window !== 'undefined' &&
<FooterLogo src={aahaLogo} />
}
</FooterColumn>
</StyledFooter>;
export default Footer;
|
src/svg-icons/social/party-mode.js
|
rscnt/material-ui
|
import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let SocialPartyMode = (props) => (
<SvgIcon {...props}>
<path d="M20 4h-3.17L15 2H9L7.17 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm-8 3c1.63 0 3.06.79 3.98 2H12c-1.66 0-3 1.34-3 3 0 .35.07.69.18 1H7.1c-.06-.32-.1-.66-.1-1 0-2.76 2.24-5 5-5zm0 10c-1.63 0-3.06-.79-3.98-2H12c1.66 0 3-1.34 3-3 0-.35-.07-.69-.18-1h2.08c.07.32.1.66.1 1 0 2.76-2.24 5-5 5z"/>
</SvgIcon>
);
SocialPartyMode = pure(SocialPartyMode);
SocialPartyMode.displayName = 'SocialPartyMode';
export default SocialPartyMode;
|
src/app/components/media/MediaPlayerCard.js
|
meedan/check-web
|
import React from 'react';
import PropTypes from 'prop-types';
import { Player } from '@meedan/check-ui';
import AspectRatio from '../layout/AspectRatio';
const MediaPlayerCard = props => (
<article className="video-media-card" style={{ position: 'relative' }}>
<AspectRatio
key={props.contentWarning}
contentWarning={props.contentWarning}
warningCreator={props.warningCreator}
warningCategory={props.warningCategory}
>
{ props.coverImage ? (
<img
src={props.coverImage}
alt=""
/>
) : null }
<div className="aspect-ratio__overlay">
<Player
url={props.filePath}
className="video-media-player"
playbackRate={props.playbackRate}
onDuration={d => props.setPlayerState({ duration: d })}
onPause={() => props.setPlayerState({ playing: false, gaps: [] })}
onPlay={() => props.setPlayerState({ playing: true })}
onProgress={p => props.setPlayerState({ progress: p })}
onReady={props.onPlayerReady}
onTimeUpdate={t => props.setPlayerState({ time: t })}
playing={props.playing}
start={props.start}
end={props.end}
gaps={props.gaps}
scrubTo={props.scrubTo}
seekTo={props.seekTo}
/>
</div>
</AspectRatio>
</article>
);
MediaPlayerCard.propTypes = {
contentWarning: PropTypes.bool.isRequired,
warningCreator: PropTypes.string.isRequired,
warningCategory: PropTypes.string.isRequired,
coverImage: PropTypes.string.isRequired,
filePath: PropTypes.string.isRequired,
playbackRate: PropTypes.number,
setPlayerState: PropTypes.func,
onPlayerReady: PropTypes.func,
playing: PropTypes.bool,
start: PropTypes.number,
end: PropTypes.number,
gaps: PropTypes.arrayOf(PropTypes.arrayOf(PropTypes.number)),
scrubTo: PropTypes.number,
seekTo: PropTypes.number,
};
MediaPlayerCard.defaultProps = {
playbackRate: 1,
setPlayerState: () => {},
onPlayerReady: () => {},
playing: false,
start: null,
end: null,
gaps: [],
scrubTo: null,
seekTo: null,
};
export default MediaPlayerCard;
|
src/app/components/forms/inputs/DropzoneInput.js
|
backpackcoder/world-in-flames
|
import React from 'react'
import {findDOMNode} from 'react-dom'
import Dropzone from 'dropzone'
Dropzone.autoDiscover = false;
export default class DropzoneInput extends React.Component {
componentDidMount() {
let element = $(findDOMNode(this));
let options = this.props.options || {};
element.dropzone(options)
}
render() {
return (
this.props.children
)
}
}
|
src/interface/report/FightSelectionPanel.js
|
FaideWW/WoWAnalyzer
|
import React from 'react';
import PropTypes from 'prop-types';
import Toggle from 'react-toggle';
import { Link } from 'react-router-dom';
import { Trans, t } from '@lingui/macro';
import { i18n } from 'interface/RootLocalizationProvider';
import makeAnalyzerUrl from 'interface/common/makeAnalyzerUrl';
import FightSelectionPanelList from './FightSelectionPanelList';
class FightSelectionPanel extends React.PureComponent {
static propTypes = {
report: PropTypes.shape({
fights: PropTypes.array.isRequired,
}).isRequired,
refreshReport: PropTypes.func.isRequired,
};
state = {
killsOnly: false,
};
render() {
const { report, refreshReport } = this.props;
const { killsOnly } = this.state;
return (
<div className="panel">
<div className="panel-heading">
<div className="row">
<div className="col-md-8">
<h2><Trans>Select the fight to parse</Trans></h2>
</div>
<div className="col-md-4 text-right toggle-control action-buttons">
<Toggle
checked={killsOnly}
icons={false}
onChange={event => this.setState({ killsOnly: event.currentTarget.checked })}
id="kills-only-toggle"
/>
<label htmlFor="kills-only-toggle">
{' '}<Trans>Kills only</Trans>
</label>
<Link
to={makeAnalyzerUrl(report)}
onClick={refreshReport}
data-tip={i18n._(t`This will refresh the fights list which can be useful if you're live logging.`)}
>
<span className="glyphicon glyphicon-refresh" aria-hidden="true" /> <Trans>Refresh</Trans>
</Link>
</div>
</div>
</div>
<div className="panel-body" style={{ padding: 0 }}>
<FightSelectionPanelList
report={report}
fights={report.fights}
killsOnly={killsOnly}
/>
</div>
</div>
);
}
}
export default FightSelectionPanel;
|
client/src/app/components/forms/wizards/Wizard.js
|
zraees/sms-project
|
import React from 'react'
export default class Wizard extends React.Component {
componentDidMount() {
let self = this;
let element = $(this.refs.wizard);
var stepsCount = $('[data-smart-wizard-tab]').length;
var currentStep = 1;
var validSteps = [];
var $form = element.closest('form');
var $prev = $('[data-smart-wizard-prev]', element);
var $next = $('[data-smart-wizard-next]', element);
function setStep(step) {
currentStep = step;
$('[data-smart-wizard-pane=' + step + ']', element).addClass('active').siblings('[data-smart-wizard-pane]').removeClass('active');
$('[data-smart-wizard-tab=' + step + ']', element).addClass('active').siblings('[data-smart-wizard-tab]').removeClass('active');
$prev.toggleClass('disabled', step == 1)
}
element.on('click', '[data-smart-wizard-tab]', function (e) {
setStep(parseInt($(this).data('smartWizardTab')));
e.preventDefault();
});
$next.on('click', function (e) {
if ($form.data('validator')) {
if (!$form.valid()) {
validSteps = _.without(validSteps, currentStep);
$form.data('validator').focusInvalid();
return false;
} else {
validSteps = _.without(validSteps, currentStep);
validSteps.push(currentStep);
element.find('[data-smart-wizard-tab=' + currentStep + ']')
.addClass('complete')
.find('.step')
.html('<i class="fa fa-check"></i>');
}
}
if (currentStep < stepsCount) {
setStep(currentStep + 1);
} else {
if (validSteps.length < stepsCount) {
var steps = _.range(1, stepsCount + 1)
_(steps).forEach(function (num) {
if (validSteps.indexOf(num) == -1) {
setStep(num);
return false;
}
})
} else {
var data = {};
_.each($form.serializeArray(), function (field) {
data[field.name] = field.value
});
if (_.isFunction(self.props.onComplete)) {
self.props.onComplete(data)
}
}
}
e.preventDefault();
});
$prev.on('click', function (e) {
if (!$prev.hasClass('disabled') && currentStep > 0) {
setStep(currentStep - 1);
}
e.preventDefault();
});
setStep(currentStep);
}
render() {
let {children, onComplete, ...props} = this.props;
return (
<div {...props} ref="wizard">
{children}
</div>
)
}
}
|
js/views/create/FriendsListView.js
|
SamyZ/TravelgramApp
|
import React from 'react';
import {
View,
Image,
ListView,
TouchableOpacity,
} from 'react-native';
import friendsListStyles from '../../styles/create/friendsListStyles';
import TextOpenSans from '../utils/TextOpenSans';
const FriendsListView = (props) => {
const listContainerStyle = props.friends.getRowCount() === 0 ? friendsListStyles.emptyListContainer : friendsListStyles.listContainer;
return (
<View style={friendsListStyles.mainContainer}>
<View style={friendsListStyles.leftContainer} />
<View style={friendsListStyles.contentContainer}>
<View style={listContainerStyle}>
<ListView
enableEmptySections
keyboardShouldPersistTaps
dataSource={props.friends}
renderRow={rowData => (
<TouchableOpacity onPress={() => props.selectFriend(rowData)}>
<View style={friendsListStyles.friendContainer}>
<Image
style={friendsListStyles.imageContainer}
source={{ uri: rowData.picture }}
/>
<TextOpenSans style={friendsListStyles.usernameFont}>{ rowData.username} </TextOpenSans>
</View>
</TouchableOpacity>
)}
/>
</View>
</View>
</View>
);
};
export default FriendsListView;
|
tests/components/RepoList/RepoList.spec.js
|
DeloitteDigitalUK/react-redux-starter-app
|
import React from 'react';
import RepoList from '../../../src/components/RepoList/';
import CardView from '../../../src/components/CardView/';
import { shallow } from 'enzyme';
describe('(Component) RepoList', () => {
let wrapper, props;
beforeEach(() => {
props = {
isLoading: false,
noReposText: 'No repositories to display.',
};
wrapper = undefined;
});
// i.e. It isn't totally broken. Only component test you need?
// https://gist.github.com/thevangelist/e2002bc6b9834def92d46e4d92f15874
it('renders successfully', () => {
wrapper = shallow(<RepoList {...props} />);
expect(wrapper).to.have.length(1);
});
it('shows a loading message when still loading', () => {
wrapper = shallow(<RepoList {...props} isLoading={true} />);
const paragraphs = wrapper.find('p');
expect(paragraphs).to.have.length(1);
expect(paragraphs.text()).to.match(/Loading/);
});
it('shows a message when there are no repos', () => {
wrapper = shallow(<RepoList {...props} repos={[]} />);
const paragraphs = wrapper.find('p');
expect(paragraphs).to.have.length(1);
expect(paragraphs.text()).to.match(/No repositories/);
});
it('creates a CardView for each repo', () => {
const repos = [
{
id: 1,
name: 'Test 1',
description: 'Desc',
url: 'http://site.com',
},
{
id: 2,
name: 'Test 2',
description: 'Desc',
url: 'http://site.com',
}
];
wrapper = shallow(<RepoList {...props} repos={repos} />);
expect(wrapper.find(CardView)).to.have.length(repos.length);
});
});
|
blueprints/layout/files/__test__/layouts/__name__Layout.spec.js
|
jeffaustin81/cropcompass-ui
|
import React from 'react'
describe('(Layout) <%= pascalEntityName %>', () => {
it('should exist', () => {
})
})
|
src/select/index.js
|
denisraslov/react-spreadsheet-table
|
import React from 'react';
import PropTypes from 'prop-types';
import Dropdown from './../dropdown';
import keys from './../kit/keymap';
import find from 'lodash.find';
import styles from './styles.css';
class SpreadsheetGridSelect extends React.PureComponent {
constructor(props) {
super(props);
this.onGlobalKeyDown = this.onGlobalKeyDown.bind(this);
this.onItemMouseLeave = this.onItemMouseLeave.bind(this);
this.state = {
isOpen: this.props.isOpen,
selectedId: this.props.selectedId
};
}
static getDerivedStateFromProps({ isOpen, selectedId }, prevState) {
return {
...prevState,
isOpen,
selectedId
};
}
componentDidMount() {
document.addEventListener('keydown', this.onGlobalKeyDown, false);
}
componentWillUnmount() {
document.removeEventListener('keydown', this.onGlobalKeyDown, false);
}
onItemClick(selectedId, item) {
this.setState({
selectedId,
isOpen: false
}, () => {
if (this.props.onChange) {
this.props.onChange(selectedId, item);
}
});
}
onItemMouseEnter(selectedIndex) {
this.setState({
selectedIndex
});
}
onItemMouseLeave() {
this.setState({
selectedIndex: null
});
}
onGlobalKeyDown(e) {
if (this.state.isOpen) {
if (e.keyCode === keys.DOWN) {
e.preventDefault();
if (this.state.selectedIndex || this.state.selectedIndex === 0) {
this.setState({
selectedIndex: this.state.selectedIndex + 1
});
} else {
this.setState({
selectedIndex: 0
});
}
if (this.state.selectedIndex > this.props.items.length - 1) {
this.setState({
selectedIndex: 0
});
}
}
if (e.keyCode === keys.UP) {
e.preventDefault();
if (this.state.selectedIndex || this.state.selectedIndex === 0) {
this.setState({
selectedIndex: this.state.selectedIndex - 1
});
} else {
this.setState({
selectedIndex: this.props.items.length - 1
});
}
if (this.state.selectedIndex < 0) {
this.setState({
selectedIndex: this.props.items.length - 1
});
}
}
if (e.keyCode === keys.ENTER || e.keyCode === keys.TAB) {
if (this.state.selectedIndex || this.state.selectedIndex === 0) {
const selectedItem = this.props.items[this.state.selectedIndex];
this.onItemClick(selectedItem.id, selectedItem);
}
}
e.preventDefault();
}
}
getItemClassName(isSelected) {
return 'SpreadsheetGridSelectItem' +
(isSelected ? ' SpreadsheetGridSelectItem_selected' : '');
}
isHasValue() {
return this.state.selectedId && this.props.items;
}
getHeaderValue() {
let value;
if (this.isHasValue()) {
value = find(this.props.items, {
id: this.state.selectedId
});
value = value ? value.name : value;
} else {
value = this.props.placeholder;
}
return value;
}
getHeaderClassName() {
return 'SpreadsheetGridSelectHeader' +
(this.state.isOpen ? ' SpreadsheetGridSelectHeader_open' : '');
}
renderHeader() {
return (
<div className={this.getHeaderClassName()}>
<div className="SpreadsheetGridSelectValue">
{this.getHeaderValue()}
</div>
</div>
);
}
renderBody() {
const items = this.props.items;
return (
<div>
{
items && items.map((item, i) => {
return (
<div
key={i}
className={this.getItemClassName(i === this.state.selectedIndex)}
onClick={this.onItemClick.bind(this, item.id, item)}
onMouseEnter={this.onItemMouseEnter.bind(this, i)}
onMouseLeave={this.onItemMouseLeave}
>
{item.name}
</div>
);
})
}
</div>
);
}
render() {
return (
<Dropdown
header={this.renderHeader()}
body={this.renderBody()}
isOpen={this.state.isOpen}
/>
);
}
}
const IdPropType = PropTypes.oneOfType([
PropTypes.string,
PropTypes.number
]);
SpreadsheetGridSelect.propTypes = {
selectedId: IdPropType,
items: PropTypes.arrayOf(
PropTypes.shape({
id: IdPropType,
value: PropTypes.string
})
),
onChange: PropTypes.func,
placeholder: PropTypes.string,
isOpen: PropTypes.bool
};
SpreadsheetGridSelect.defaultProps = {
items: [],
placeholder: '',
isOpen: false
};
export default SpreadsheetGridSelect;
|
examples/todos/components/Footer.js
|
mjw56/redux
|
import React from 'react'
import FilterLink from '../containers/FilterLink'
const Footer = () => (
<p>
Show:
{" "}
<FilterLink filter="SHOW_ALL">
All
</FilterLink>
{", "}
<FilterLink filter="SHOW_ACTIVE">
Active
</FilterLink>
{", "}
<FilterLink filter="SHOW_COMPLETED">
Completed
</FilterLink>
</p>
)
export default Footer
|
__tests__/tests/components/CodeLine.js
|
dyesseyumba/git-point
|
import React from 'react';
import { shallow } from 'enzyme';
import { CodeLine } from 'components';
describe('<CodeLine />', () => {
it('correctly renders patch line', () => {
const wrapper = shallow(
<CodeLine
newChunk
change={{ content: 'test line' }}
filename={'test.js'}
/>
).childAt(0);
const lineNumbers = wrapper.childAt(0);
const lineContent = wrapper
.childAt(1)
.childAt(0)
.childAt(0);
expect(
lineNumbers
.childAt(0)
.childAt(0)
.text()
).toEqual('...');
expect(
lineNumbers
.childAt(1)
.childAt(0)
.text()
).toEqual('...');
expect(lineContent.text()).toEqual('test line');
});
it('correctly renders normal line', () => {
const wrapper = shallow(
<CodeLine
newChunk
change={{ content: 'test line', type: 'normal', ln1: 50, ln2: 51 }}
filename={'test.js'}
/>
).childAt(0);
const lineNumbers = wrapper.childAt(0);
const lineContent = wrapper
.childAt(1)
.childAt(0)
.childAt(0);
expect(
lineNumbers
.childAt(0)
.childAt(0)
.text()
).toEqual('50');
expect(
lineNumbers
.childAt(1)
.childAt(0)
.text()
).toEqual('51');
expect(lineContent.text()).toEqual('test line');
});
it('correctly renders addition line', () => {
const wrapper = shallow(
<CodeLine
change={{ content: 'test line', type: 'add', ln: 57 }}
filename={'test.js'}
/>
).childAt(0);
const lineNumbers = wrapper.childAt(0);
const lineContent = wrapper
.childAt(1)
.childAt(0)
.childAt(0);
expect(
lineNumbers
.childAt(0)
.childAt(0)
.text()
).toEqual('');
expect(
lineNumbers
.childAt(1)
.childAt(0)
.text()
).toEqual('57');
expect(lineContent.text()).toEqual('test line');
});
it('correctly renders deletion line', () => {
const wrapper = shallow(
<CodeLine
change={{ content: 'test line', type: 'del', ln: 57 }}
filename={'test.js'}
/>
).childAt(0);
const lineNumbers = wrapper.childAt(0);
const lineContent = wrapper
.childAt(1)
.childAt(0)
.childAt(0);
expect(
lineNumbers
.childAt(0)
.childAt(0)
.text()
).toEqual('57');
expect(
lineNumbers
.childAt(1)
.childAt(0)
.text()
).toEqual('');
expect(lineContent.text()).toEqual('test line');
});
});
|
test/specs/collections/Menu/Menu-test.js
|
aabustamante/Semantic-UI-React
|
import _ from 'lodash'
import React from 'react'
import Menu from 'src/collections/Menu/Menu'
import MenuItem from 'src/collections/Menu/MenuItem'
import MenuHeader from 'src/collections/Menu/MenuHeader'
import MenuMenu from 'src/collections/Menu/MenuMenu'
import { SUI } from 'src/lib'
import * as common from 'test/specs/commonTests'
import { sandbox } from 'test/utils'
describe('Menu', () => {
common.isConformant(Menu)
common.hasSubComponents(Menu, [MenuHeader, MenuItem, MenuMenu])
common.hasUIClassName(Menu)
common.rendersChildren(Menu)
common.implementsWidthProp(Menu, SUI.WIDTHS, {
canEqual: false,
propKey: 'widths',
})
common.propKeyAndValueToClassName(Menu, 'fixed', ['left', 'right', 'bottom', 'top'])
common.propKeyOnlyToClassName(Menu, 'borderless')
common.propKeyOnlyToClassName(Menu, 'compact')
common.propKeyOnlyToClassName(Menu, 'fluid')
common.propKeyOnlyToClassName(Menu, 'inverted')
common.propKeyOnlyToClassName(Menu, 'pagination')
common.propKeyOnlyToClassName(Menu, 'pointing')
common.propKeyOnlyToClassName(Menu, 'secondary')
common.propKeyOnlyToClassName(Menu, 'stackable')
common.propKeyOnlyToClassName(Menu, 'text')
common.propKeyOnlyToClassName(Menu, 'vertical')
common.propKeyOrValueAndKeyToClassName(Menu, 'attached', ['top', 'bottom'])
common.propKeyOrValueAndKeyToClassName(Menu, 'floated', ['right'])
common.propKeyOrValueAndKeyToClassName(Menu, 'icon', ['labeled'])
common.propKeyOrValueAndKeyToClassName(Menu, 'tabular', ['right'])
common.propValueOnlyToClassName(Menu, 'color', SUI.COLORS)
common.propValueOnlyToClassName(Menu, 'size', _.without(SUI.SIZES, 'medium', 'big'))
it('renders a `div` by default', () => {
shallow(<Menu />)
.should.have.tagName('div')
})
describe('activeIndex', () => {
const items = [
{ key: 'home', name: 'home' },
{ key: 'users', name: 'users' },
]
it('is null by default', () => {
shallow(<Menu items={items} />)
.should.not.have.descendants('.active')
})
it('is set when clicking an item', () => {
const wrapper = mount(<Menu items={items} />)
wrapper
.find('MenuItem')
.at(1)
.simulate('click')
// must re-query for the menu items or we get a cached copy
wrapper
.find('MenuItem')
.at(1)
.should.have.prop('active', true)
})
})
describe('items', () => {
const spy = sandbox.spy()
const items = [
{ key: 'home', name: 'home', onClick: spy, 'data-foo': 'something' },
{ key: 'users', name: 'users', active: true, 'data-foo': 'something' },
]
const children = mount(<Menu items={items} />).find('MenuItem')
it('renders children', () => {
children.first().should.have.prop('name', 'home')
children.last().should.have.prop('name', 'users')
})
it('onClick can omitted', () => {
const click = () => children.last().simulate('click')
expect(click).to.not.throw()
})
it('passes onClick handler', () => {
const event = { target: null }
const props = { name: 'home', index: 0 }
children.first().simulate('click', event)
spy.should.have.been.calledOnce()
spy.should.have.been.calledWithMatch(event, props)
})
it('passes arbitrary props', () => {
children.everyWhere(item => item.should.have.prop('data-foo', 'something'))
})
})
describe('onItemClick', () => {
it('can be omitted', () => {
const click = () => mount(<Menu items={[{ key: 'home', name: 'home' }]} />)
.find('MenuItem')
.first()
.simulate('click')
expect(click).to.not.throw()
})
it('is called with (e, { name, index }) when clicked', () => {
const event = { target: null }
const itemSpy = sandbox.spy()
const menuSpy = sandbox.spy()
const items = [
{ key: 'home', name: 'home' },
{ key: 'users', name: 'users', onClick: itemSpy },
]
const matchProps = { index: 1, name: 'users' }
mount(<Menu items={items} onItemClick={menuSpy} />)
.find('MenuItem')
.last()
.simulate('click', event)
itemSpy.should.have.been.calledOnce()
itemSpy.should.have.been.calledWithMatch(event, matchProps)
menuSpy.should.have.been.calledOnce()
menuSpy.should.have.been.calledWithMatch(event, matchProps)
})
})
})
|
src/svg-icons/hardware/gamepad.js
|
mit-cml/iot-website-source
|
import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let HardwareGamepad = (props) => (
<SvgIcon {...props}>
<path d="M15 7.5V2H9v5.5l3 3 3-3zM7.5 9H2v6h5.5l3-3-3-3zM9 16.5V22h6v-5.5l-3-3-3 3zM16.5 9l-3 3 3 3H22V9h-5.5z"/>
</SvgIcon>
);
HardwareGamepad = pure(HardwareGamepad);
HardwareGamepad.displayName = 'HardwareGamepad';
HardwareGamepad.muiName = 'SvgIcon';
export default HardwareGamepad;
|
app/javascript/mastodon/features/compose/components/upload_form.js
|
kibousoft/mastodon
|
import React from 'react';
import ImmutablePropTypes from 'react-immutable-proptypes';
import UploadProgressContainer from '../containers/upload_progress_container';
import ImmutablePureComponent from 'react-immutable-pure-component';
import UploadContainer from '../containers/upload_container';
export default class UploadForm extends ImmutablePureComponent {
static propTypes = {
mediaIds: ImmutablePropTypes.list.isRequired,
};
render () {
const { mediaIds } = this.props;
return (
<div className='compose-form__upload-wrapper'>
<UploadProgressContainer />
<div className='compose-form__uploads-wrapper'>
{mediaIds.map(id => (
<UploadContainer id={id} key={id} />
))}
</div>
</div>
);
}
}
|
src/containers/auth/SignupScreen.js
|
meetfranz/franz
|
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { inject, observer } from 'mobx-react';
import Signup from '../../components/auth/Signup';
import UserStore from '../../stores/UserStore';
import FeaturesStore from '../../stores/FeaturesStore';
import { globalError as globalErrorPropType } from '../../prop-types';
export default @inject('stores', 'actions') @observer class SignupScreen extends Component {
static propTypes = {
error: globalErrorPropType.isRequired,
};
onSignup(values) {
const { actions, stores } = this.props;
const { canSkipTrial, defaultTrialPlan, pricingConfig } = stores.features.anonymousFeatures;
if (!canSkipTrial) {
Object.assign(values, {
plan: defaultTrialPlan,
currency: pricingConfig.currencyID,
});
}
actions.user.signup(values);
}
render() {
const { stores, error } = this.props;
return (
<Signup
onSubmit={values => this.onSignup(values)}
isSubmitting={stores.user.signupRequest.isExecuting}
loginRoute={stores.user.loginRoute}
error={error}
/>
);
}
}
SignupScreen.wrappedComponent.propTypes = {
actions: PropTypes.shape({
user: PropTypes.shape({
signup: PropTypes.func.isRequired,
}).isRequired,
}).isRequired,
stores: PropTypes.shape({
user: PropTypes.instanceOf(UserStore).isRequired,
features: PropTypes.instanceOf(FeaturesStore).isRequired,
}).isRequired,
};
|
src/helpers/Html.js
|
bertho-zero/react-redux-universal-hot-example
|
import React from 'react';
import PropTypes from 'prop-types';
import serialize from 'serialize-javascript';
import Helmet from 'react-helmet';
import config from 'config';
/**
* Wrapper component containing HTML metadata and boilerplate tags.
* Used in server-side code only to wrap the string output of the
* rendered route component.
*
* The only thing this component doesn't (and can't) include is the
* HTML doctype declaration, which is added to the rendered output
* by the server.js file.
*/
const Html = ({
assets, store, content, bundles
}) => {
const head = Helmet.renderStatic();
/* eslint-disable react/no-danger */
return (
<html lang="en-US">
<head>
{head.base.toComponent()}
{head.title.toComponent()}
{head.meta.toComponent()}
{head.link.toComponent()}
{head.script.toComponent()}
<link rel="shortcut icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="manifest" href="/manifest.json" />
<meta name="mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="application-name" content="React Hot" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<meta name="apple-mobile-web-app-title" content="React Hot" />
<meta name="theme-color" content="#3677dd" />
{/* styles (will be present only in production with webpack extract text plugin) */}
{assets.styles
&& Object.keys(assets.styles).map(style => (
<link
href={assets.styles[style]}
key={style}
media="screen, projection"
rel="stylesheet"
type="text/css"
charSet="UTF-8"
/>
))}
{/* (will be present only in development mode) */}
{assets.styles && Object.keys(assets.styles).length === 0 ? (
<style dangerouslySetInnerHTML={{ __html: '#content{display:none}' }} />
) : null}
</head>
<body>
<div id="content" dangerouslySetInnerHTML={{ __html: content }} />
{store && (
<script
dangerouslySetInnerHTML={{
__html: `window.__PRELOADED__=true;window.__data=${serialize(store.getState())};`
}}
charSet="UTF-8"
/>
)}
{assets.javascript && <script src={assets.javascript.main} charSet="UTF-8" />}
{bundles.map(bundle => bundle && <script src={config.assetsPath + bundle.file} key={bundle.id} />)}
{/* (will be present only in development mode) */}
{assets.styles && Object.keys(assets.styles).length === 0 ? (
<script dangerouslySetInnerHTML={{ __html: 'document.getElementById("content").style.display="block";' }} />
) : null}
</body>
</html>
);
/* eslint-enable react/no-danger */
};
Html.propTypes = {
assets: PropTypes.shape({
styles: PropTypes.object,
javascript: PropTypes.object
}),
bundles: PropTypes.arrayOf(PropTypes.any),
content: PropTypes.string,
store: PropTypes.shape({
getState: PropTypes.func
}).isRequired
};
Html.defaultProps = {
assets: {},
bundles: [],
content: ''
};
export default Html;
|
admin/client/App/elemental/DropdownButton/index.js
|
helloworld3q3q/keystone
|
/* eslint quote-props: ["error", "as-needed"] */
import React from 'react';
import { css, StyleSheet } from 'aphrodite/no-important';
import Button from '../Button';
function DropdownButton ({ children, ...props }) {
return (
<Button {...props}>
{children}
<span className={css(classes.arrow)} />
</Button>
);
};
// NOTE
// 1: take advantage of `currentColor` by leaving border top color undefined
// 2: even though the arrow is vertically centered, visually it appears too low
// because of lowercase characters beside it
const classes = StyleSheet.create({
arrow: {
borderLeft: '0.3em solid transparent',
borderRight: '0.3em solid transparent',
borderTop: '0.3em solid', // 1
display: 'inline-block',
height: 0,
marginTop: '-0.125em', // 2
verticalAlign: 'middle',
width: 0,
// add spacing
':first-child': {
marginRight: '0.5em',
},
':last-child': {
marginLeft: '0.5em',
},
},
});
module.exports = DropdownButton;
|
docs/app/Examples/collections/Form/FieldVariations/index.js
|
vageeshb/Semantic-UI-React
|
import React from 'react'
import ExampleSection from 'docs/app/Components/ComponentDoc/ExampleSection'
import ComponentExample from 'docs/app/Components/ComponentDoc/ComponentExample'
const FormFieldVariationsExamples = () => (
<ExampleSection title='Field Variations'>
<ComponentExample
title='Inline'
description='A field can have its label next to instead of above it.'
examplePath='collections/Form/FieldVariations/FormExampleInlineField'
/>
</ExampleSection>
)
export default FormFieldVariationsExamples
|
docs/app/Examples/modules/Dropdown/Types/DropdownExampleInlineTwo.js
|
shengnian/shengnian-ui-react
|
import React from 'react'
import { Dropdown, Header, Icon } from 'shengnian-ui-react'
const options = [
{
key: 'today',
text: 'today',
value: 'today',
content: 'Today',
},
{
key: 'this week',
text: 'this week',
value: 'this week',
content: 'This Week',
},
{
key: 'this month',
text: 'this month',
value: 'this month',
content: 'This Month',
},
]
const DropdownExampleInlineTwo = () => (
<Header as='h4'>
<Icon name='trophy' />
<Header.Content>
Trending repos
{' '}
<Dropdown inline header='Adjust time span' options={options} defaultValue={options[0].value} />
</Header.Content>
</Header>
)
export default DropdownExampleInlineTwo
|
src/app/Footer.js
|
halhenke/life-letters
|
import React from 'react';
import styles from './Footer.css';
export default class Footer extends React.Component {
render() {
return (
<footer className={styles.footer}>
<p>2015 © Hal Henke</p>
</footer>
);
}
}
|
examples/Accordion.js
|
15lyfromsaturn/react-materialize
|
import React from 'react';
import Collapsible from '../src/Collapsible';
import CollapsibleItem from '../src/CollapsibleItem';
export default
<Collapsible accordion defaultActiveKey={1}>
<CollapsibleItem header='First' icon='filter_drama' eventKey={1}>
Lorem ipsum dolor sit amet.
</CollapsibleItem>
<CollapsibleItem header='Second' icon='place' eventKey={2}>
Lorem ipsum dolor sit amet.
</CollapsibleItem>
<CollapsibleItem header='Third' icon='whatshot' eventKey={3}>
Lorem ipsum dolor sit amet.
</CollapsibleItem>
</Collapsible>;
|
src/ParaRowTextEditor.js
|
OCMC-Translation-Projects/ioc-liturgical-react
|
import React from 'react';
import PropTypes from 'prop-types';
import {
Button
, Checkbox
, Col
, ControlLabel
, FormControl
, Glyphicon
, Grid
, Row
, Tab
, Tabs
, Well
} from 'react-bootstrap';
import { get } from 'lodash';
import {BootstrapTable, TableHeaderColumn} from 'react-bootstrap-table';
import FontAwesome from 'react-fontawesome';
import axios from 'axios';
import Server from './helpers/Server';
import NotesLister from './NotesLister';
import Grammar from './modules/Grammar';
import Spinner from './helpers/Spinner';
import TextNotesLister from './TextNotesLister';
import ResourceSelector from './modules/ReactSelector';
import WorkflowForm from './helpers/WorkflowForm';
/**
* Display a text to edit, with source and models as rows.
*/
export class ParaRowTextEditor extends React.Component {
constructor(props) {
super(props);
let pdfSubTitle = "";
let prefs = {};
if (props.session.userInfo && props.session.userInfo.prefs) {
prefs = props.session.userInfo.prefs;
if (prefs.includeNotesTransAdvice) {
pdfSubTitle = "A Liturgical Translator's Manual";
}
}
let citeData = [];
if (props.session.dropdowns) {
citeData = props.session.dropdowns.bibTexStylesDropdown;
}
let labels = props.session.labels;
let labelTopics = props.session.labelTopics;
this.state =
{
labels: {
thisClass: labels[labelTopics.ParaTextEditor]
, buttons: labels[labelTopics.button]
, messages: labels[labelTopics.messages]
, search: labels[labelTopics.search]
}
, citeData: citeData
, citeStyle: prefs.bibLatexStyle ? prefs.bibLatexStyle : "authoryear"
, greekSourceValue: ""
, greekSourceId: ""
, showSearchResults: false
, message: get(this.state,"message", labels[labelTopics.search].msg1)
, downloadMessage: ""
,
messageIcon: get(this.state,"messageIcon", this.messageIcons.info)
,
data: {values: [{"id": "", "value:": ""}]}
,
options: {
sizePerPage: 30
, sizePerPageList: [5, 15, 30]
, onSizePerPageList: this.onSizePerPageList
, hideSizePerPage: true
, paginationShowsTotal: true
}
,
showSelectionButtons: false
,
selectedId: ""
,
selectedValue: ""
,
selectedIdPartsPrompt: "Select one or more ID parts, then click on the search icon:"
,
selectedIdParts: [
{key: "domain", label: ""},
{key: "topic", label: ""},
{key: "key", label: ""}
]
, showIdPartSelector: false
, idColumnSize: "80px"
, editorValue: props.value
, currentDocType: props.docType
, currentId: props.idLibrary + "~" + props.idTopic + "~" + props.idKey
, currentIdLibrary: props.idLibrary
, currentIdTopic: props.idTopic
, currentIdKey: props.idKey
, domain: "*"
, selectedBook: "*"
, selectedChapter: "*"
, docProp: "id"
, matcher: "ew"
, query: "~"
+ props.idTopic
+ "~"
+ props.idKey
, pdfId: ""
, pdfTitle: ""
, pdfSubTitle: pdfSubTitle
, pdfAuthor: prefs.author ? prefs.author : ""
, pdfAuthorTitle: prefs.authorTitle ? prefs.authorTitle : ""
, pdfAuthorAffiliation: prefs.authorAffiliation ? prefs.authorAffiliation : ""
, includeAdviceNotes: prefs.includeNotesTransAdvice ? prefs.includeNotesTransAdvice : ""
, includePersonalNotes: prefs.includeNotesUser ? prefs.includeNotesUser : ""
, includeGrammar: prefs.includeGrammar ? prefs.includeGrammar : ""
, combineNotes: prefs.combineNotes ? prefs.combineNotes : ""
, createToc: prefs.createToc ? prefs.createToc : ""
, showDownloadLinks: false
, preparingDownloads: false
, biblatex: "http://ftp.math.purdue.edu/mirrors/ctan.org/macros/latex/contrib/biblatex/doc/biblatex.pdf"
, submitDisabled: true
};
this.fetchData = this.fetchData.bind(this);
this.getDownloadLinks = this.getDownloadLinks.bind(this);
this.getParaRows = this.getParaRows.bind(this);
this.getTabs = this.getTabs.bind(this);
this.getTextArea = this.getTextArea.bind(this);
this.getTitleRow = this.getTitleRow.bind(this);
this.getWorkflowPanel = this.getWorkflowPanel.bind(this);
this.getStatusIcon = this.getStatusIcon.bind(this);
this.getVisibilityIcon = this.getVisibilityIcon.bind(this);
this.handleciteStyleChange = this.handleciteStyleChange.bind(this);
this.handleDownloadRequest = this.handleDownloadRequest.bind(this);
this.handleDownloadCallback = this.handleDownloadCallback.bind(this);
this.handleEditorChange = this.handleEditorChange.bind(this);
this.handleIncludeAdviceNotesChange = this.handleIncludeAdviceNotesChange.bind(this);
this.handleIncludeGrammarChange = this.handleIncludeGrammarChange.bind(this);
this.handleIncludePersonalNotesChange = this.handleIncludePersonalNotesChange.bind(this);
this.handleCombineNotesChange = this.handleCombineNotesChange.bind(this);
this.handleCreateTocChange = this.handleCreateTocChange.bind(this);
this.handlePdfAuthorChange = this.handlePdfAuthorChange.bind(this);
this.handlePdfAuthorAffiliationChange = this.handlePdfAuthorAffiliationChange.bind(this);
this.handlePdfAuthorTitleChange = this.handlePdfAuthorTitleChange.bind(this);
this.handlePdfTitleChange = this.handlePdfTitleChange.bind(this);
this.handlePdfSubTitleChange = this.handlePdfSubTitleChange.bind(this);
this.handlePropsChange = this.handlePropsChange.bind(this);
this.handleStateChange = this.handleStateChange.bind(this);
this.handleSubmit = this.handleSubmit.bind(this);
this.handleValueUpdateCallback = this.handleValueUpdateCallback.bind(this);
this.handleWorkflowCallback = this.handleWorkflowCallback.bind(this);
this.notifyParentValueChanged = this.notifyParentValueChanged.bind(this);
this.setMessage = this.setMessage.bind(this);
this.submitDisabled = this.submitDisabled.bind(this);
};
componentWillMount = () => {
this.fetchData();
};
componentWillReceiveProps = (nextProps) => {
let prefs = {};
let pdfSubTitle = get(this.state, "pdfSubTitle", "");
if (nextProps.session.userInfo && nextProps.session.userInfo.prefs) {
prefs = nextProps.session.userInfo.prefs;
if (pdfSubTitle.length === 0 && prefs.includeNotesTransAdvice) {
pdfSubTitle = "A Liturgical Translator's Manual";
}
}
let citeData = [];
if (nextProps.session.dropdowns) {
citeData = nextProps.session.dropdowns.bibTexStylesDropdown;
}
let labels = nextProps.session.labels;
let labelTopics = nextProps.session.labelTopics;
this.setState((prevState, props) => {
return {
labels: {
thisClass: labels[labelTopics.ParaTextEditor]
, buttons: labels[labelTopics.button]
, messages: labels[labelTopics.messages]
, search: labels[labelTopics.search]
}
, message: get(prevState,"message", labels[labelTopics.search].msg1)
, messageIcon: get(prevState,"messageIcon", this.messageIcons.info)
, greekSourceValue: ""
, greekSourceId: ""
, citeData: citeData
, citeStyle: prefs.bibLatexStyle ? prefs.bibLatexStyle : "authoryear"
, pdfSubTitle: pdfSubTitle
, pdfAuthor: prefs.author ? prefs.author : ""
, pdfAuthorTitle: prefs.authorTitle ? prefs.authorTitle : ""
, pdfAuthorAffiliation: prefs.authorAffiliation ? prefs.authorAffiliation : ""
, includeAdviceNotes: prefs.includeNotesTransAdvice ? prefs.includeNotesTransAdvice : ""
, includePersonalNotes: prefs.includeNotesUser ? prefs.includeNotesUser : ""
, includeGrammar: prefs.includeGrammar ? prefs.includeGrammar : ""
, combineNotes: prefs.combineNotes ? prefs.combineNotes : ""
, createToc: prefs.createToc ? prefs.createToc : ""
}
}, function () { return this.handleStateChange("place holder")});
};
// if we need to do something after setState, do it here...
handleStateChange = (parm) => {
this.handlePropsChange();
};
/**
* Because we are passing back the value each time it changes,
* componentWillReceiveProps keeps getting called.
* We don't want that to result in calling fetchData unless
* the docType, library, topic, or key changed.
*/
handlePropsChange = () => {
if (this.state.currentDocType !== this.props.docType
|| this.state.currentIdLibrary !== this.props.idLibrary
|| this.state.currentIdTopic !== this.props.idTopic
|| this.state.currentIdKey !== this.props.idKey
) {
this.fetchData();
}
};
/**
* font-awesome icons for messages
* @type {{info: string, warning: string, error: string}}
*/
messageIcons = {
info: "info-circle"
, warning: "lightbulb-o"
, error: "exclamation-triangle"
// , toggleOn: "eye"
// , toggleOff: "eye-slash"
, toggleOn: "toggle-on"
, toggleOff: "toggle-off"
, simpleSearch: "minus"
, advancedSearch: "bars"
, idPatternSearch: "key"
};
setMessage(message) {
this.setState({
message: message
});
};
fetchData() {
this.setState({
message: this.state.labels.search.msg2
, messageIcon: this.messageIcons.info
});
let config = {
auth: {
username: this.props.session.userInfo.username
, password: this.props.session.userInfo.password
}
};
let parms =
"?t=" + encodeURIComponent(this.props.docType)
+ "&d=" + encodeURIComponent(this.state.domain)
+ "&b=" + encodeURIComponent(this.state.selectedBook)
+ "&c=" + encodeURIComponent(this.state.selectedChapter)
+ "&q=" + encodeURIComponent(this.state.query)
+ "&p=" + encodeURIComponent(this.state.docProp)
+ "&m=" + encodeURIComponent(this.state.matcher)
;
let path = this.props.session.restServer + Server.getWsServerDbApi() + 'docs' + parms;
axios.get(path, config)
.then(response => {
let greekSource = response.data.values.find( o => o.id.startsWith("gr_gr_cog"));
let greekSourceId = "";
let greekSourceValue = "";
let pdfTitle = this.state.pdfTitle;
if (greekSource) {
greekSourceId = greekSource.id;
greekSourceValue = greekSource.value;
if (pdfTitle.length === 0) {
if (greekSourceValue.length > 31) {
let words = greekSourceValue.substring(0,30).split(/[\s,.;]/);
if (words.length > 4) {
pdfTitle = words[0] + " " + words[1] + " " + words[2] + " " + words[3];
} else if (words.length > 3) {
pdfTitle = words[0] + " " + words[1] + " " + words[2];
} else if (words.length > 2) {
pdfTitle = words[0] + " " + words[1];
} else {
pdfTitle = words[0];
}
} else {
pdfTitle = greekSourceValue.substring(0,30);
}
}
}
let thisText = response.data.values.find( o => o.id === (this.props.idLibrary
+ "~"
+ this.props.idTopic
+ "~"
+ this.props.idKey
));
let workflow = {
assignedTo: ""
, status: "EDITING"
, visibility: "PRIVATE"
, statusIcon: "edit"
, visibilityIcon: "share-alt"
};
let originalWorkflow = {
assignedTo: ""
, status: "EDITING"
, visibility: "PRIVATE"
};
try {
if (thisText) {
if (thisText.status) {
let theStatus = thisText.status;
workflow.status = thisText.status;
originalWorkflow.status = theStatus;
workflow.statusIcon = this.getStatusIcon(thisText.status);
}
if (thisText.visibility) {
let theVisibility = thisText.visibility;
workflow.visibility = thisText.visibility;
originalWorkflow.visibility = theVisibility;
workflow.visibilityIcon = this.getVisibilityIcon(thisText.visibility);
}
}
} catch (err) {
console.log(err);
}
let values = response.data.values.filter((row) => {
return row.value.length > 0;
});
response.data.values = values;
let resultCount = 0;
let message = this.state.labels.search.foundNone;
let found = this.state.labels.search.foundMany;
if (values) {
resultCount = values.length;
if (resultCount === 0) {
message = this.state.labels.search.foundNone;
} else if (resultCount === 1) {
message = this.state.labels.search.foundOne;
} else {
message = found
+ " "
+ resultCount
+ ".";
}
}
this.setState({
message: message
, messageIcon: this.messageIcons.info
, showSearchResults: true
, data: response.data
, greekSourceId: greekSourceId
, greekSourceValue: greekSourceValue
, pdfTitle: pdfTitle
, thisText: thisText
, workflow: workflow
, originalWorkflow: originalWorkflow
}
);
})
.catch((error) => {
let message = error.message;
let messageIcon = this.messageIcons.error;
if (error && error.response && error.response.status === 404) {
message = this.state.labels.search.foundNone;
messageIcon = this.messageIcons.warning;
this.setState({data: message, message: message, messageIcon: messageIcon});
}
});
}
handleIncludeAdviceNotesChange = (evt) => {
let pdfSubTitle = this.state.pdfSubTitle;
if (this.state.includeAdviceNotes) {
if (pdfSubTitle && pdfSubTitle.startsWith("A Liturgical Translator's")) {
pdfSubTitle = "";
}
} else {
if (! pdfSubTitle) {
pdfSubTitle = "A Liturgical Translator's Manual";
}
}
this.setState(
{
includeAdviceNotes: evt.target.checked
, pdfSubTitle: pdfSubTitle
});
};
handleIncludePersonalNotesChange = (evt) => {
this.setState({ includePersonalNotes: evt.target.checked });
};
handleIncludeGrammarChange = (evt) => {
this.setState({ includeGrammar: evt.target.checked });
};
handleCombineNotesChange = (evt) => {
this.setState({ combineNotes: evt.target.checked });
};
handleCreateTocChange = (evt) => {
this.setState({ createToc: evt.target.checked });
};
getDownloadLinks = () => {
if (this.state.showDownloadLinks) {
let url = "data/" + this.state.pdfId;
return (
<Row className="App-Download-Row">
<Col className="App-Download-Col" xs={3} md={3}>
<a href={url + ".pdf"} target={"_blank"}>{this.state.labels.buttons.downloadAsPdf}</a>
</Col>
<Col className="App-Download-Col" xs={4} md={4}>
<a href={url + ".tex"} target={"_blank"}>{this.state.labels.buttons.downloadAsTex}</a>
</Col>
<Col className="App-Download-Col" xs={5} md={5}>
<a href={url + ".bib"} target={"_blank"}>{this.state.labels.buttons.downloadAsTexBib}</a>
</Col>
</Row>
);
} else {
if (this.state.preparingDownloads) {
return (
<Row className="App-Download-Row">
<Col className="App-Download-Col" xs={12} md={12}>
<Spinner message={this.state.labels.messages.preparingPdf}/>
</Col>
</Row>
);
} else {
return (<span></span>);
}
}
};
handleciteStyleChange = (selection) => {
this.setState({
citeStyle: selection["value"]
});
};
handleDownloadRequest = () => {
this.setState({
preparingDownloads: true
, showDownloadLinks: false
});
let id = "gr_gr_cog/"
+ this.props.idTopic
+ "/"
+ this.props.idKey
;
let includeAdviceNotes = "false";
let includePersonalNotes = "false";
let includeGrammar = "false";
let combineNotes = "false";
let createToc = "false";
if (this.state.includeAdviceNotes) {
includeAdviceNotes = "true";
}
if (this.state.includePersonalNotes) {
includePersonalNotes = "true";
}
if (this.state.includeGrammar) {
includeGrammar = "true";
}
if (this.state.combineNotes) {
combineNotes = "true";
}
if (this.state.includePersonalNotes) {
includePersonalNotes = "true";
}
if (this.state.createToc) {
createToc = "true";
}
let parms =
"ia=" + encodeURIComponent(includeAdviceNotes)
+ "&ip=" + encodeURIComponent(includePersonalNotes)
+ "&ig=" + encodeURIComponent(includeGrammar)
+ "&cn=" + encodeURIComponent(combineNotes)
+ "&toc=" + encodeURIComponent(createToc)
+ "&al=" + encodeURIComponent(this.props.idLibrary)
+ "&mt=" + encodeURIComponent(this.state.pdfTitle)
+ "&st=" + encodeURIComponent(this.state.pdfSubTitle)
+ "&au=" + encodeURIComponent(this.state.pdfAuthor)
+ "&at=" + encodeURIComponent(this.state.pdfAuthorTitle)
+ "&af=" + encodeURIComponent(this.state.pdfAuthorAffiliation)
+ "&cs=" + encodeURIComponent(this.state.citeStyle)
;
Server.getTextDownloads(
this.props.session.restServer
, this.props.session.userInfo.username
, this.props.session.userInfo.password
, id
, parms
, this.handleDownloadCallback
);
};
getWorkflowPanel = () => {
if (this.props.canChange && ! this.props.idLibrary.includes("_sys_")) {
return (
<Tab eventKey={"workflow"} title={this.state.labels.thisClass.workflowPanel}>
<Well>
<WorkflowForm
session={this.props.session}
callback={this.handleWorkflowCallback}
library={this.props.idLibrary}
status={this.state.workflow.status}
visibility={this.state.workflow.visibility}
/>
</Well>
</Tab>
);
}
};
getStatusIcon = (status) => {
let statusIcon = "edit";
switch (status) {
case ("EDITING"): {
statusIcon = "edit";
break;
}
case ("REVIEWING"): {
statusIcon = "eye-open";
break;
}
case ("FINALIZED"): {
statusIcon = "check";
break;
}
default: {
let statusIcon = "edit";
}
}
return statusIcon;
};
getVisibilityIcon = (visibility) => {
let visibilityIcon = "lock";
switch (visibility) {
case ("PERSONAL"): {
visibilityIcon = "lock"; // user-secret
break;
}
case ("PRIVATE"): {
visibilityIcon = "share-alt";
break;
}
case ("PUBLIC"): {
visibilityIcon = "globe";
break;
}
default: {
let visibilityIcon = "lock";
}
}
return visibilityIcon;
};
handleWorkflowCallback = ( visibility, status, assignedTo ) => {
if (visibility && status) {
let statusIcon = this.getStatusIcon(status);
let visibilityIcon = this.getVisibilityIcon(visibility);
let workflow = this.state.workflow;
workflow.status = status;
workflow.visibility = visibility;
workflow.assignedToUser = assignedTo;
workflow.visibilityIcon = visibilityIcon;
workflow.statusIcon = statusIcon;
this.setState(
{
workflow: workflow
}, this.submitDisabled()
);
}
};
getPdf = () => {
this.setState({
preparingDownloads: true
, showDownloadLinks: false
});
let parms =
"id=" + encodeURIComponent(id)
;
Server.restGetPdf(
this.props.session.restServer
, Server.getDbServerAgesPdfApi()
, this.props.session.userInfo.username
, this.props.session.userInfo.password
, parms
, this.state.pdfFilename
)
.then( response => {
this.setState(
{
data: response
, preparingDownloads: false
, showDownloadLinks: true
}
);
})
.catch( error => {
this.setState(
{
data: {
values:
[
{
"id": ""
, "library": ""
, "topic": ""
, "key": ""
, "value:": ""
}
]
, userMessage: error.userMessage
, developerMessage: error.developerMessage
, messageIcon: error.messageIcon
, status: error.status
, showSearchResults: false
, resultCount: 0
, fetching: false
}
})
})
;
};
handleDownloadCallback = (restCallResult) => {
if (restCallResult && restCallResult.data && restCallResult.data.values) {
let data = restCallResult.data.values[0];
let pdfId = data.pdfId;
let pdfFilename = data.pdfFilename;
this.setState(
{
pdfId: pdfId
, pdfFilename: pdfFilename
, preparingDownloads: false
, showDownloadLinks: true
}
);
}
};
handlePdfStatusCallback = (result) => {
let statusMessage = this.state.labels.messages.couldNotGenerate;
let showPdfButton = false;
if (result.code === 200) {
let statusMessage = "";
showPdfButton = true;
}
this.setState({
fetchingPdf: false
, showPdfButton: showPdfButton
, generationStatusMessage: statusMessage
});
};
getTextArea = () => {
if (this.props.canChange && ! this.props.idLibrary.includes("_sys_")) {
return (
<div className="row">
<Well>
<div>
<ControlLabel>
{this.state.labels.thisClass.yourTranslation
+ " (" + this.props.idLibrary + ")"}
</ControlLabel>
</div>
<textarea
className="App-Modal-Editor-TextArea"
rows="4"
cols="100"
spellCheck="true"
value={this.state.editorValue}
onChange={this.handleEditorChange}
>
</textarea>
<div>
<Button
type="submit"
bsStyle="primary"
disabled={this.state.submitDisabled}
onClick={this.handleSubmit}
>
{this.state.labels.thisClass.submit}
</Button>
<span className="App App-message"><FontAwesome
name={this.state.messageIcon}/>
{this.state.message}
</span>
<span className="App App-Text-Editor-Workflow-Glyph">
<Glyphicon glyph={this.state.workflow.statusIcon}/>
<FontAwesome name={this.state.workflow.visibilityIcon}/>
</span>
</div>
</Well>
</div>
)
} else {
return (<span className="App App-no-display"></span>);
}
};
submitDisabled = () => {
if (this.state.editorValue === this.props.value
&& this.state.originalWorkflow.status === this.state.workflow.status
&& this.state.originalWorkflow.visibility === this.state.workflow.visibility
) {
this.setState({submitDisabled: true});
} else {
this.setState({submitDisabled: false});
}
};
handlePdfAuthorChange = (e) => {
this.setState({pdfAuthor: e.target.value});
};
handlePdfAuthorAffiliationChange = (e) => {
this.setState({pdfAuthorAffiliation: e.target.value});
};
handlePdfAuthorTitleChange = (e) => {
this.setState({pdfAuthorTitle: e.target.value});
};
handlePdfTitleChange = (e) => {
this.setState({pdfTitle: e.target.value});
};
handlePdfSubTitleChange = (e) => {
this.setState({pdfSubTitle: e.target.value});
};
getTitleRow = () => {
return (
<div>
<Row className="App show-grid App-PDF-Title-Row">
<Col xs={3} md={3}>
<ControlLabel>{this.state.labels.thisClass.pdfTitle}:</ControlLabel>
</Col>
<Col xs={9} md={9}>
<FormControl
id={"fxPdfTitle"}
className={"App App-PDF-Title"}
type="text"
value={this.state.pdfTitle}
placeholder={this.state.labels.thisClass.pdfTitle}
onChange={this.handlePdfTitleChange}
/>
</Col>
</Row>
<Row className="App show-grid App-PDF-Title-Row">
<Col xs={3} md={3}>
<ControlLabel>{this.state.labels.thisClass.pdfSubTitle}:</ControlLabel>
</Col>
<Col xs={9} md={9}>
<FormControl
id={"fxPdfSubTitle"}
className={"App App-PDF-Title"}
type="text"
value={this.state.pdfSubTitle}
placeholder={this.state.labels.thisClass.pdfSubTitle}
onChange={this.handlePdfSubTitleChange}
/>
</Col>
</Row>
<Row className="App show-grid App-PDF-Author-Row">
<Col xs={3} md={3}>
<ControlLabel>{this.state.labels.thisClass.pdfAuthor}:</ControlLabel>
</Col>
<Col xs={9} md={9}>
<FormControl
id={"fxPdfAuthor"}
className={"App App-PDF-Author"}
type="text"
value={this.state.pdfAuthor}
placeholder={this.state.labels.thisClass.pdfAuthor}
onChange={this.handlePdfAuthorChange}
/>
</Col>
</Row>
<Row className="App show-grid App-PDF-Author-Row">
<Col xs={3} md={3}>
<ControlLabel>{this.state.labels.thisClass.pdfAuthorTitle}:</ControlLabel>
</Col>
<Col xs={9} md={9}>
<FormControl
id={"fxPdfAuthorTitle"}
className={"App App-PDF-Author"}
type="text"
value={this.state.pdfAuthorTitle}
placeholder={this.state.labels.thisClass.pdfAuthorTitle}
onChange={this.handlePdfAuthorTitleChange}
/>
</Col>
</Row>
<Row className="App show-grid App-PDF-Author-Row">
<Col xs={3} md={3}>
<ControlLabel>{this.state.labels.thisClass.pdfAuthorAffiliation}:</ControlLabel>
</Col>
<Col xs={9} md={9}>
<FormControl
id={"fxPdfAuthorAffiliation"}
className={"App App-PDF-Author"}
type="text"
value={this.state.pdfAuthorAffiliation}
placeholder={this.state.labels.thisClass.pdfAuthorAffiliation}
onChange={this.handlePdfAuthorAffiliationChange}
/>
</Col>
</Row>
<Row className="App show-grid App-PDF-BibStyle-Row">
<Col xs={3} md={3}>
<ControlLabel>{this.state.labels.thisClass.citeStyle}:</ControlLabel>
</Col>
<Col xs={5} md={5}>
<div className="App-PDF-BibStyle-Dropdown">
<ResourceSelector
title={""}
initialValue={this.state.citeStyle}
resources={this.state.citeData}
changeHandler={this.handleciteStyleChange}
multiSelect={false}
/>
</div>
</Col>
<Col xs={4} md={4}>
<a className="App-See-Biblatex" href={this.state.biblatex} target={"_blank"}>{this.state.labels.thisClass.seeBiblatex}</a>
</Col>
</Row>
</div>
);
};
getTabs = () => {
return (
<div className="row">
<Well>
<Tabs id="App-Text-Node-Editor-Tabs" animation={false}>
<Tab eventKey={"textnotes"} title={
this.state.labels.thisClass.textualNotesPanelTitle}>
<Well>
<TextNotesLister
session={this.props.session}
topicId={this.state.currentId}
topicText={this.props.value}
/>
</Well>
</Tab>
<Tab eventKey={"grammar"} title={
this.state.labels.thisClass.grammarPanelTitle}>
<Grammar
session={this.props.session}
idTopic={this.props.idTopic}
idKey={this.props.idKey}
/>
</Tab>
<Tab eventKey={"usernote"} title={
this.state.labels.thisClass.userNotesPanelTitle}>
<Well>
<NotesLister
session={this.props.session}
type={"NoteUser"}
topicId={this.state.currentId}
topicText={this.props.value}
/>
</Well>
</Tab>
<Tab eventKey={"download"} title={
this.state.labels.thisClass.downloadPanelTitle}>
<Well>
<Well>
{this.getTitleRow()}
<Row>
<Col className="App-Info-Row" xs={12} md={12}>
<Checkbox
checked={this.state.combineNotes}
onChange={this.handleCombineNotesChange}
inline={true}
>
{this.state.labels.thisClass.combineNotes}
</Checkbox>
</Col>
</Row>
<Row>
<Col className="App-Info-Row" xs={12} md={12}>
<Checkbox
checked={this.state.createToc}
onChange={this.handleCreateTocChange}
inline={true}
>
{this.state.labels.thisClass.createToc}
</Checkbox>
</Col>
</Row>
<Row className="App-Info-Row">
<Col className="" xs={12} md={12}>
<Checkbox
checked={this.state.includeGrammar}
onChange={this.handleIncludeGrammarChange}
inline={true}
>
{this.state.labels.thisClass.includeGrammar}
</Checkbox>
</Col>
</Row>
<Row className="App-Info-Row">
<Col className="" xs={12} md={12}>
<Checkbox
checked={this.state.includePersonalNotes}
onChange={this.handleIncludePersonalNotesChange}
inline={true}
>
{this.state.labels.thisClass.includePersonalNotes}
</Checkbox>
</Col>
</Row>
<Row>
<Col className="App-Info-Row" xs={12} md={12}>
<Checkbox
checked={this.state.includeAdviceNotes}
onChange={this.handleIncludeAdviceNotesChange}
inline={true}
>
{this.state.labels.thisClass.includeAdviceNotes}
</Checkbox>
</Col>
</Row>
</Well>
<Row className="App-Info-Row">
<Button
type="submit"
bsStyle="primary"
onClick={this.handleDownloadRequest}
>
{this.state.labels.buttons.createFiles}
</Button>
</Row>
{this.getDownloadLinks()}
</Well>
</Tab>
{this.getWorkflowPanel()}
</Tabs>
</Well>
</div>
);
};
handleEditorChange = (event) => {
this.setState({
editorValue: event.target.value
}, this.submitDisabled);
if (this.props.onChange) {
this.props.onChange(event.target.value);
}
};
notifyParentValueChanged = () => {
if (this.props.onSubmit
&& this.state.message === this.state.labels.messages.updated) {
this.props.onSubmit(
this.state.editorValue
);
}
};
handleValueUpdateCallback = (restCallResult) => {
if (restCallResult) {
let message = restCallResult.message;
if (message === "OK") {
message = this.state.labels.messages.updated;
}
this.setState({
message: message
, messageIcon: restCallResult.messageIcon
},this.notifyParentValueChanged);
}
};
handleSubmit = (event) => {
this.setState({
message: this.state.labels.messages.updating
, messageIcon: this.messageIcons.info
});
let parms =
"i=" + encodeURIComponent(
this.props.idLibrary
+ "~"
+ this.props.idTopic
+ "~" + this.props.idKey
)
+ "&t=" + encodeURIComponent("Liturgical")
;
Server.putValue(
this.props.session.restServer
, this.props.session.userInfo.username
, this.props.session.userInfo.password
, {
value: this.state.editorValue
, seq: undefined
, status: this.state.workflow.status
, visibility: this.state.workflow.visibility
}
, parms
, this.handleValueUpdateCallback
);
};
getParaRows = () => {
if (this.state.showSearchResults) {
return (
<div className="row">
<ControlLabel>
{this.state.labels.thisClass.showingMatchesFor + " " + this.props.idTopic + "~" + this.props.idKey}
</ControlLabel>
<Well>
<BootstrapTable
data={this.state.data.values}
trClassName={"App-data-tr"}
striped
hover
pagination
options={ this.state.options }
>
<TableHeaderColumn
isKey
dataField='id'
dataSort={ true }
hidden
>ID</TableHeaderColumn>
<TableHeaderColumn
dataField='library'
dataSort={ true }
width={this.state.idColumnSize}>Domain</TableHeaderColumn>
<TableHeaderColumn
dataField='value'
dataSort={ true }
>Value</TableHeaderColumn>
</BootstrapTable>
</Well>
</div>
)
} else {
return (
<Spinner message={this.state.labels.messages.retrieving}/>
)
}
};
render() {
return (
<div className="App App-Text-Note-Editor">
{(! this.state.showSearchResults) ? <Spinner message={this.state.labels.messages.retrieving}/>
:
<div className="App-ParaRow-Text-Editor">
<Grid>
{this.getParaRows()}
{this.getTextArea()}
{this.getTabs()}
</Grid>
</div>
}
</div>
);
}
}
ParaRowTextEditor.propTypes = {
session: PropTypes.object.isRequired
, docType: PropTypes.string.isRequired
, idLibrary: PropTypes.string.isRequired
, idTopic: PropTypes.string.isRequired
, idKey: PropTypes.string.isRequired
, value: PropTypes.string.isRequired
, canChange: PropTypes.bool.isRequired
, canReview: PropTypes.bool
, onSubmit: PropTypes.func
, onChange: PropTypes.func
};
export default ParaRowTextEditor;
|
stories/killop.js
|
ramonfm/killop
|
import React from 'react';
import { storiesOf } from '@kadira/storybook';
import KillopComponent from '../src/components/killop';
import ConnectedKillopComponent from '../src/components/';
storiesOf('KillopComponent', module)
.add('connected to store', () => <ConnectedKillopComponent />)
.add('enabled', () => <KillopComponent status="enabled" />)
.add('disabled', () => <KillopComponent status="disabled" />);
|
Example/index.android.js
|
cuonghuynhvan/react-native-camera-android-simple
|
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
View,
Button
} from 'react-native';
import Camera from 'react-native-camera-android-simple';
const Type = {
FRONT: 'front',
BACK: 'back'
};
const styles = StyleSheet.create({
container: {
flex: 1
},
preview: {
flex: 1
},
captureContainer: {
position: 'absolute',
flexDirection: 'row',
left: 0,
right: 0,
bottom: 40,
alignItems: 'center',
zIndex: 1
},
captureChildContainer: {
flex: 1,
alignItems: 'flex-start'
},
captureButton: {
borderRadius: 64,
borderWidth: 0,
width: 53,
height: 53,
backgroundColor: '#ffffff',
paddingLeft: 0,
paddingRight: 0
},
reverseCameraButton: {
borderWidth: 0,
marginLeft: 34,
width: 53,
height: 53,
paddingLeft: 0,
paddingRight: 0
},
circleBorder: {
width: 59,
height: 59,
justifyContent: 'center',
alignItems: 'center',
borderWidth: 1,
borderRadius: 64,
borderColor: '#ffffff',
backgroundColor: 'transparent'
}
});
export default class Example extends Component {
constructor(props) {
super(props);
this._onCapturePress = this._onCapturePress.bind(this);
this._onReversePress = this._onReversePress.bind(this);
this.state = {
type: Type.BACK
};
}
_onReversePress() {
const { type } = this.state;
this.setState({
type: type === Type.BACK ? Type.FRONT : Type.BACK
});
}
_onCapturePress() {
const options = {};
this.camera.capture({ metadata: options })
.then((data) => {
// Handle you callback data here.
})
.catch((err) => {
// Handle error here
});
}
_renderCameraButtons() {
return (
<View
style={styles.captureContainer}
accessibilityLabel="Camera_Container"
>
<View style={styles.captureChildContainer} />
<View style={styles.circleBorder}>
<Button
onPress={this._onCapturePress}
style={styles.captureButton}
title="[capture]"
color="#841584"
accessibilityLabel="Learn more about this purple button"
/>
</View>
<View style={styles.captureChildContainer}>
<Button
style={styles.reverseCameraButton}
onPress={this._onReversePress}
title="[Change]"
color="#999999"
accessibilityLabel="Learn more about this purple button"
/>
</View>
</View>
);
}
render() {
const { type } = this.state;
return (
<View
style={styles.preview}
>
<Camera
ref={(instance) => {
this.camera = instance;
}}
style={styles.preview}
type={type}
/>
{this._renderCameraButtons()}
</View>
);
}
}
AppRegistry.registerComponent('Example', () => Example);
|
src/ProjectInput.js
|
Miloucodaisseur/task_manager
|
import React from 'react';
import jQuery from 'jquery';
class ProjectInput extends React.Component {
constructor() {
super();
}
onSubmitForm(event) {
event.preventDefault();
let component = this;
let title = this.refs.newProjectTitle.value;
let description = this.refs.newProjectDescription.value;
let newProject = {
id: null,
title: title,
description: description
};
jQuery.ajax({
type: "POST",
url: "https://projectapitask.herokuapp.com/projects.json",
data: JSON.stringify({
project: newProject
}),
contentType: "application/json",
dataType: "json"
})
.done(function(data) {
component.props.onChange();
component.refs.newProjectTitle.value = "";
component.refs.newProjectDescription.value = "";
})
.fail(function(error) {
console.log(error);
});
}
render() {
var style = {
width: '31%',
backgroundColor: '#fff',
margin: '5px',
display: 'inline-block',
verticalAlign: 'top',
padding: '20px'
}
var input = {
height: '35px',
width: '100%',
padding: '0',
borderStyle: 'none',
border: 'none',
outline: '0',
fontSize: '24px',
fontFamily: 'helvetica-light',
color: '#D11F57',
backgroundImage: 'url(http://www.tjinauyeung.nl/plus-icon.png)',
backgroundSize: 'contain',
backgroundRepeat: 'no-repeat',
backgroundPosition: 'right'
}
var textarea = {
marginTop: '20px',
width: '100%',
height: '130px',
borderStyle: 'none',
border: 'none',
outline: '0',
fontSize: '16px'
}
var add = {
width: '140px',
height: '30px',
fontFamily: 'helvetica-light',
fontSize: '12px',
textTransform: 'uppercase',
color: 'white',
padding: '5px',
border: 'none',
backgroundColor: '#00ADB0',
borderRadius: '3px',
letterSpacing: '1px',
outline: '0'
}
var user = {
width: '50px',
height: '50px',
marginRight: '20px',
marginBottom: '20px',
borderRadius: '50%',
display: 'inline-block'
}
var adduser = {
fontWeight: '100',
color: 'lightgrey',
marginTop: '20px'
}
return (
<div style={style}>
<form onSubmit={this.onSubmitForm.bind(this)}>
<input style={input} ref="newProjectTitle" placeholder="Add a new project"/>
<textarea style={textarea} rows="5" placeholder="Add your project description here. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Perspiciatis doloremque ad harum numquam dicta voluptatibus voluptates quidem quisquam, nam voluptatum deserunt possimus? Expedita quasi sequi error incidunt molestiae pariatur quod?" ref="newProjectDescription"/>
<h2 style={adduser}>Members:</h2>
<img style={user} src="https://qph.is.quoracdn.net/main-qimg-498de3782ec00063441d03e10b7548c4?convert_to_webp=true" />
<img style={user} src="https://qph.is.quoracdn.net/main-qimg-498de3782ec00063441d03e10b7548c4?convert_to_webp=true" />
<img style={user} src="http://www.tjinauyeung.nl/adduser.jpg" />
<button style={add} type="submit">Add</button>
</form>
</div>
);
}
}
export default ProjectInput;
|
tests/lib/rules/vars-on-top.js
|
vitorbal/eslint
|
/**
* @fileoverview Tests for vars-on-top rule.
* @author Danny Fritz
* @author Gyandeep Singh
*/
"use strict";
//------------------------------------------------------------------------------
// Requirements
//------------------------------------------------------------------------------
const rule = require("../../../lib/rules/vars-on-top"),
EslintTester = require("../../../lib/testers/rule-tester");
//------------------------------------------------------------------------------
// Tests
//------------------------------------------------------------------------------
const ruleTester = new EslintTester();
ruleTester.run("vars-on-top", rule, {
valid: [
[
"var first = 0;",
"function foo() {",
" first = 2;",
"}"
].join("\n"),
[
"function foo() {",
"}"
].join("\n"),
[
"function foo() {",
" var first;",
" if (true) {",
" first = true;",
" } else {",
" first = 1;",
" }",
"}"
].join("\n"),
[
"function foo() {",
" var first;",
" var second = 1;",
" var third;",
" var fourth = 1, fifth, sixth = third;",
" var seventh;",
" if (true) {",
" third = true;",
" }",
" first = second;",
"}"
].join("\n"),
[
"function foo() {",
" var i;",
" for (i = 0; i < 10; i++) {",
" alert(i);",
" }",
"}"
].join("\n"),
[
"function foo() {",
" var outer;",
" function inner() {",
" var inner = 1;",
" var outer = inner;",
" }",
" outer = 1;",
"}"
].join("\n"),
[
"function foo() {",
" var first;",
" //Hello",
" var second = 1;",
" first = second;",
"}"
].join("\n"),
[
"function foo() {",
" var first;",
" /*",
" Hello Clarice",
" */",
" var second = 1;",
" first = second;",
"}"
].join("\n"),
[
"function foo() {",
" var first;",
" var second = 1;",
" function bar(){",
" var first;",
" first = 5;",
" }",
" first = second;",
"}"
].join("\n"),
[
"function foo() {",
" var first;",
" var second = 1;",
" function bar(){",
" var third;",
" third = 5;",
" }",
" first = second;",
"}"
].join("\n"),
[
"function foo() {",
" var first;",
" var bar = function(){",
" var third;",
" third = 5;",
" }",
" first = 5;",
"}"
].join("\n"),
[
"function foo() {",
" var first;",
" first.onclick(function(){",
" var third;",
" third = 5;",
" });",
" first = 5;",
"}"
].join("\n"),
{
code: [
"function foo() {",
" var i = 0;",
" for (let j = 0; j < 10; j++) {",
" alert(j);",
" }",
" i = i + 1;",
"}"
].join("\n"),
parserOptions: {
ecmaVersion: 6
}
},
"'use strict'; var x; f();",
"'use strict'; 'directive'; var x; var y; f();",
"function f() { 'use strict'; var x; f(); }",
"function f() { 'use strict'; 'directive'; var x; var y; f(); }",
{code: "import React from 'react'; var y; function f() { 'use strict'; var x; var y; f(); }", parserOptions: { sourceType: "module" }},
{code: "'use strict'; import React from 'react'; var y; function f() { 'use strict'; var x; var y; f(); }", parserOptions: { sourceType: "module" }},
{code: "import React from 'react'; 'use strict'; var y; function f() { 'use strict'; var x; var y; f(); }", parserOptions: { sourceType: "module" }},
{code: "import * as foo from 'mod.js'; 'use strict'; var y; function f() { 'use strict'; var x; var y; f(); }", parserOptions: { sourceType: "module" }},
{code: "import { square, diag } from 'lib'; 'use strict'; var y; function f() { 'use strict'; var x; var y; f(); }", parserOptions: { sourceType: "module" }},
{code: "import { default as foo } from 'lib'; 'use strict'; var y; function f() { 'use strict'; var x; var y; f(); }", parserOptions: { sourceType: "module" }},
{code: "import 'src/mylib'; 'use strict'; var y; function f() { 'use strict'; var x; var y; f(); }", parserOptions: { sourceType: "module" }},
{code: "import theDefault, { named1, named2 } from 'src/mylib'; 'use strict'; var y; function f() { 'use strict'; var x; var y; f(); }", parserOptions: { sourceType: "module" }},
{
code: [
"export var x;",
"var y;",
"var z;"
].join("\n"),
parserOptions: {
ecmaVersion: 6,
sourceType: "module"
}
},
{
code: [
"var x;",
"export var y;",
"var z;"
].join("\n"),
parserOptions: {
ecmaVersion: 6,
sourceType: "module"
}
},
{
code: [
"var x;",
"var y;",
"export var z;"
].join("\n"),
parserOptions: {
ecmaVersion: 6,
sourceType: "module"
}
}
],
invalid: [
{
code: [
"var first = 0;",
"function foo() {",
" first = 2;",
" second = 2;",
"}",
"var second = 0;"
].join("\n"),
errors: [
{
message: "All 'var' declarations must be at the top of the function scope.",
type: "VariableDeclaration"
}
]
},
{
code: [
"function foo() {",
" var first;",
" first = 1;",
" first = 2;",
" first = 3;",
" first = 4;",
" var second = 1;",
" second = 2;",
" first = second;",
"}"
].join("\n"),
errors: [
{
message: "All 'var' declarations must be at the top of the function scope.",
type: "VariableDeclaration"
}
]
},
{
code: [
"function foo() {",
" var first;",
" if (true) {",
" var second = true;",
" }",
" first = second;",
"}"
].join("\n"),
errors: [
{
message: "All 'var' declarations must be at the top of the function scope.",
type: "VariableDeclaration"
}
]
},
{
code: [
"function foo() {",
" for (var i = 0; i < 10; i++) {",
" alert(i);",
" }",
"}"
].join("\n"),
errors: [
{
message: "All 'var' declarations must be at the top of the function scope.",
type: "VariableDeclaration"
}
]
},
{
code: [
"function foo() {",
" var first = 10;",
" var i;",
" for (i = 0; i < first; i ++) {",
" var second = i;",
" }",
"}"
].join("\n"),
errors: [
{
message: "All 'var' declarations must be at the top of the function scope.",
type: "VariableDeclaration"
}
]
},
{
code: [
"function foo() {",
" var first = 10;",
" var i;",
" switch (first) {",
" case 10:",
" var hello = 1;",
" break;",
" }",
"}"
].join("\n"),
errors: [
{
message: "All 'var' declarations must be at the top of the function scope.",
type: "VariableDeclaration"
}
]
},
{
code: [
"function foo() {",
" var first = 10;",
" var i;",
" try {",
" var hello = 1;",
" } catch (e) {",
" alert('error');",
" }",
"}"
].join("\n"),
errors: [
{
message: "All 'var' declarations must be at the top of the function scope.",
type: "VariableDeclaration"
}
]
},
{
code: [
"function foo() {",
" var first = 10;",
" var i;",
" try {",
" asdf;",
" } catch (e) {",
" var hello = 1;",
" }",
"}"
].join("\n"),
errors: [
{
message: "All 'var' declarations must be at the top of the function scope.",
type: "VariableDeclaration"
}
]
},
{
code: [
"function foo() {",
" var first = 10;",
" while (first) {",
" var hello = 1;",
" }",
"}"
].join("\n"),
errors: [
{
message: "All 'var' declarations must be at the top of the function scope.",
type: "VariableDeclaration"
}
]
},
{
code: [
"function foo() {",
" var first = 10;",
" do {",
" var hello = 1;",
" } while (first == 10);",
"}"
].join("\n"),
errors: [
{
message: "All 'var' declarations must be at the top of the function scope.",
type: "VariableDeclaration"
}
]
},
{
code: [
"function foo() {",
" var first = [1,2,3];",
" for (var item in first) {",
" item++;",
" }",
"}"
].join("\n"),
errors: [
{
message: "All 'var' declarations must be at the top of the function scope.",
type: "VariableDeclaration"
}
]
},
{
code: [
"function foo() {",
" var first = [1,2,3];",
" var item;",
" for (item in first) {",
" var hello = item;",
" }",
"}"
].join("\n"),
errors: [
{
message: "All 'var' declarations must be at the top of the function scope.",
type: "VariableDeclaration"
}
]
},
{
code: [
"var foo = () => {",
" var first = [1,2,3];",
" var item;",
" for (item in first) {",
" var hello = item;",
" }",
"}"
].join("\n"),
parserOptions: { ecmaVersion: 6 },
errors: [
{
message: "All 'var' declarations must be at the top of the function scope.",
type: "VariableDeclaration"
}
]
},
{
code: "'use strict'; 0; var x; f();",
errors: [{message: "All 'var' declarations must be at the top of the function scope.", type: "VariableDeclaration"}]
},
{
code: "'use strict'; var x; 'directive'; var y; f();",
errors: [{message: "All 'var' declarations must be at the top of the function scope.", type: "VariableDeclaration"}]
},
{
code: "function f() { 'use strict'; 0; var x; f(); }",
errors: [{message: "All 'var' declarations must be at the top of the function scope.", type: "VariableDeclaration"}]
},
{
code: "function f() { 'use strict'; var x; 'directive'; var y; f(); }",
errors: [{message: "All 'var' declarations must be at the top of the function scope.", type: "VariableDeclaration"}]
},
{
code: [
"export function f() {}",
"var x;"
].join("\n"),
parserOptions: {
ecmaVersion: 6,
sourceType: "module"
},
errors: [{message: "All 'var' declarations must be at the top of the function scope.", type: "VariableDeclaration"}]
},
{
code: [
"var x;",
"export function f() {}",
"var y;"
].join("\n"),
parserOptions: {
ecmaVersion: 6,
sourceType: "module"
},
errors: [{message: "All 'var' declarations must be at the top of the function scope.", type: "VariableDeclaration"}]
},
{
code: [
"import {foo} from 'foo';",
"export {foo};",
"var test = 1;"
].join("\n"),
parserOptions: {
ecmaVersion: 6,
sourceType: "module"
},
errors: [{message: "All 'var' declarations must be at the top of the function scope.", type: "VariableDeclaration"}]
},
{
code: [
"export {foo} from 'foo';",
"var test = 1;"
].join("\n"),
parserOptions: {
ecmaVersion: 6,
sourceType: "module"
},
errors: [{message: "All 'var' declarations must be at the top of the function scope.", type: "VariableDeclaration"}]
},
{
code: [
"export * from 'foo';",
"var test = 1;"
].join("\n"),
parserOptions: {
ecmaVersion: 6,
sourceType: "module"
},
errors: [{message: "All 'var' declarations must be at the top of the function scope.", type: "VariableDeclaration"}]
}
]
});
|
test/client/scripts/components/admin/detail-view/viewable-by-reporter-button-test.js
|
kuali/research-coi
|
/*
The Conflict of Interest (COI) module of Kuali Research
Copyright © 2005-2016 Kuali, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
*/
import React from 'react';
import { shallow } from 'enzyme';
import { ROLES } from '../../../../../../coi-constants';
import ViewableByReporterButton from '../../../../../../client/scripts/components/admin/detail-view/comment-bubble/viewable-by-reporter-button';
import assert from 'assert';
describe('ViewableByReporterButton', () => {
const createComponentWrapper = (role, visible, readonly) => {
return shallow(
<ViewableByReporterButton
id={3}
role={role}
piVisible={visible}
disclosureReadonly={readonly}
/>
);
};
let wrapper;
context('as an admin', () => {
context('and the disclosure is not readonly', () => {
const readonly = false;
context('and the comment is not visible by the reporter', () => {
const visible = false;
before(() => {
wrapper = createComponentWrapper(ROLES.ADMIN, visible, readonly);
});
it('should display the button', () => {
assert.equal(wrapper.find('button').length, 1);
});
it('should display the show button text', () => {
assert.equal(wrapper.find('button').text(), 'Show to Reporter');
});
});
context('and the comment is visisble by the reporter', () => {
const visible = true;
before(() => {
wrapper = createComponentWrapper(ROLES.ADMIN, visible, readonly);
});
it('should display the button', () => {
assert.equal(wrapper.find('button').length, 1);
});
it('should display the hide button text', () => {
assert.equal(wrapper.find('button').text(), 'Hide from Reporter');
});
});
});
context('and the disclosure is readonly', () => {
before(() => {
wrapper = createComponentWrapper(ROLES.ADMIN, false, true);
});
it('should not display the button', () => {
assert.equal(wrapper.find('button').length, 0);
});
});
});
context('as a reviewer', () => {
beforeEach(() => {
wrapper = createComponentWrapper(ROLES.REVIEWER, true, false);
});
it('should not display the button', () => {
assert.equal(wrapper.find('button').length, 0);
});
});
});
|
packages/bonde-styleguide/src/cards/Tooltip/Tooltip.js
|
ourcities/rebu-client
|
import React from 'react'
import PropTypes from 'prop-types'
import styled from 'styled-components'
import Icon from '../../content/Icon/Icon'
import Button from '../../content/Button/Button'
import Backdrop from '../../layout/Backdrop/Backdrop'
import { borderSpacing, borderSpacingPropTypes } from '../../utils'
const CloseButton = styled(({ className, onClose }) => (
<div className={className}>
<Button flat onClick={onClose}>
<Icon name='times' size={12} color='#FFFFFF' />
</Button>
</div>
))`
position: absolute;
top: 12px;
right: 12px;
& > ${Button} {
padding: 0;
min-width: 38px;
}
`
const CardTooltip = styled(({ className, onClose, Content }) => (
<div className={className}>
{onClose && <CloseButton onClose={onClose} />}
<Content />
</div>
))`
color: #FFFFFF;
border-radius: 1px;
background-color: #424242;
box-shadow: 2px 1px 14px 11px rgba(0, 0, 0, 0.04);
padding: 30px;
position: absolute;
z-index: 10;
${props => props.margin && borderSpacing('margin', props.margin)}
${props => props.minWidth && `
min-width: ${props.minWidth}px;
`}
${props => props.width && `
width: ${props.width}px;
`}
${props => props.minHeight && `
min-height: ${props.minHeight}px;
`}
${props => props.small && `
padding: 15px;
`}
&:before {
content: '';
position: absolute;
border: 8px solid transparent;
${props => props.placement.startsWith('left') && `
right: -16px;
border-left-color: #424242;
`}
${props => props.placement.startsWith('right') && `
left: -16px;
border-right-color: #424242;
`}
${props => props.placement.startsWith('top') && `
bottom: -16px;
border-top-color: #424242;
`}
${props => props.placement.startsWith('bottom') && `
top: -16px;
border-bottom-color: #424242;
`}
${props => props.placement.endsWith('top') && `
top: 8%;
`}
${props => props.placement.endsWith('bottom') && `
bottom: 8%;
`}
${props => props.placement.endsWith('left') && `
left: 8%;
`}
${props => props.placement.endsWith('right') && `
right: 8%;
`}
/**
* TODO: Needs to fix middle positions.
*/
${props => ['top-middle', 'bottom-middle'].includes(props.placement) && `
left: calc(50% - 8px);
`}
${props => ['right-middle', 'left-middle'].includes(props.placement) && `
top: calc(50% - 8px);
`}
}
${props => props.placement.startsWith('top') && `
margin-bottom: 8px;
bottom: 103%;
`}
${props => props.placement.startsWith('bottom') && `
margin-top: 8px;
top: 103%;
`}
${props => props.placement.startsWith('left') && `
margin-right: 8px;
right: 103%;
`}
${props => props.placement.startsWith('right') && `
margin-left: 8px;
left: 103%;
`}
${props => props.placement.endsWith('top') && `
top: 0;
`}
${props => props.placement.endsWith('bottom') && `
bottom: 0;
`}
${props => props.placement.endsWith('left') && `
left: 0;
`}
${props => props.placement.endsWith('right') && `
right: 0;
`}
/**
* TODO: Needs to fix middle positions.
*/
${props => ['top-middle', 'bottom-middle'].includes(props.placement) && `
left: calc(50% - 41px);
`}
${props => ['right-middle', 'left-middle'].includes(props.placement) && `
top: calc(50% - 41px);
`}
${props => props.position && props.position.top && `top: ${props.position.top};`}
${props => props.position && props.position.bottom && `bottom: ${props.position.bottom};`}
${props => props.position && props.position.left && `left: ${props.position.left};`}
${props => props.position && props.position.right && `right: ${props.position.right};`}
`
const Tooltip = styled(({ className, children, nolock, backdropClose, show, ...props }) => (
<div className={className}>
{show && !nolock && <Backdrop onClick={backdropClose ? props.onClose : undefined} />}
{show && <CardTooltip {...props} />}
{children}
</div>
))`
display: inline-block;
position: relative;
width: 100%;
`
const { oneOfType, oneOf, node, func, bool, shape, number, string } = PropTypes
Tooltip.propTypes = {
/** The component that will be wrapped with the tooltip. */
children: oneOfType([node, func]).isRequired,
/** The minimum width of tooltip. */
minWidth: number,
/** The minimum height of tooltip. */
minHeight: number,
/** The content that will we rendered inside of the tooltip. */
Content: oneOfType([node, func]).isRequired,
/** If pass this prop, the backdrop will not be rendered. */
nolock: bool,
/** Enable this to show the tooltip. */
show: bool,
/** The function that will be executed to close the tooltip. */
onClose: func,
/** Enable this to execute the `onClose` function when Backdrop was clicked. */
backdropClose: bool,
/** The position that the tooltip will be placed around the target. */
placement: oneOf([
'top-left',
'top-middle',
'top-right',
'right-top',
'right-middle',
'right-bottom',
'bottom-left',
'bottom-middle',
'bottom-right',
'left-top',
'left-middle',
'left-bottom',
]),
/** Manually set the position of tooltip relative to the target. */
position: shape({
top: string,
bottom: string,
left: string,
right: string,
}),
margin: borderSpacingPropTypes
}
Tooltip.defaultProps = {
nolock: false,
backdropClose: false,
show: true,
placement: 'right-top',
position: {},
}
Tooltip.displayName = 'Tooltip'
/* @component */
export default Tooltip
|
routes/GetStarted/GetStarted.js
|
RickFrom1987/rickfrom1987.com
|
/**
* React App SDK (https://github.com/kriasoft/react-app)
*
* Copyright © 2015-present Kriasoft, LLC. All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE.txt file in the root directory of this source tree.
*/
import React from 'react';
import Layout from '../../components/Layout';
import s from './GetStarted.css';
import { title, html } from './GetStarted.md';
class AboutPage extends React.Component {
componentDidMount() {
document.title = title;
}
render() {
return (
<Layout className={s.content}>
<h1>{title}</h1>
<div dangerouslySetInnerHTML={{ __html: html }} />
</Layout>
);
}
}
export default AboutPage;
|
actor-apps/app-web/src/app/components/activity/GroupProfile.react.js
|
alessandrostone/actor-platform
|
import React from 'react';
import DialogActionCreators from 'actions/DialogActionCreators';
import LoginStore from 'stores/LoginStore';
import PeerStore from 'stores/PeerStore';
import DialogStore from 'stores/DialogStore';
import InviteUserActions from 'actions/InviteUserActions';
import AvatarItem from 'components/common/AvatarItem.react';
import InviteUser from 'components/modals/InviteUser.react';
import GroupProfileMembers from 'components/activity/GroupProfileMembers.react';
const getStateFromStores = (groupId) => {
const thisPeer = PeerStore.getGroupPeer(groupId);
return {
thisPeer: thisPeer,
isNotificationsEnabled: DialogStore.isNotificationsEnabled(thisPeer)
};
};
class GroupProfile extends React.Component {
static propTypes = {
group: React.PropTypes.object.isRequired
};
componentWillMount() {
DialogStore.addNotificationsListener(this.whenNotificationChanged);
}
componentWillUnmount() {
DialogStore.removeNotificationsListener(this.whenNotificationChanged);
}
componentWillReceiveProps(newProps) {
this.setState(getStateFromStores(newProps.group.id));
}
constructor(props) {
super(props);
this.onNotificationChange = this.onNotificationChange.bind(this);
this.state = getStateFromStores(this.props.group.id);
}
onAddMemberClick(group) {
InviteUserActions.modalOpen(group);
}
onLeaveGroupClick(groupId) {
DialogActionCreators.leaveGroup(groupId);
}
onNotificationChange(event) {
DialogActionCreators.changeNotificationsEnabled(this.state.thisPeer, event.target.checked);
}
whenNotificationChanged = () => {
this.setState(getStateFromStores(this.props.group.id));
};
render() {
const group = this.props.group;
const myId = LoginStore.getMyId();
const isNotificationsEnabled = this.state.isNotificationsEnabled;
let memberArea;
let adminControls;
if (group.adminId === myId) {
adminControls = (
<li className="profile__list__item">
<a className="red">Delete group</a>
</li>
);
}
if (DialogStore.isGroupMember(group)) {
memberArea = (
<div>
<div className="notifications">
<label htmlFor="notifications">Enable Notifications</label>
<div className="switch pull-right">
<input checked={isNotificationsEnabled} id="notifications" onChange={this.onNotificationChange.bind(this)} type="checkbox"/>
<label htmlFor="notifications"></label>
</div>
</div>
<GroupProfileMembers groupId={group.id} members={group.members}/>
<ul className="profile__list profile__list--controls">
<li className="profile__list__item">
<a className="link__blue" onClick={this.onAddMemberClick.bind(this, group)}>Add member</a>
</li>
<li className="profile__list__item">
<a className="link__red" onClick={this.onLeaveGroupClick.bind(this, group.id)}>Leave group</a>
</li>
{adminControls}
</ul>
{/*
<footer className="profile__controls">
<a className="button button--wide" onClick={this.onAddMemberClick.bind(this, group)}>Add member</a>
<a className="button button--wide" onClick={this.onLeaveGroupClick.bind(this, group.id)}>Leave group</a>
</footer>
*/}
<InviteUser/>
</div>
);
}
return (
<div className="activity__body profile">
<div className="profile__name">
<AvatarItem image={group.bigAvatar}
placeholder={group.placeholder}
size="medium"
title={group.name}/>
<h3>{group.name}</h3>
</div>
{memberArea}
</div>
);
}
}
export default GroupProfile;
|
src/ui/layout/Auth.js
|
dhruv-kumar-jha/productivity-frontend
|
'use strict';
import React from 'react';
import AuthHeader from 'app/components/common/AuthHeader';
import { I18n } from './I18n';
const Default = (props) => {
return (
<I18n fetch={ false }>
<div className="has-fh">
<AuthHeader />
<main className="body-wrapper">
{ props.children }
</main>
</div>
</I18n>
)
}
export default Default;
|
assets/components/views/Trades/__tests__/View-test.js
|
TimeTechFinancial/TimeTechFinancial
|
import 'react-native';
import React from 'react';
import TradesView from '../View';
// Note: test renderer must be required after react-native.
import renderer from 'react-test-renderer';
test('renders correctly', () => {
const tree = renderer.create(
<TradesView/>
).toJSON();
expect(tree).toMatchSnapshot();
});
|
test/specs/elements/Label/LabelDetail-test.js
|
koenvg/Semantic-UI-React
|
import faker from 'faker'
import React from 'react'
import * as common from 'test/specs/commonTests'
import LabelDetail from 'src/elements/Label/LabelDetail'
describe('LabelDetail', () => {
common.isConformant(LabelDetail)
common.rendersChildren(LabelDetail)
describe('content prop', () => {
it('renders children', () => {
const text = faker.hacker.phrase()
shallow(<LabelDetail content={text} />)
.should.contain.text(text)
})
})
})
|
src/components/Header/Header.js
|
larsvinter/react-starter-kit
|
/*! React Starter Kit | MIT License | http://www.reactstarterkit.com/ */
import React, { Component } from 'react';
import styles from './Header.css';
import withStyles from '../../decorators/withStyles';
import Link from '../Link';
import Navigation from '../Navigation';
@withStyles(styles)
class Header extends Component {
render() {
return (
<div className="Header">
<div className="Header-container">
<a className="Header-brand" href="/" onClick={Link.handleClick}>
<img className="Header-brandImg" src={require('./logo-small.png')} width="38" height="38" alt="React" />
<span className="Header-brandTxt">Your Company</span>
</a>
<Navigation className="Header-nav" />
<div className="Header-banner">
<h1 className="Header-bannerTitle">React</h1>
<p className="Header-bannerDesc">Complex web apps made easy</p>
</div>
</div>
</div>
);
}
}
export default Header;
|
static/src/components/notAuthenticatedComponent.js
|
kdog1425/React-Redux-Flask-Web-Crawler
|
import React from 'react';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import { browserHistory } from 'react-router';
import * as actionCreators from '../actions/auth';
function mapStateToProps(state) {
return {
token: state.auth.token,
userName: state.auth.userName,
isAuthenticated: state.auth.isAuthenticated,
};
}
function mapDispatchToProps(dispatch) {
return bindActionCreators(actionCreators, dispatch);
}
export function requireNoAuthentication(Component) {
class notAuthenticatedComponent extends React.Component {
constructor(props) {
super(props);
this.state = {
loaded: false,
};
}
componentWillMount() {
this.checkAuth();
}
componentWillReceiveProps(nextProps) {
this.checkAuth(nextProps);
}
checkAuth(props = this.props) {
if (props.isAuthenticated) {
browserHistory.push('/main');
} else {
const token = localStorage.getItem('token');
if (token) {
fetch('api/is_token_valid', {
method: 'post',
credentials: 'include',
headers: {
'Accept': 'application/json', // eslint-disable-line quote-props
'Content-Type': 'application/json',
},
body: JSON.stringify({ token }),
})
.then(res => {
if (res.status === 200) {
this.props.loginUserSuccess(token);
browserHistory.push('/main');
} else {
this.setState({
loaded: true,
});
}
});
} else {
this.setState({
loaded: true,
});
}
}
}
render() {
return (
<div>
{!this.props.isAuthenticated && this.state.loaded
? <Component {...this.props} />
: null
}
</div>
);
}
}
notAuthenticatedComponent.propTypes = {
loginUserSuccess: React.PropTypes.func,
isAuthenticated: React.PropTypes.bool,
};
return connect(mapStateToProps, mapDispatchToProps)(notAuthenticatedComponent);
}
|
src/svg-icons/image/photo-size-select-actual.js
|
tan-jerene/material-ui
|
import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let ImagePhotoSizeSelectActual = (props) => (
<SvgIcon {...props}>
<path d="M21 3H3C2 3 1 4 1 5v14c0 1.1.9 2 2 2h18c1 0 2-1 2-2V5c0-1-1-2-2-2zM5 17l3.5-4.5 2.5 3.01L14.5 11l4.5 6H5z"/>
</SvgIcon>
);
ImagePhotoSizeSelectActual = pure(ImagePhotoSizeSelectActual);
ImagePhotoSizeSelectActual.displayName = 'ImagePhotoSizeSelectActual';
ImagePhotoSizeSelectActual.muiName = 'SvgIcon';
export default ImagePhotoSizeSelectActual;
|
features/apimgt/org.wso2.carbon.apimgt.publisher.feature/src/main/resources/publisher/node_modules/rc-select/es/Select.js
|
bhathiya/test
|
import _defineProperty from 'babel-runtime/helpers/defineProperty';
import _extends from 'babel-runtime/helpers/extends';
import React from 'react';
import ReactDOM from 'react-dom';
import createClass from 'create-react-class';
import KeyCode from 'rc-util/es/KeyCode';
import classnames from 'classnames';
import Animate from 'rc-animate';
import classes from 'component-classes';
import { getPropValue, getValuePropValue, isCombobox, isMultipleOrTags, isMultipleOrTagsOrCombobox, isSingleMode, toArray, findIndexInValueByKey, UNSELECTABLE_ATTRIBUTE, UNSELECTABLE_STYLE, preventDefaultEvent, findFirstMenuItem, includesSeparators, splitBySeparators, findIndexInValueByLabel } from './util';
import SelectTrigger from './SelectTrigger';
import FilterMixin from './FilterMixin';
import { SelectPropTypes } from './PropTypes';
function noop() {}
function saveRef(name, component) {
this[name] = component;
}
function chaining() {
for (var _len = arguments.length, fns = Array(_len), _key = 0; _key < _len; _key++) {
fns[_key] = arguments[_key];
}
return function () {
for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
args[_key2] = arguments[_key2];
}
for (var i = 0; i < fns.length; i++) {
if (fns[i] && typeof fns[i] === 'function') {
fns[i].apply(this, args);
}
}
};
}
var Select = createClass({
propTypes: SelectPropTypes,
mixins: [FilterMixin],
getDefaultProps: function getDefaultProps() {
return {
prefixCls: 'rc-select',
defaultOpen: false,
labelInValue: false,
defaultActiveFirstOption: true,
showSearch: true,
allowClear: false,
placeholder: '',
onChange: noop,
onFocus: noop,
onBlur: noop,
onSelect: noop,
onSearch: noop,
onDeselect: noop,
showArrow: true,
dropdownMatchSelectWidth: true,
dropdownStyle: {},
dropdownMenuStyle: {},
optionFilterProp: 'value',
optionLabelProp: 'value',
notFoundContent: 'Not Found'
};
},
getInitialState: function getInitialState() {
var props = this.props;
var value = [];
if ('value' in props) {
value = toArray(props.value);
} else {
value = toArray(props.defaultValue);
}
value = this.addLabelToValue(props, value);
value = this.addTitleToValue(props, value);
var inputValue = '';
if (props.combobox) {
inputValue = value.length ? this.getLabelFromProps(props, value[0].key) : '';
}
this.saveInputRef = saveRef.bind(this, 'inputInstance');
this.saveInputMirrorRef = saveRef.bind(this, 'inputMirrorInstance');
var open = props.open;
if (open === undefined) {
open = props.defaultOpen;
}
return {
value: value,
inputValue: inputValue,
open: open
};
},
componentWillMount: function componentWillMount() {
this.adjustOpenState();
},
componentWillReceiveProps: function componentWillReceiveProps(nextProps) {
if ('value' in nextProps) {
var value = toArray(nextProps.value);
value = this.addLabelToValue(nextProps, value);
value = this.addTitleToValue(nextProps, value);
this.setState({
value: value
});
if (nextProps.combobox) {
this.setState({
inputValue: value.length ? this.getLabelFromProps(nextProps, value[0].key) : ''
});
}
}
},
componentWillUpdate: function componentWillUpdate(nextProps, nextState) {
this.props = nextProps;
this.state = nextState;
this.adjustOpenState();
},
componentDidUpdate: function componentDidUpdate() {
if (isMultipleOrTags(this.props)) {
var inputNode = this.getInputDOMNode();
var mirrorNode = this.getInputMirrorDOMNode();
if (inputNode.value) {
inputNode.style.width = '';
inputNode.style.width = mirrorNode.clientWidth + 'px';
} else {
inputNode.style.width = '';
}
}
},
componentWillUnmount: function componentWillUnmount() {
this.clearFocusTime();
this.clearBlurTime();
this.clearAdjustTimer();
if (this.dropdownContainer) {
ReactDOM.unmountComponentAtNode(this.dropdownContainer);
document.body.removeChild(this.dropdownContainer);
this.dropdownContainer = null;
}
},
onInputChange: function onInputChange(event) {
var tokenSeparators = this.props.tokenSeparators;
var val = event.target.value;
if (isMultipleOrTags(this.props) && tokenSeparators && includesSeparators(val, tokenSeparators)) {
var nextValue = this.tokenize(val);
this.fireChange(nextValue);
this.setOpenState(false, true);
this.setInputValue('', false);
return;
}
this.setInputValue(val);
this.setState({
open: true
});
if (isCombobox(this.props)) {
this.fireChange([{
key: val
}]);
}
},
onDropdownVisibleChange: function onDropdownVisibleChange(open) {
if (open && !this._focused) {
this.clearBlurTime();
this.timeoutFocus();
this._focused = true;
this.updateFocusClassName();
}
this.setOpenState(open);
},
onKeyDown: function onKeyDown(event) {
var props = this.props;
if (props.disabled) {
return;
}
var keyCode = event.keyCode;
if (this.state.open && !this.getInputDOMNode()) {
this.onInputKeyDown(event);
} else if (keyCode === KeyCode.ENTER || keyCode === KeyCode.DOWN) {
this.setOpenState(true);
event.preventDefault();
}
},
onInputKeyDown: function onInputKeyDown(event) {
var props = this.props;
if (props.disabled) {
return;
}
var state = this.state;
var keyCode = event.keyCode;
if (isMultipleOrTags(props) && !event.target.value && keyCode === KeyCode.BACKSPACE) {
event.preventDefault();
var value = state.value;
if (value.length) {
this.removeSelected(value[value.length - 1].key);
}
return;
}
if (keyCode === KeyCode.DOWN) {
if (!state.open) {
this.openIfHasChildren();
event.preventDefault();
event.stopPropagation();
return;
}
} else if (keyCode === KeyCode.ESC) {
if (state.open) {
this.setOpenState(false);
event.preventDefault();
event.stopPropagation();
}
return;
}
if (state.open) {
var menu = this.refs.trigger.getInnerMenu();
if (menu && menu.onKeyDown(event)) {
event.preventDefault();
event.stopPropagation();
}
}
},
onMenuSelect: function onMenuSelect(_ref) {
var _this = this;
var item = _ref.item;
var value = this.state.value;
var props = this.props;
var selectedValue = getValuePropValue(item);
var selectedLabel = this.getLabelFromOption(item);
var event = selectedValue;
if (props.labelInValue) {
event = {
key: event,
label: selectedLabel
};
}
props.onSelect(event, item);
var selectedTitle = item.props.title;
if (isMultipleOrTags(props)) {
if (findIndexInValueByKey(value, selectedValue) !== -1) {
return;
}
value = value.concat([{
key: selectedValue,
label: selectedLabel,
title: selectedTitle
}]);
} else {
if (isCombobox(props)) {
this.skipAdjustOpen = true;
this.clearAdjustTimer();
this.skipAdjustOpenTimer = setTimeout(function () {
_this.skipAdjustOpen = false;
}, 0);
}
if (value.length && value[0].key === selectedValue) {
this.setOpenState(false, true);
return;
}
value = [{
key: selectedValue,
label: selectedLabel,
title: selectedTitle
}];
this.setOpenState(false, true);
}
this.fireChange(value);
var inputValue = void 0;
if (isCombobox(props)) {
inputValue = getPropValue(item, props.optionLabelProp);
} else {
inputValue = '';
}
this.setInputValue(inputValue, false);
},
onMenuDeselect: function onMenuDeselect(_ref2) {
var item = _ref2.item,
domEvent = _ref2.domEvent;
if (domEvent.type === 'click') {
this.removeSelected(getValuePropValue(item));
}
this.setInputValue('', false);
},
onArrowClick: function onArrowClick(e) {
e.stopPropagation();
if (!this.props.disabled) {
this.setOpenState(!this.state.open, !this.state.open);
}
},
onPlaceholderClick: function onPlaceholderClick() {
if (this.getInputDOMNode()) {
this.getInputDOMNode().focus();
}
},
onOuterFocus: function onOuterFocus(e) {
this.clearBlurTime();
if (!isMultipleOrTagsOrCombobox(this.props) && e.target === this.getInputDOMNode()) {
return;
}
if (this._focused) {
return;
}
this._focused = true;
this.updateFocusClassName();
this.timeoutFocus();
},
onPopupFocus: function onPopupFocus() {
this.maybeFocus(true, true);
},
onOuterBlur: function onOuterBlur() {
var _this2 = this;
this.blurTimer = setTimeout(function () {
_this2._focused = false;
_this2.updateFocusClassName();
var props = _this2.props;
var value = _this2.state.value;
var inputValue = _this2.state.inputValue;
if (isSingleMode(props) && props.showSearch && inputValue && props.defaultActiveFirstOption) {
var options = _this2._options || [];
if (options.length) {
var firstOption = findFirstMenuItem(options);
if (firstOption) {
value = [{
key: firstOption.key,
label: _this2.getLabelFromOption(firstOption)
}];
_this2.fireChange(value);
}
}
} else if (isMultipleOrTags(props) && inputValue) {
_this2.state.inputValue = _this2.getInputDOMNode().value = '';
}
props.onBlur(_this2.getVLForOnChange(value));
}, 10);
},
onClearSelection: function onClearSelection(event) {
var props = this.props;
var state = this.state;
if (props.disabled) {
return;
}
var inputValue = state.inputValue,
value = state.value;
event.stopPropagation();
if (inputValue || value.length) {
if (value.length) {
this.fireChange([]);
}
this.setOpenState(false, true);
if (inputValue) {
this.setInputValue('');
}
}
},
onChoiceAnimationLeave: function onChoiceAnimationLeave() {
this.refs.trigger.refs.trigger.forcePopupAlign();
},
getLabelBySingleValue: function getLabelBySingleValue(children, value) {
var _this3 = this;
if (value === undefined) {
return null;
}
var label = null;
React.Children.forEach(children, function (child) {
if (child.type.isSelectOptGroup) {
var maybe = _this3.getLabelBySingleValue(child.props.children, value);
if (maybe !== null) {
label = maybe;
}
} else if (getValuePropValue(child) === value) {
label = _this3.getLabelFromOption(child);
}
});
return label;
},
getValueByLabel: function getValueByLabel(children, label) {
var _this4 = this;
if (label === undefined) {
return null;
}
var value = null;
React.Children.forEach(children, function (child) {
if (child.type.isSelectOptGroup) {
var maybe = _this4.getValueByLabel(child.props.children, label);
if (maybe !== null) {
value = maybe;
}
} else if (toArray(_this4.getLabelFromOption(child)).join('') === label) {
value = getValuePropValue(child);
}
});
return value;
},
getLabelFromOption: function getLabelFromOption(child) {
return getPropValue(child, this.props.optionLabelProp);
},
getLabelFromProps: function getLabelFromProps(props, value) {
return this.getLabelByValue(props.children, value);
},
getVLForOnChange: function getVLForOnChange(vls_) {
var vls = vls_;
if (vls !== undefined) {
if (!this.props.labelInValue) {
vls = vls.map(function (v) {
return v.key;
});
} else {
vls = vls.map(function (vl) {
return { key: vl.key, label: vl.label };
});
}
return isMultipleOrTags(this.props) ? vls : vls[0];
}
return vls;
},
getLabelByValue: function getLabelByValue(children, value) {
var label = this.getLabelBySingleValue(children, value);
if (label === null) {
return value;
}
return label;
},
getDropdownContainer: function getDropdownContainer() {
if (!this.dropdownContainer) {
this.dropdownContainer = document.createElement('div');
document.body.appendChild(this.dropdownContainer);
}
return this.dropdownContainer;
},
getPlaceholderElement: function getPlaceholderElement() {
var props = this.props,
state = this.state;
var hidden = false;
if (state.inputValue) {
hidden = true;
}
if (state.value.length) {
hidden = true;
}
if (isCombobox(props) && state.value.length === 1 && !state.value[0].key) {
hidden = false;
}
var placeholder = props.placeholder;
if (placeholder) {
return React.createElement(
'div',
_extends({
onMouseDown: preventDefaultEvent,
style: _extends({
display: hidden ? 'none' : 'block'
}, UNSELECTABLE_STYLE)
}, UNSELECTABLE_ATTRIBUTE, {
onClick: this.onPlaceholderClick,
className: props.prefixCls + '-selection__placeholder'
}),
placeholder
);
}
return null;
},
getInputElement: function getInputElement() {
var props = this.props;
var inputElement = props.getInputElement ? props.getInputElement() : React.createElement('input', null);
var inputCls = classnames(inputElement.props.className, _defineProperty({}, props.prefixCls + '-search__field', true));
return React.createElement(
'div',
{ className: props.prefixCls + '-search__field__wrap' },
React.cloneElement(inputElement, {
ref: this.saveInputRef,
onChange: this.onInputChange,
onKeyDown: chaining(this.onInputKeyDown, inputElement.props.onKeyDown),
value: this.state.inputValue,
disabled: props.disabled,
className: inputCls
}),
React.createElement(
'span',
{
ref: this.saveInputMirrorRef,
className: props.prefixCls + '-search__field__mirror'
},
this.state.inputValue,
'\xA0'
)
);
},
getInputDOMNode: function getInputDOMNode() {
return this.topCtrlNode ? this.topCtrlNode.querySelector('input,textarea,div[contentEditable]') : this.inputInstance;
},
getInputMirrorDOMNode: function getInputMirrorDOMNode() {
return this.inputMirrorInstance;
},
getPopupDOMNode: function getPopupDOMNode() {
return this.refs.trigger.getPopupDOMNode();
},
getPopupMenuComponent: function getPopupMenuComponent() {
return this.refs.trigger.getInnerMenu();
},
setOpenState: function setOpenState(open, needFocus) {
var _this5 = this;
var props = this.props,
state = this.state;
if (state.open === open) {
this.maybeFocus(open, needFocus);
return;
}
var nextState = {
open: open
};
if (!open && isSingleMode(props) && props.showSearch) {
this.setInputValue('');
}
if (!open) {
this.maybeFocus(open, needFocus);
}
this.setState(nextState, function () {
if (open) {
_this5.maybeFocus(open, needFocus);
}
});
},
setInputValue: function setInputValue(inputValue) {
var fireSearch = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
if (inputValue !== this.state.inputValue) {
this.setState({
inputValue: inputValue
});
if (fireSearch) {
this.props.onSearch(inputValue);
}
}
},
timeoutFocus: function timeoutFocus() {
var _this6 = this;
if (this.focusTimer) {
this.clearFocusTime();
}
this.focusTimer = setTimeout(function () {
_this6.props.onFocus();
}, 10);
},
clearFocusTime: function clearFocusTime() {
if (this.focusTimer) {
clearTimeout(this.focusTimer);
this.focusTimer = null;
}
},
clearBlurTime: function clearBlurTime() {
if (this.blurTimer) {
clearTimeout(this.blurTimer);
this.blurTimer = null;
}
},
clearAdjustTimer: function clearAdjustTimer() {
if (this.skipAdjustOpenTimer) {
clearTimeout(this.skipAdjustOpenTimer);
this.skipAdjustOpenTimer = null;
}
},
updateFocusClassName: function updateFocusClassName() {
var refs = this.refs,
props = this.props;
if (this._focused) {
classes(refs.root).add(props.prefixCls + '-focused');
} else {
classes(refs.root).remove(props.prefixCls + '-focused');
}
},
maybeFocus: function maybeFocus(open, needFocus) {
if (needFocus || open) {
var input = this.getInputDOMNode();
var _document = document,
activeElement = _document.activeElement;
if (input && (open || isMultipleOrTagsOrCombobox(this.props))) {
if (activeElement !== input) {
input.focus();
this._focused = true;
}
} else {
var selection = this.refs.selection;
if (activeElement !== selection) {
selection.focus();
this._focused = true;
}
}
}
},
addLabelToValue: function addLabelToValue(props, value_) {
var _this7 = this;
var value = value_;
if (props.labelInValue) {
value.forEach(function (v) {
v.label = v.label || _this7.getLabelFromProps(props, v.key);
});
} else {
value = value.map(function (v) {
return {
key: v,
label: _this7.getLabelFromProps(props, v)
};
});
}
return value;
},
addTitleToValue: function addTitleToValue(props, values) {
var _this8 = this;
var nextValues = values;
var keys = values.map(function (v) {
return v.key;
});
React.Children.forEach(props.children, function (child) {
if (child.type.isSelectOptGroup) {
nextValues = _this8.addTitleToValue(child.props, nextValues);
} else {
var value = getValuePropValue(child);
var valueIndex = keys.indexOf(value);
if (valueIndex > -1) {
nextValues[valueIndex].title = child.props.title;
}
}
});
return nextValues;
},
removeSelected: function removeSelected(selectedKey) {
var props = this.props;
if (props.disabled || this.isChildDisabled(selectedKey)) {
return;
}
var label = void 0;
var value = this.state.value.filter(function (singleValue) {
if (singleValue.key === selectedKey) {
label = singleValue.label;
}
return singleValue.key !== selectedKey;
});
var canMultiple = isMultipleOrTags(props);
if (canMultiple) {
var event = selectedKey;
if (props.labelInValue) {
event = {
key: selectedKey,
label: label
};
}
props.onDeselect(event);
}
this.fireChange(value);
},
openIfHasChildren: function openIfHasChildren() {
var props = this.props;
if (React.Children.count(props.children) || isSingleMode(props)) {
this.setOpenState(true);
}
},
fireChange: function fireChange(value) {
var props = this.props;
if (!('value' in props)) {
this.setState({
value: value
});
}
props.onChange(this.getVLForOnChange(value));
},
isChildDisabled: function isChildDisabled(key) {
return toArray(this.props.children).some(function (child) {
var childValue = getValuePropValue(child);
return childValue === key && child.props && child.props.disabled;
});
},
tokenize: function tokenize(string) {
var _this9 = this;
var _props = this.props,
multiple = _props.multiple,
tokenSeparators = _props.tokenSeparators,
children = _props.children;
var nextValue = this.state.value;
splitBySeparators(string, tokenSeparators).forEach(function (label) {
var selectedValue = { key: label, label: label };
if (findIndexInValueByLabel(nextValue, label) === -1) {
if (multiple) {
var value = _this9.getValueByLabel(children, label);
if (value) {
selectedValue.key = value;
nextValue = nextValue.concat(selectedValue);
}
} else {
nextValue = nextValue.concat(selectedValue);
}
}
});
return nextValue;
},
adjustOpenState: function adjustOpenState() {
if (this.skipAdjustOpen) {
return;
}
var open = this.state.open;
if (typeof document !== 'undefined' && this.getInputDOMNode() && document.activeElement === this.getInputDOMNode()) {
open = true;
}
var options = [];
if (open) {
options = this.renderFilterOptions();
}
this._options = options;
if (isMultipleOrTagsOrCombobox(this.props) || !this.props.showSearch) {
if (open && !options.length) {
open = false;
}
}
this.state.open = open;
},
renderTopControlNode: function renderTopControlNode() {
var _this10 = this;
var _state = this.state,
value = _state.value,
open = _state.open,
inputValue = _state.inputValue;
var props = this.props;
var choiceTransitionName = props.choiceTransitionName,
prefixCls = props.prefixCls,
maxTagTextLength = props.maxTagTextLength,
showSearch = props.showSearch;
var className = prefixCls + '-selection__rendered';
var innerNode = null;
if (isSingleMode(props)) {
var selectedValue = null;
if (value.length) {
var showSelectedValue = false;
var opacity = 1;
if (!showSearch) {
showSelectedValue = true;
} else {
if (open) {
showSelectedValue = !inputValue;
if (showSelectedValue) {
opacity = 0.4;
}
} else {
showSelectedValue = true;
}
}
var singleValue = value[0];
selectedValue = React.createElement(
'div',
{
key: 'value',
className: prefixCls + '-selection-selected-value',
title: singleValue.title || singleValue.label,
style: {
display: showSelectedValue ? 'block' : 'none',
opacity: opacity
}
},
value[0].label
);
}
if (!showSearch) {
innerNode = [selectedValue];
} else {
innerNode = [selectedValue, React.createElement(
'div',
{
className: prefixCls + '-search ' + prefixCls + '-search--inline',
key: 'input',
style: {
display: open ? 'block' : 'none'
}
},
this.getInputElement()
)];
}
} else {
var selectedValueNodes = [];
if (isMultipleOrTags(props)) {
selectedValueNodes = value.map(function (singleValue) {
var content = singleValue.label;
var title = singleValue.title || content;
if (maxTagTextLength && typeof content === 'string' && content.length > maxTagTextLength) {
content = content.slice(0, maxTagTextLength) + '...';
}
var disabled = _this10.isChildDisabled(singleValue.key);
var choiceClassName = disabled ? prefixCls + '-selection__choice ' + prefixCls + '-selection__choice__disabled' : prefixCls + '-selection__choice';
return React.createElement(
'li',
_extends({
style: UNSELECTABLE_STYLE
}, UNSELECTABLE_ATTRIBUTE, {
onMouseDown: preventDefaultEvent,
className: choiceClassName,
key: singleValue.key,
title: title
}),
React.createElement(
'div',
{ className: prefixCls + '-selection__choice__content' },
content
),
disabled ? null : React.createElement('span', {
className: prefixCls + '-selection__choice__remove',
onClick: _this10.removeSelected.bind(_this10, singleValue.key)
})
);
});
}
selectedValueNodes.push(React.createElement(
'li',
{
className: prefixCls + '-search ' + prefixCls + '-search--inline',
key: '__input'
},
this.getInputElement()
));
if (isMultipleOrTags(props) && choiceTransitionName) {
innerNode = React.createElement(
Animate,
{
onLeave: this.onChoiceAnimationLeave,
component: 'ul',
transitionName: choiceTransitionName
},
selectedValueNodes
);
} else {
innerNode = React.createElement(
'ul',
null,
selectedValueNodes
);
}
}
return React.createElement(
'div',
{
className: className,
ref: function ref(node) {
return _this10.topCtrlNode = node;
}
},
this.getPlaceholderElement(),
innerNode
);
},
render: function render() {
var _rootCls;
var props = this.props;
var multiple = isMultipleOrTags(props);
var state = this.state;
var className = props.className,
disabled = props.disabled,
allowClear = props.allowClear,
prefixCls = props.prefixCls;
var ctrlNode = this.renderTopControlNode();
var extraSelectionProps = {};
var open = this.state.open;
var options = this._options;
if (!isMultipleOrTagsOrCombobox(props)) {
extraSelectionProps = {
onKeyDown: this.onKeyDown,
tabIndex: 0
};
}
var rootCls = (_rootCls = {}, _defineProperty(_rootCls, className, !!className), _defineProperty(_rootCls, prefixCls, 1), _defineProperty(_rootCls, prefixCls + '-open', open), _defineProperty(_rootCls, prefixCls + '-focused', open || !!this._focused), _defineProperty(_rootCls, prefixCls + '-combobox', isCombobox(props)), _defineProperty(_rootCls, prefixCls + '-disabled', disabled), _defineProperty(_rootCls, prefixCls + '-enabled', !disabled), _defineProperty(_rootCls, prefixCls + '-allow-clear', !!props.allowClear), _rootCls);
var clearStyle = _extends({}, UNSELECTABLE_STYLE, {
display: 'none'
});
if (state.inputValue || state.value.length) {
clearStyle.display = 'block';
}
var clear = React.createElement('span', _extends({
key: 'clear',
onMouseDown: preventDefaultEvent,
style: clearStyle
}, UNSELECTABLE_ATTRIBUTE, {
className: prefixCls + '-selection__clear',
onClick: this.onClearSelection
}));
return React.createElement(
SelectTrigger,
{
onPopupFocus: this.onPopupFocus,
dropdownAlign: props.dropdownAlign,
dropdownClassName: props.dropdownClassName,
dropdownMatchSelectWidth: props.dropdownMatchSelectWidth,
defaultActiveFirstOption: props.defaultActiveFirstOption,
dropdownMenuStyle: props.dropdownMenuStyle,
transitionName: props.transitionName,
animation: props.animation,
prefixCls: props.prefixCls,
dropdownStyle: props.dropdownStyle,
combobox: props.combobox,
showSearch: props.showSearch,
options: options,
multiple: multiple,
disabled: disabled,
visible: open,
inputValue: state.inputValue,
value: state.value,
onDropdownVisibleChange: this.onDropdownVisibleChange,
getPopupContainer: props.getPopupContainer,
onMenuSelect: this.onMenuSelect,
onMenuDeselect: this.onMenuDeselect,
ref: 'trigger'
},
React.createElement(
'div',
{
style: props.style,
ref: 'root',
onBlur: this.onOuterBlur,
onFocus: this.onOuterFocus,
className: classnames(rootCls)
},
React.createElement(
'div',
_extends({
ref: 'selection',
key: 'selection',
className: prefixCls + '-selection\n ' + prefixCls + '-selection--' + (multiple ? 'multiple' : 'single'),
role: 'combobox',
'aria-autocomplete': 'list',
'aria-haspopup': 'true',
'aria-expanded': open
}, extraSelectionProps),
ctrlNode,
allowClear ? clear : null,
multiple || !props.showArrow ? null : React.createElement(
'span',
_extends({
key: 'arrow',
className: prefixCls + '-arrow',
style: UNSELECTABLE_STYLE
}, UNSELECTABLE_ATTRIBUTE, {
onClick: this.onArrowClick
}),
React.createElement('b', null)
)
)
)
);
}
});
Select.displayName = 'Select';
export default Select;
|
resources/apps/frontend/src/pages/subscriptions/form.js
|
johndavedecano/PHPLaravelGymManagementSystem
|
import React from 'react';
import serialize from 'form-serialize';
import {Form, FormGroup, Input, Label, Button, Row, Col} from 'reactstrap';
import MemberSelect from 'components/Form/Select/MemberSelect';
import SubscriptionStatusSelect from 'components/Form/Select/SubscriptionStatusSelect';
import PackageSelect from 'components/Form/Select/PackageSelect';
import getErrorMessage from 'utils/getErrorMessage';
import notify from 'utils/notify';
import date from 'utils/date';
export default class extends React.Component {
static defaultProps = {
successMessage: 'Successfully submitted',
onSubmit: () => {},
isCreate: false,
status: 'active',
interval: 1,
};
state = {
isSubmitting: false,
};
onSubmit = async event => {
try {
event.preventDefault();
this.setState({isSubmitting: true});
const form = event.target;
const data = serialize(form, {hash: true});
await this.props.onSubmit(data);
this.setState({isSubmitting: false});
notify({
type: 'success',
text: this.props.successMessage,
});
} catch (error) {
notify({
type: 'error',
text: getErrorMessage(error),
});
this.setState({isSubmitting: false});
}
};
render() {
return (
<Form onSubmit={this.onSubmit}>
<Row>
<Col md={6}>
<FormGroup>
<Label for="user_id">Member</Label>
<MemberSelect
name="user_id"
id="user_id"
placeholder="Select Member"
defaultValue={this.props.user_id}
/>
</FormGroup>
</Col>
<Col md={6}>
<FormGroup>
<Label for="package_id">Package</Label>
<PackageSelect
name="package_id"
id="package_id"
placeholder="Select Package"
defaultValue={this.props.package_id}
/>
</FormGroup>
</Col>
</Row>
<Row>
<Col md={6}>
<FormGroup>
<Label for="interval">Interval</Label>
<Input
type="number"
name="interval"
id="interval"
required
min={1}
defaultValue={this.props.interval}
/>
</FormGroup>
</Col>
<Col md={6}>
<FormGroup>
<Label for="status">Status</Label>
<SubscriptionStatusSelect
name="status"
id="status"
placeholder="Select Status"
defaultValue={this.props.status}
isDisabled={this.props.isCreate}
/>
</FormGroup>
</Col>
</Row>
<Row>
<Col md={6}>
<FormGroup>
<Label for="expires_at">Expiration At</Label>
<input
className="form-control"
type="date"
name="expires_at"
id="expires_at"
required
min={1}
defaultValue={date(this.props.expires_at, 'YYYY-MM-DD')}
disabled={this.props.isCreate}
/>
</FormGroup>
</Col>
<Col md={6}>
<FormGroup>
<Label for="suspended_at">Suspended At</Label>
<input
className="form-control"
type="date"
name="suspended_at"
id="suspended_at"
required
min={1}
defaultValue={date(this.props.suspended_at, 'YYYY-MM-DD')}
disabled={this.props.isCreate}
/>
</FormGroup>
</Col>
</Row>
<Button
color="primary"
className="float-right"
disabled={this.state.isSubmitting}
>
{this.state.isSubmitting ? 'Please Wait...' : 'Submit Form'}
</Button>
</Form>
);
}
}
|
component/Test.js
|
jimju/BNDemo
|
'use strict'
import React, { Component } from 'react';
import {
Text,StyleSheet,View
} from 'react-native';
class Test extends React.Component {
render(){
return(
<View style={styles.content}>
<Text> Hello Test !</Text>
</View>
);
}
}
const styles = StyleSheet.create({
content:{
flex:1,
flexDirection:'column',
}
});
export {Test as default};
|
src/components/topic/stories/BrowseStoriesContainer.js
|
mitmedialab/MediaCloud-Web-Tools
|
import PropTypes from 'prop-types';
import React from 'react';
import { FormattedMessage, injectIntl } from 'react-intl';
import { connect } from 'react-redux';
import { push } from 'react-router-redux';
import { Grid, Row, Col } from 'react-flexbox-grid/lib';
import { pagedAndSortedLocation } from '../../util/location';
import withPaging from '../../common/hocs/PagedContainer';
import TopicPageTitle from '../TopicPageTitle';
import TopicStoriesContainer from '../provider/TopicStoriesContainer';
const localMessages = {
title: { id: 'topic.influentialStories.title', defaultMessage: 'Browse Stories' },
};
const BrowseStoriesContainer = ({ previousButton, nextButton, linkId }) => (
<Grid>
<Row>
<Col lg={12}>
<TopicPageTitle value={localMessages.title} />
<h1><FormattedMessage {...localMessages.title} /></h1>
<TopicStoriesContainer
border={false}
uid="browse"
extraArgs={{ limit: 100 }}
linkId={linkId}
/>
{ previousButton }
{ nextButton }
</Col>
</Row>
</Grid>
);
BrowseStoriesContainer.propTypes = {
// from the composition chain
intl: PropTypes.object.isRequired,
// from state
links: PropTypes.object,
linkId: PropTypes.string,
// from PagedContainer wrapper
nextButton: PropTypes.node,
previousButton: PropTypes.node,
};
const mapStateToProps = (state, ownProps) => ({
links: state.topics.selected.provider.stories.results.browse ? state.topics.selected.provider.stories.results.browse.link_ids : {},
linkId: ownProps.location.query.linkId,
});
const handlePageChange = (dispatch, props, linkId) => {
// just update the URL
dispatch(push(pagedAndSortedLocation(
props.location,
linkId,
props.sort,
props.filters,
)));
};
export default
injectIntl(
connect(mapStateToProps)(
withPaging(handlePageChange)(
BrowseStoriesContainer
)
)
);
|
docs/app/Examples/elements/Label/Variations/LabelExampleSize.js
|
vageeshb/Semantic-UI-React
|
import _ from 'lodash'
import React from 'react'
import { Label } from 'semantic-ui-react'
const sizes = ['mini', 'tiny', 'small', 'medium', 'large', 'big', 'huge', 'massive']
const LabelExampleSize = () => (
<div>
{sizes.map(size => (
<Label key={size} size={size}>
{_.capitalize(size)}
</Label>
))}
</div>
)
export default LabelExampleSize
|
src/components/overlay_tooltip.js
|
libeanim/sundew-notes
|
import React from 'react';
import _ from 'lodash';
import { Tooltip, OverlayTrigger } from 'react-bootstrap';
export default function(props){
const id = _.uniqueId('tooltip_');
const tooltip = <Tooltip id={id}>{ props.text }</Tooltip>;
return (
<OverlayTrigger trigger={ props.trigger || ['hover', 'focus'] } placement={ props.placement || 'left' } overlay={ tooltip }>
{ props.children }
</OverlayTrigger>
);
}
|
src/NavBar.js
|
otsoaUnLoco/wolf-chess
|
// @flow
import React from 'react';
import ReadFileDialog from './ReadFileDialog';
export default function NavBar(props: {
resetBoard: (void) => void,
readFile: (string) => void
}): React.Element<*> {
return (
<div id="navBar" >
<button type="reset" onClick={props.resetBoard}>New Game</button>
<button type="button">from FEN</button>
<ReadFileDialog readFile={props.readFile} />
<button type="button">set position</button>
</div >
);
}
|
src/svg-icons/image/looks.js
|
owencm/material-ui
|
import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let ImageLooks = (props) => (
<SvgIcon {...props}>
<path d="M12 10c-3.86 0-7 3.14-7 7h2c0-2.76 2.24-5 5-5s5 2.24 5 5h2c0-3.86-3.14-7-7-7zm0-4C5.93 6 1 10.93 1 17h2c0-4.96 4.04-9 9-9s9 4.04 9 9h2c0-6.07-4.93-11-11-11z"/>
</SvgIcon>
);
ImageLooks = pure(ImageLooks);
ImageLooks.displayName = 'ImageLooks';
ImageLooks.muiName = 'SvgIcon';
export default ImageLooks;
|
packages/arwes/src/Line/sandbox.js
|
romelperez/ui
|
import React from 'react';
import Line from './index';
export default () => (
<div style={{ padding: '20px' }}>
<Line animate />
<Line animate layer="success" />
<Line animate layer="alert" />
</div>
);
|
app/components/spinners/material-spinner/component.js
|
DenQ/electron-react-lex
|
import React from 'react';
import BaseComponent from 'lex/libs/base/component';
import Spinner from 'react-spinner-material';
export default class MaterialSpinner extends BaseComponent {
render() {
this.decorateStyle();
const { show } = this.props;
return (
<Spinner
size={200}
spinnerColor={this.styles.palette.textColor}
spinnerWidth={15}
visible={show}
/>
);
}
}
|
src/components/UsersWatching/index.js
|
danbovey/Dekt
|
import React, { Component } from 'react';
import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
import Tooltip from 'rc-tooltip';
import * as showActions from 'actions/show';
import Spinner from 'components/Spinner';
import './styles';
@connect(
state => ({
auth: state.auth,
watching: state.watching
}),
dispatch => ({
showActions: bindActionCreators(showActions, dispatch)
})
)
export default class UsersWatching extends Component {
componentWillMount() {
const show = this.props.show;
if(show.watching == null && show.watching_loading == false) {
this.props.showActions.watching(show.item.show.ids.slug);
}
}
renderUser(user, i, auth = false) {
return (
<Tooltip
placement="bottom"
transitionName="rc-tooltip-zoom"
overlay={<span>{auth ? 'YOU!' : user.username}</span>}
mouseLeaveDelay={0}
key={i}
>
<a href={`https://trakt.tv/users/${user.username}`} target="_blank" rel="noopener" className={auth ? 'me' : ''}>
<img src={user.images ? user.images.avatar.full : 'https://walter.trakt.tv/hotlink-ok/placeholders/medium/fry.png'} alt={user.username} />
</a>
</Tooltip>
);
}
render() {
const {
auth,
show,
watching
} = this.props;
const users = show.watching;
if(!show.watching_loading && users) {
const isWatching = watching.item && watching.item.show && watching.item.show.ids.trakt == show.item.show.ids.trakt;
let usersLength = isWatching ? 9 : 10;
if(users.length > 10) {
usersLength = usersLength - 1;
}
return (
<div className="users-watching">
{users.length > 0 ? (
<div>
<p>{users.length} watching now</p>
<div className="users">
{isWatching ? this.renderUser(auth.user, 0, true) : null}
{users.slice(0, usersLength)
.filter(u => u.username != auth.user.username)
.map((user, i) => this.renderUser(user, i))
}
{users.length > 10 ? (
<a href="#" className="plus-more">+{users.length - 9} more</a>
) : null}
</div>
</div>
) : null}
</div>
);
} else {
return (
<div className="users-watching loading">
<Spinner size="medium" />
</div>
);
}
}
}
|
teoria02/componentes/EstadoTarea.js
|
mart-dominguez/OFA2017-S01-C02
|
import React from 'react';
class EstadoTarea extends React.Component {
constructor(props) {
super(props);
this.handleChange = this.handleChange.bind(this);
}
handleChange(e) {
this.props.estadoChange(this.props.indice,e.target.name,e.target.value);
}
render(){
return (
<select value={this.props.estado} onChange={this.handleChange} name={this.props.nombre}>
<option value="planificada">Para hacer</option>
<option value="encurso">En Curso</option>
<option value="finalizada">Terminada!</option>
</select>
);
}
}
export default EstadoTarea;
|
packages/cf-builder-pagination/example/basic/component.js
|
mdno/mdno.github.io
|
import React from 'react';
import { PaginationBuilder } from 'cf-builder-pagination';
function getStartAndEnd(page, pageSize) {
const start = (page - 1) * pageSize;
const end = start + pageSize - 1;
return [start, end];
}
function hasAllItems(items, start, end) {
for (let i = start; i <= end; i++) {
if (!items[i] || items[i].isRequesting) {
return false;
}
}
return true;
}
class BuilderPagination extends React.Component {
constructor(props) {
super(props);
this.state = {
items: [],
totalCount: 143,
page: 1,
perPage: 20
};
this.handlePageChange = this.handlePageChange.bind(this);
}
componentDidMount() {
this.maybeRequestPage(this.state.page);
}
handlePageChange(page) {
this.maybeRequestPage(page);
}
// This is mimicking what will happen in the API actions/reducers:
maybeRequestPage(page) {
const items = this.state.items.slice();
const [start, end] = getStartAndEnd(page, this.state.perPage);
const needsRequest = !hasAllItems(items, start, end);
if (!needsRequest) {
this.setState({ page });
return;
}
for (let i = start; i <= end; i++) {
if (!items[i]) {
items[i] = {
isRequesting: true
};
}
}
this.setState({ page, items });
setTimeout(() => {
const items = this.state.items.slice();
for (let i = start; i <= end; i++) {
items[i].isRequesting = false;
}
this.setState({ items });
}, 500);
}
render() {
const [start, end] = getStartAndEnd(this.state.page, this.state.perPage);
const loading = !hasAllItems(this.state.items, start, end);
return (
<PaginationBuilder
onPageChange={this.handlePageChange}
loading={loading}
totalCount={this.state.totalCount}
page={this.state.page}
perPage={this.state.perPage}
/>
);
}
}
export default BuilderPagination;
|
public/assets/js/node_modules/react-select/examples/src/app.js
|
ngocson8b/6jar
|
/* eslint react/prop-types: 0 */
import React from 'react';
import ReactDOM from 'react-dom';
import Select from 'react-select';
import Contributors from './components/Contributors';
import CustomKeysField from './components/CustomKeysField';
import CustomRenderField from './components/CustomRenderField';
import DisabledUpsellOptions from './components/DisabledUpsellOptions';
import MultiSelectField from './components/MultiSelectField';
import RemoteSelectField from './components/RemoteSelectField';
import SelectedValuesField from './components/SelectedValuesField';
import StatesField from './components/StatesField';
import UsersField from './components/UsersField';
import ValuesAsNumbersField from './components/ValuesAsNumbersField';
var FLAVOURS = [
{ label: 'Chocolate', value: 'chocolate' },
{ label: 'Vanilla', value: 'vanilla' },
{ label: 'Strawberry', value: 'strawberry' },
{ label: 'Cookies and Cream', value: 'cookiescream' },
{ label: 'Peppermint', value: 'peppermint' }
];
var FLAVOURS_WITH_DISABLED_OPTION = FLAVOURS.slice(0);
FLAVOURS_WITH_DISABLED_OPTION.unshift({ label: 'Caramel (You don\'t like it, apparently)', value: 'caramel', disabled: true });
function logChange() {
console.log.apply(console, [].concat(['Select value changed:'], Array.prototype.slice.apply(arguments)));
}
ReactDOM.render(
<div>
<StatesField label="States" searchable />
<MultiSelectField label="Multiselect" />
<Contributors label="Contributors" hint="This example uses custom properties for the name and value of options, as well as async options loading" />
<UsersField label="Users (custom options/value)" hint="This example uses Gravatar to render user's image besides the value and the options" />
<ValuesAsNumbersField label="Values as numbers" />
<CustomKeysField label="Custom object keys for options" />
<SelectedValuesField label="Clickable labels (labels as links)" options={FLAVOURS} hint="Open the console to see click behaviour (data/event)" />
<SelectedValuesField label="Disabled option" options={FLAVOURS_WITH_DISABLED_OPTION} hint="You savage! Caramel is the best..." />
<DisabledUpsellOptions label="Disabled option with a link"/>
<SelectedValuesField label="Option Creation (tags mode)" options={FLAVOURS} allowCreate hint="Enter a value that's NOT in the list, then hit return" />
<CustomRenderField label="Custom render options/values" />
<RemoteSelectField label="Remote Options" hint='Type anything in the remote example to asynchronously load options. Valid alternative results are "A", "AA", and "AB"' />
</div>,
document.getElementById('example')
);
|
public/js/app/queryTools/components/TableResult.js
|
fendy3002/QzQueryTools
|
import React from 'react'
import lo from 'lodash'
import sa from 'superagent';
var Elem = function({table}){
var renderHead = (fields) => {
var fieldDoms = lo.map(fields, k=> (
<th>{k}</th>
));
return <thead>
<tr>
{fieldDoms}
</tr>
</thead>;
};
var renderTd = (row, fields) => {
return lo.map(fields, k=> {
return <td>{row[k]}</td>;
});
};
var renderData = (data, fields) => {
var trList = lo.map(data, row => {
return <tr>{renderTd(row, fields)}</tr>;
});
return <tbody>{trList}</tbody>;
};
return <div className="box">
<div className="box-header with-border">
<h3 className="box-title">{table.label}</h3>
<div className="box-tools pull-right">
<button type="button" className="btn btn-box-tool" data-widget="collapse">
<i className="fa fa-minus"></i>
</button>
</div>
</div>
<div className="box-body table-responsive no-padding">
<table className="table table-responsive table-condensed table-striped table-bordered">
{renderHead(table.fields)}
{renderData(table.data, table.fields)}
</table>
</div>
</div>;
};
export default Elem;
|
src/js/templates/content/post.js
|
julianburr/wp-react-theme
|
import React, { Component } from 'react';
import PostMeta from '../../components/post/meta';
import { renderHtml } from '../../utils/render';
export default class ContentPost extends Component {
render () {
const { content } = this.props;
console.log('content.data.data', content.data.data)
return (
<div>
<PostMeta post={content.data.data} />
<h1>{content.data.data.title}</h1>
{renderHtml(content.data.data.content.rendered)}
{/* TODO: next/prev buttons */}
</div>
);
}
}
|
app/component/target-progress.js
|
TinyTheBrontosaurus/CricketTrainer
|
import React, { Component } from 'react';
import {
AppRegistry,
Button,
Text
} from 'react-native';
import { Col, Grid } from "react-native-easy-grid";
/**
* A single target for displaying its progress in the darts game. Shows a button that can hit next
* to its progress.
*/
export default class TargetProgress extends Component {
constructor(props) {
super(props);
}
render() {
return <Grid>
<Col size={1}>
<Button
onPress={this.props.callback}
title={"" + this.props.label}
accessibilityLabel={"Hit target " + this.props.label}
disabled={this.props.disabled}
color="#841584"
/>
</Col>
<Col size={1}>
<Text>{this.getHitsSymbol()}</Text>
</Col>
<Col size={1}>
<Text>{(this.props.cleared || "-")}</Text>
</Col>
</Grid>
}
/**
* Cricket progress is typically marked by a \, X, then (X) on a chalkboard. Do the best with
* ASCII art here to return that
* @returns {*} Symbol based on number of hits
*/
getHitsSymbol() {
switch(this.props.hits) {
case 0:
return '-';
case 1:
return '\\';
case 2:
return 'X';
case 3:
default:
return 'O';
}
}
}
AppRegistry.registerComponent('TargetProgress', () => TargetProgress);
|
client/admin/scenes/protected/settings.js
|
kirinami/portfolio
|
import React, { Component } from 'react';
import { Breadcrumb, BreadcrumbItem } from 'reactstrap';
import { Link } from 'react-router-dom';
import { inject, observer } from 'mobx-react';
import Loading from '../../components/loading';
import InputField from '../../forms/fields/input-field';
import TextareaField from '../../forms/fields/textarea-field';
import SettingsForm from '../../forms/settings-form';
@inject('alertStore', 'settingsStore')
@observer
export default class Settings extends Component {
settingsForm = new SettingsForm();
async componentDidMount() {
const { alertStore, settingsStore } = this.props;
try {
const response = await settingsStore.loadSettings();
if (response.success) {
this.settingsForm.imports(settingsStore.settings);
}
alertStore.showSuccess(response.message);
} catch (err) {
alertStore.showDanger(err.message);
}
}
async handleSubmit() {
const { alertStore, settingsStore } = this.props;
try {
const form = this.settingsForm.exports();
const response = await settingsStore.updateSettings(form);
alertStore.showSuccess(response.message);
} catch (err) {
alertStore.showDanger(err.message);
}
}
render() {
const { settingsStore } = this.props;
const { isLoading, settings } = settingsStore;
if (isLoading) {
return <Loading/>;
}
return (
<div className="settings-component">
<Breadcrumb>
<BreadcrumbItem>
<Link to="/">Dashboard</Link>
</BreadcrumbItem>
<BreadcrumbItem active>Settings</BreadcrumbItem>
</Breadcrumb>
<div className="row">
<div className="col-12">
<form
className="mb-3"
onSubmit={event => this.settingsForm.onSubmit(event, {
onSuccess: this.handleSubmit.bind(this),
})}>
<div className="card mb-3">
<div className="card-body">
<div className="form-group">
<InputField field={this.settingsForm.select('title')}/>
</div>
<div className="form-group">
<InputField field={this.settingsForm.select('keywords')}/>
</div>
<div className="form-group mb-0">
<TextareaField field={this.settingsForm.select('description')}/>
</div>
</div>
</div>
<div className="card mb-3">
<div className="card-header">
{this.settingsForm.select('block.header').label}
</div>
<div className="card-body">
<div className="form-group">
<InputField field={this.settingsForm.select('block.header.title')}/>
</div>
<div className="form-group mb-0">
<TextareaField field={this.settingsForm.select('block.header.description')}/>
</div>
</div>
</div>
<div className="card mb-3">
<div className="card-header">
{this.settingsForm.select('block.about').label}
</div>
<div className="card-body pb-1">
<div className="row">
{this.settingsForm.select('block.about').map((field, i) => (
<div key={field.id} className="col-md-6">
<div className="card mb-3">
<div className="card-body">
<div className="form-group">
<InputField field={field.select('title')}/>
</div>
<div className="form-group mb-0">
<TextareaField field={field.select('description')}/>
</div>
</div>
</div>
</div>
))}
</div>
</div>
</div>
<div className="card mb-3">
<div className="card-header">
{this.settingsForm.select('block.portfolio').label}
</div>
<div className="card-body">
<div className="form-group mb-0">
<InputField field={this.settingsForm.select('block.portfolio.heading')}/>
</div>
</div>
</div>
<div className="card mb-3">
<div className="card-header">
{this.settingsForm.select('block.contacts').label}
</div>
<div className="card-body">
<div className="form-group mb-0">
<InputField field={this.settingsForm.select('block.contacts.heading')}/>
</div>
</div>
</div>
<div className="card">
<div className="card-footer bg-white" style={{ borderTop: 'none' }}>
<div className="row">
<div className="col-lg-6 mb-2 mb-lg-0 pt-lg-1-9">
<small className="text-muted">{settings.updatedAt}</small>
</div>
<div className="col-lg-6 text-lg-right">
<button type="submit" className="btn btn-success mr-1 mb-1 mb-lg-0">
<i className="fa fa-fw fa-save"/>
</button>
</div>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
);
}
}
|
news/sources/app.js
|
pintimes/lifeix-football-app-react
|
/**
* Sample React Native App
* https://github.com/facebook/react-native
* @flow
*/
import React, { Component } from 'react';
import {
StyleSheet,
Navigator
} from 'react-native';
import {Router, routerReducer, Route, Container, Animations, Schema} from 'react-native-redux-router';
import { createStore, combineReducers } from 'redux';
import { Provider } from 'react-redux';
import Welcome from './view/welcome';
import Home from './view/home';
import Detail from './view/detail';
import Settings from './view/settings';
import TestView from './view/testView';
import {NavBar, NavBarModal,NavBarLeft} from './common/NavBar';
import TestTip from './common/TestTip';
console.disableYellowBox=true;
let store = createStore(combineReducers({routerReducer}));
export default class App extends Component {
constructor (props) {
super(props)
}
render() {
return this.renderRouter();
}
renderRouter(){
return (
<Provider store={store}>
<Router>
<Schema name="default" sceneConfig={Animations.FlatFloatFromRight}/>
<Schema name="withoutAnimation" sceneConfig={Animations.FlatFloatFromBottom} navBar={NavBarLeft} type="RESET"/>
<Route name="welcome" component={Welcome} initial={true} type="reset" />
<Route name="home" component={Home} schema="default" title="首页" />
<Route name="detail" component={Detail} schema="withoutAnimation" title="详情"/>
<Route name="settings" component={Settings} />
<Route name="testTip" component={TestTip} schema="popup" />
<Route name="testView" component={TestView} />
</Router>
</Provider>
)
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
//backgroundColor: '#CE1126',
},
});
|
src/index.js
|
budunwang/React-Gallery
|
import 'core-js/fn/object/assign';
import React from 'react';
import ReactDOM from 'react-dom';
import App from './components/Main';
// Render the main component into the dom
ReactDOM.render(<App />, document.getElementById('app'));
|
src/main.js
|
successkrisz/fx-rates-right
|
import React from 'react'
import ReactDOM from 'react-dom'
import createStore from './store/createStore'
import AppContainer from './containers/AppContainer'
// ========================================================
// Store Instantiation
// ========================================================
const initialState = window.___INITIAL_STATE__
const store = createStore(initialState)
// ========================================================
// Render Setup
// ========================================================
const MOUNT_NODE = document.getElementById('root')
let render = () => {
const routes = require('./routes/index').default(store)
ReactDOM.render(
<AppContainer store={store} routes={routes} />,
MOUNT_NODE
)
}
// This code is excluded from production bundle
if (__DEV__) {
if (module.hot) {
// Development render functions
const renderApp = render
const renderError = (error) => {
const RedBox = require('redbox-react').default
ReactDOM.render(<RedBox error={error} />, MOUNT_NODE)
}
// Wrap render in try/catch
render = () => {
try {
renderApp()
} catch (error) {
console.error(error)
renderError(error)
}
}
// Setup hot module replacement
module.hot.accept('./routes/index', () =>
setImmediate(() => {
ReactDOM.unmountComponentAtNode(MOUNT_NODE)
render()
})
)
}
}
// ========================================================
// Go!
// ========================================================
render()
|
client/app/screens/InviteCreate.js
|
damienomurchu/snapscreen
|
import React from 'react';
import { Image, Picker } from 'react-native';
import {
Body,
Card,
CardItem,
Container,
Content,
Button,
Icon,
Item,
Input,
Text,
Toast,
View,
} from 'native-base';
import { createInvite } from '../api';
import { formatShowtime } from '../utils';
const styles = {
content: {
marginVertical: 10,
marginHorizontal: 8,
},
buttonContainer: {
marginTop: 8,
marginHorizontal: 2,
},
h4: {
fontSize: 18,
lineHeight: 24,
},
small: {
fontSize: 14,
},
};
export default class InviteCreateScreen extends React.Component {
static navigationOptions = {
title: 'Create Invite',
};
constructor(props) {
super(props);
this.state = {
invitees: [
{
id: '',
},
],
};
}
_theaterSelected(theater) {
this.setState({
theater,
movieShowtime: null,
});
}
_movieShowtimeSelected(movieShowtime) {
this.setState({ movieShowtime });
}
_handleInviteeChange(index, input) {
// Update list of invitees when text inputs are changed
let invitees = this.state.invitees.slice();
invitees[index] = { id: input, name: input };
this.setState({ invitees });
}
_handleInviteeSubmit(index, event) {
// Ensure there's always an empty invitee input
let invitees = this.state.invitees.slice();
if (invitees[invitees.length - 1].id !== '') {
invitees.push({ id: '' });
this.setState({ invitees });
}
}
_handleSendInvite() {
// Strip off the empty invitee if there is one
let invitees = this.state.invitees.slice();
if (invitees[invitees.length - 1].id === '') {
invitees.pop();
}
// Prepare payload
let payload = {
theater: this.state.theater,
movie: this.state.movieShowtime.movie,
showtime: this.state.movieShowtime.showtime,
invitees: invitees,
};
// Send it!
createInvite(payload)
.then(() => {
Toast.show({
text: 'Invite sent!',
position: 'bottom',
buttonText: 'Okay',
});
this.props.navigation.goBack();
})
.catch(error => {
alert('Error sending invite: ' + JSON.stringify(error));
});
}
_canSendInvite() {
return (
this.state.theater &&
this.state.movieShowtime &&
this.state.invitees[0].id
);
}
render() {
return (
<Container>
<Content style={styles.content}>
<Card>
<CardItem header bordered>
<Icon name="pin" /><Text>THEATER</Text>
</CardItem>
<If condition={this.state.theater}>
<CardItem>
<Body>
<Text style={styles.h4}>{this.state.theater.name}</Text>
<Text style={styles.small}>{this.state.theater.address}</Text>
</Body>
</CardItem>
</If>
<CardItem>
<Button
rounded
light
small
onPress={() =>
this.props.navigation.navigate('SelectTheater', {
onSelect: this._theaterSelected.bind(this),
})}
>
<Text>Select a theater</Text>
</Button>
</CardItem>
</Card>
<Card>
<CardItem header bordered>
<Icon name="clock" />
<Text>MOVIE & SHOWTIME</Text>
</CardItem>
<If condition={this.state.movieShowtime}>
<CardItem>
<Body>
<Text style={styles.h4}>
{this.state.movieShowtime.movie.title}
</Text>
<Text style={styles.small}>
{formatShowtime(this.state.movieShowtime.showtime.time)}
</Text>
</Body>
</CardItem>
</If>
<CardItem>
<Button
rounded
light
small
disabled={!this.state.theater}
onPress={() =>
this.props.navigation.navigate('SelectMovieShowtime', {
theaterID: this.state.theater.id,
onSelect: this._movieShowtimeSelected.bind(this),
})}
>
<Text>Select a movie & showtime</Text>
</Button>
</CardItem>
</Card>
<Card>
<CardItem header bordered>
<Icon name="people" />
<Text>INVITED</Text>
</CardItem>
<CardItem>
<Body>
<For each="invitee" index="idx" of={this.state.invitees}>
<Item underline key={idx}>
<Input
placeholder="Enter an email address"
onChangeText={this._handleInviteeChange.bind(this, idx)}
onSubmitEditing={this._handleInviteeSubmit.bind(
this,
idx
)}
/>
</Item>
</For>
</Body>
</CardItem>
</Card>
<View style={styles.buttonContainer}>
<Button
block
primary
disabled={!this._canSendInvite()}
onPress={this._handleSendInvite.bind(this)}
>
<Text>Send Invite</Text>
</Button>
</View>
</Content>
</Container>
);
}
}
|
src/scripts/views/reclaimPage.js
|
TayLang/IronPong
|
import React from 'react'
import ACTIONS from '../actions.js'
import STORE from '../store.js'
import NavBar from './components/navBar'
import Header from './components/header'
var ReclaimPage = React.createClass({
render: function(){
return(
<div className = 'reclaim-page-wrapper'>
<Header />
<NavBar />
<ReclaimForm />
</div>
)
}
})
var ReclaimForm = React.createClass({
handleKeyPress: function(){
},
render: function() {
return(
<div>
<input onKeyPress={this.handleKeyPress} type="text" placeholder="Enter old nickname"/>
</div>
)
}
})
export default ReclaimPage
|
renderer/components/File.js
|
JiniHendrix/reactide
|
import React from 'react';
import RenameForm from './RenameForm';
import PropTypes from 'prop-types';
const File = ({
file,
dblClickHandler,
selectedItem,
id,
clickHandler,
renameFlag,
renameHandler
}) => {
return (
<li
className={selectedItem.id === id ? 'list-item selected' : 'list-item'}
onDoubleClick={dblClickHandler.bind(null, file)}
onClick={clickHandler.bind(null, id, file.path, file.type)}
>
{renameFlag && selectedItem.id === id ? <RenameForm renameHandler={renameHandler}/> : <span className="icon icon-file-text">{file.name}</span>}
</li>
)
}
File.propTypes = {
file: PropTypes.object.isRequired,
dblClickHandler: PropTypes.func.isRequired,
selectedItem: PropTypes.object.isRequired,
id: PropTypes.number.isRequired,
clickHandler: PropTypes.func.isRequired,
renameFlag: PropTypes.bool.isRequired,
renameHandler: PropTypes.func.isRequired
}
export default File;
|
src/components/top-bar.js
|
mushishi78/content-editor
|
import React from 'react';
export default class TopBar extends React.Component {
render() {
return !this.props.loggedIn ? null :
<header style={styles.header}>
<nav style={styles.nav}>
{this.iconLink('/mushishi78/content-editor/docs', icons.docs)}
{this.iconLink('https://github.com/mushishi78/content-editor', icons.github)}
{this.logout()}
</nav>
{this.iconLink('/', icons.home)}
{this.breadcrumbs(this.props.href || '')}
</header>
}
iconLink(href, icon) {
return (
<a href={href} style={styles.a}>
<i style={styles.icon} className={icon} />
</a>
);
}
logout() {
return(
<a onClick={this.props.logout.bind(this, undefined)}
href='javascript:void(0)'>
<i style={styles.icon} className={icons.logout} />
</a>
);
}
breadcrumbs(href) {
return href.split('/').map((label, i, array) => {
return !label ? null :
<span style={styles.breadcrumb} key={i}>
<a href={array.slice(0, i + 1).join('/')} style={styles.a}>{label}</a>
{ i < array.length - 1 ? '/' : '' }
</span>
})
}
}
const icons = {
home: 'octicon octicon-home',
logout: 'octicon octicon-log-out',
docs: 'octicon octicon-info',
github: 'octicon octicon-mark-github'
}
const styles = {
header: {
background: '#fff',
fontSize: '1.5em',
padding: '0.3em',
boxShadow: '0 1px 1px 1px rgba(0,0,0,0.5)'
},
nav: {
float: 'right'
},
a: {
color: '#2980b9',
padding: '0 0.2em'
},
breadcrumb: {
display: 'inline-block'
},
icon: {
fontSize: '1em',
color: '#34495e',
padding: '0.05em 0.2em'
}
}
|
src/components/Button.js
|
drakang4/creative-project-manager
|
import React from 'react';
import PropTypes from 'prop-types';
import styled from 'styled-components';
import { secondary, secondaryDark, blackLight, blackLessLight, black, white } from '../styles/color';
const Button = styled.button`
padding: 16px;
font-size: 16px;
color: ${black};
background-color: ${blackLight};
border: none;
border-radius: 4px;
flex: 1;
${props => props.accent && `
color: ${white};
background-color: ${secondary};
`}
transition: all 0.2s ease;
&:not(:last-child) {
margin-right: 8px;
}
&:hover {
background-color: ${blackLessLight};
${props => props.accent && `
background-color: ${secondaryDark};
`}
}
&:active {
background-color: ${blackLessLight};
${props => props.accent && `
background-color: ${secondaryDark};
`}
}
`;
export default Button;
|
src/svg-icons/image/flip.js
|
barakmitz/material-ui
|
import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let ImageFlip = (props) => (
<SvgIcon {...props}>
<path d="M15 21h2v-2h-2v2zm4-12h2V7h-2v2zM3 5v14c0 1.1.9 2 2 2h4v-2H5V5h4V3H5c-1.1 0-2 .9-2 2zm16-2v2h2c0-1.1-.9-2-2-2zm-8 20h2V1h-2v22zm8-6h2v-2h-2v2zM15 5h2V3h-2v2zm4 8h2v-2h-2v2zm0 8c1.1 0 2-.9 2-2h-2v2z"/>
</SvgIcon>
);
ImageFlip = pure(ImageFlip);
ImageFlip.displayName = 'ImageFlip';
ImageFlip.muiName = 'SvgIcon';
export default ImageFlip;
|
src/components/Buttress/Buttress.js
|
sk-iv/iva-app
|
import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
if(process.env.WEBPACK) require('./Buttress.css');
const Buttress = (props) => {
const {
children,
className,
size,
blend,
image,
style,
alt,
...other
} = props;
const renderImg = {
role: "img",
style: {backgroundImage:`url(${image})`, ...style}
};
const renderTxt = () => {
return(
<div className={'y-middle w-100'}>
{children}
</div>
);
};
return (
<div
className={classNames('buttress-size bg-fill y-middle-wrapper', blend ? 'img-blend' : null, 'buttress-'+size, className)}
{...renderImg}
>
{children ? renderTxt() : null}
</div>
);
};
Buttress.defaultProps= {
size: 60
};
Buttress.propTypes = {
children: PropTypes.node,
className: PropTypes.string,
size: PropTypes.number
};
export default Buttress;
|
app/javascript/mastodon/features/notifications/components/notifications_permission_banner.js
|
pinfort/mastodon
|
import React from 'react';
import Icon from 'mastodon/components/icon';
import Button from 'mastodon/components/button';
import IconButton from 'mastodon/components/icon_button';
import { requestBrowserPermission } from 'mastodon/actions/notifications';
import { changeSetting } from 'mastodon/actions/settings';
import { connect } from 'react-redux';
import PropTypes from 'prop-types';
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
const messages = defineMessages({
close: { id: 'lightbox.close', defaultMessage: 'Close' },
});
export default @connect()
@injectIntl
class NotificationsPermissionBanner extends React.PureComponent {
static propTypes = {
dispatch: PropTypes.func.isRequired,
intl: PropTypes.object.isRequired,
};
handleClick = () => {
this.props.dispatch(requestBrowserPermission());
}
handleClose = () => {
this.props.dispatch(changeSetting(['notifications', 'dismissPermissionBanner'], true));
}
render () {
const { intl } = this.props;
return (
<div className='notifications-permission-banner'>
<div className='notifications-permission-banner__close'>
<IconButton icon='times' onClick={this.handleClose} title={intl.formatMessage(messages.close)} />
</div>
<h2><FormattedMessage id='notifications_permission_banner.title' defaultMessage='Never miss a thing' /></h2>
<p><FormattedMessage id='notifications_permission_banner.how_to_control' defaultMessage="To receive notifications when Mastodon isn't open, enable desktop notifications. You can control precisely which types of interactions generate desktop notifications through the {icon} button above once they're enabled." values={{ icon: <Icon id='sliders' /> }} /></p>
<Button onClick={this.handleClick}><FormattedMessage id='notifications_permission_banner.enable' defaultMessage='Enable desktop notifications' /></Button>
</div>
);
}
}
|
stories/dialogs/delete-wallet.stories.js
|
LN-Zap/zap-desktop
|
import React from 'react'
import { storiesOf } from '@storybook/react'
import { DeleteWalletDialog } from 'components/Home'
import { Window } from '../helpers'
storiesOf('Dialogs', module)
.addDecorator(story => <Window>{story()}</Window>)
.add('Delete Wallet', () => (
<DeleteWalletDialog
isOpen
onClose={() => {}}
onDelete={() => {}}
walletDir="/path/to/wallet/would/show/here"
/>
))
|
examples/custom-server-hapi/pages/index.js
|
BlancheXu/test
|
import React from 'react'
import Link from 'next/link'
export default () => (
<ul>
<li>
<Link href='/b' as='/a'>
<a>a</a>
</Link>
</li>
<li>
<Link href='/a' as='/b'>
<a>b</a>
</Link>
</li>
</ul>
)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.