path
stringlengths 5
296
| repo_name
stringlengths 5
85
| content
stringlengths 25
1.05M
|
|---|---|---|
src/containers/skill-tree/SkillTree.js
|
phodal/growth-ng
|
/* eslint-disable global-require */
/* global __DEV__, require */
import React, { Component } from 'react';
import { WebView, StyleSheet, Platform } from 'react-native';
import { Actions } from 'react-native-router-flux';
import AppSizes from '../../theme/sizes';
import AppStyles from '../../theme/styles';
import SKILL_TREE_DATA from './SKILL_TREE_DATA';
const filter = require('lodash.filter');
const styles = StyleSheet.create({
container: {
height: AppSizes.screen.height,
width: AppSizes.screen.width,
},
});
class SkillTree extends Component {
static componentName = 'SkillTree';
constructor() {
super();
this.webview = null;
}
handleMessage = (event: Object) => {
const message = event.nativeEvent.data;
const skillId = parseInt(JSON.parse(message).id, 10);
const title = filter(SKILL_TREE_DATA, { id: skillId })[0].title;
Actions.skillDetail({ skillId, title });
};
render = () => {
let source;
if (__DEV__) {
source = require('./www/index.html');
} else {
source = Platform.OS === 'ios' ? require('./www/index.html') : { uri: 'file:///android_asset/skilltree/index.html' };
}
return (
<WebView
ref={(webview) => {
this.webview = webview;
}}
scalesPageToFit
startInLoadingState
onMessage={this.handleMessage}
source={source}
automaticallyAdjustContentInsets={false}
style={[AppStyles.container, styles.container]}
injectedJavaScript=""
onNavigationStateChange={this.onNavigationStateChange}
/>
);
}
}
export default SkillTree;
|
src/index.js
|
kgosse/productapp
|
require('./styles/main.scss');
import React from 'react';
import ReactDOM from 'react-dom';
import App from './components/App';
ReactDOM.render(<App />, document.getElementById('root'));
|
src/svg-icons/action/assignment-return.js
|
manchesergit/material-ui
|
import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let ActionAssignmentReturn = (props) => (
<SvgIcon {...props}>
<path d="M19 3h-4.18C14.4 1.84 13.3 1 12 1c-1.3 0-2.4.84-2.82 2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-7 0c.55 0 1 .45 1 1s-.45 1-1 1-1-.45-1-1 .45-1 1-1zm4 12h-4v3l-5-5 5-5v3h4v4z"/>
</SvgIcon>
);
ActionAssignmentReturn = pure(ActionAssignmentReturn);
ActionAssignmentReturn.displayName = 'ActionAssignmentReturn';
ActionAssignmentReturn.muiName = 'SvgIcon';
export default ActionAssignmentReturn;
|
src/components/Match/Scoreboards/index.js
|
fooey/gw2w2w-cra
|
import React, { Component } from 'react';
import { Link } from 'react-router-dom';
import _ from 'lodash';
import classnames from 'classnames';
import numeral from 'numeral';
// import Card from 'src/components/Layout/Card';
import { getWorldBySlug, getWorld, getWorldLink } from 'src/lib/world';
// import { getTeamColor } from 'src/lib/match';
class Scoreboards extends Component {
render() {
const { match, langSlug, worldSlug } = this.props;
const matchWorld = getWorldBySlug(worldSlug);
// const teamColor = getTeamColor(match.all_worlds, world.id);
return (
<div className="match-scoreboards level-1">
{_.map(['red', 'blue', 'green'], color => (
<Scoreboard
key={color}
color={color}
langSlug={langSlug}
match={match}
matchWorld={matchWorld}
worldSlug={langSlug}
/>
))}
</div>
);
}
}
class Scoreboard extends Component {
render() {
const {
color,
langSlug,
match,
matchWorld,
// worldSlug,
} = this.props;
const worldId = _.get(match.worlds, `${color}_id`);
const world = getWorld(worldId);
const allWorldIds = _.without(_.get(match.all_worlds, `${color}_ids`), worldId);
const score = _.get(match, ['scores', color]);
const classes = classnames({
"match-scoreboard": true,
active: world.id === matchWorld.id,
[`team-${color}`]: true,
// [`team-${color}-bg`]: true,
});
return (
<div className={classes}>
<h2 className={``}>
<Link to={getWorldLink(world, langSlug)} className={`team-${color}`}>
{_.get(world, [langSlug, 'name'])}
</Link>
</h2>
<h3 key={worldId} className={``}>
{_.map(allWorldIds, worldId => {
const world = getWorld(worldId);
return (
<Link key={worldId} to={getWorldLink(world, langSlug)} className={`team-${color}`}>
{_.get(world, [langSlug, 'name'])}
</Link>
);
})}
</h3>
<div className='team-score'>
{numeral(score).format('0,0')}
</div>
</div>
);
}
}
export default Scoreboards;
|
client/views/admin/apps/CloudLoginModal.js
|
VoiSmart/Rocket.Chat
|
import { Button, ButtonGroup, Icon, Modal } from '@rocket.chat/fuselage';
import React from 'react';
import { useSetModal } from '../../../contexts/ModalContext';
import { useRoute } from '../../../contexts/RouterContext';
import { useTranslation } from '../../../contexts/TranslationContext';
const CloudLoginModal = (props) => {
const t = useTranslation();
const setModal = useSetModal();
const cloudRoute = useRoute('cloud');
const handleCloseButtonClick = () => {
setModal(null);
};
const handleCancelButtonClick = () => {
setModal(null);
};
const handleLoginButtonClick = () => {
cloudRoute.push();
setModal(null);
};
return (
<Modal {...props}>
<Modal.Header>
<Icon color='danger' name='info-circled' size={20} />
<Modal.Title>{t('Apps_Marketplace_Login_Required_Title')}</Modal.Title>
<Modal.Close onClick={handleCloseButtonClick} />
</Modal.Header>
<Modal.Content fontScale='p1'>
{t('Apps_Marketplace_Login_Required_Description')}
</Modal.Content>
<Modal.Footer>
<ButtonGroup align='end'>
<Button ghost onClick={handleCancelButtonClick}>
{t('Cancel')}
</Button>
<Button primary danger onClick={handleLoginButtonClick}>
{t('Login')}
</Button>
</ButtonGroup>
</Modal.Footer>
</Modal>
);
};
export default CloudLoginModal;
|
examples/todomvc/containers/Root.js
|
jlongster/redux
|
import React, { Component } from 'react';
import TodoApp from './TodoApp';
import { createStore, combineReducers } from 'redux';
import { Provider } from 'react-redux';
import rootReducer from '../reducers';
const store = createStore(rootReducer);
export default class Root extends Component {
render() {
return (
<Provider store={store}>
{() => <TodoApp /> }
</Provider>
);
}
}
|
src/components/bet/BetFormModal.js
|
itjope/tipskampen
|
import React from 'react'
import Dialog from 'material-ui/Dialog'
import FlatButton from 'material-ui/FlatButton'
const BetFormModal = (props) => {
const actions = [
<FlatButton
label='Cancel'
secondary={true}
onTouchTap={props.onCancel}
/>,
<FlatButton
label='Save'
primary={true}
onTouchTap={props.onSave}
/>
]
return <Dialog
actions={actions}
modal={true}
contentStyle={{width: 330, minHeight: 700}}
autoScrollBodyContent={true}
// autoDetectWindowHeight={false}
open={props.open}
>
{props.children}
</Dialog>
}
BetFormModal.propTypes = {
open: React.PropTypes.bool.isRequired,
onCancel: React.PropTypes.func.isRequired,
onSave: React.PropTypes.func.isRequired,
children: React.PropTypes.element.isRequired
}
export default BetFormModal
|
src/components/Signin.js
|
ihenvyr/react-parse
|
import React from 'react';
import Form from './Form';
import Input from './Input';
import Button from './Button';
import Parse from 'parse';
import { withRouter } from 'react-router';
const Signin = ({ router }) => {
const handleSubmit = (event) => {
event.preventDefault();
const { username, password } = event.target;
Parse.User.logIn(username.value, password.value, {
success: (user) => router.push('/'),
error: (user, error) => console.log(`Error: ${error.code} ${error.message}`),
});
};
return (
<Form onSubmit={handleSubmit}>
<h3>Sign In</h3>
<p><Input name="username" type="text" placeholder="Username" required/></p>
<p><Input name="password" type="password" placeholder="Password" required/></p>
<Button type="submit" primary>Sign In</Button>
</Form>
);
};
Signin.propTypes = {};
Signin.defaultProps = {};
export default withRouter(Signin);
|
app/components/Navbar/NavDropdownDivider/index.js
|
josueorozco/parlay
|
import React from 'react';
import classNames from 'classnames';
/*
|--------------------------------------------------------------------------
| NavDropdownDivider
|--------------------------------------------------------------------------
|
| Stateless component
|
*/
const NavDropdownDivider = () => (
<div
className={classNames(
'dropdown-divider',
)}
/>
);
export default NavDropdownDivider;
|
client/app/containers/FeaturePage/index.js
|
jjt/ffsssshh
|
/*
* FeaturePage
*
* List all the features
*/
import React from 'react';
import { connect } from 'react-redux';
import { routeActions } from 'react-router-redux';
import Button from 'Button';
import H1 from 'H1';
import A from 'A';
import styles from './styles.css';
class FeaturePage extends React.Component {
constructor() {
super();
this.onChangeRoute = this.onChangeRoute.bind(this);
this.changeRouteToHome = this.changeRouteToHome.bind(this);
}
onChangeRoute(url) {
this.props.changeRoute(url);
}
changeRouteToHome() {
this.onChangeRoute('/');
}
render() {
return (
<div>
<H1>Features</H1>
<ul className={ styles.list }>
<li className={ styles.listItem }>
<p>Using <A href="https://github.com/gaearon/react-transform-hmr"><strong>react-transform-hmr</strong></A>, your changes in the CSS and JS get reflected in the app instantly without refreshing the page. That means that the <strong>current application state persists</strong> even when you change something in the underlying code! For a very good explanation and demo watch Dan Abramov himself <A href="https://www.youtube.com/watch?v=xsSnOQynTHs">talking about it at react-europe</A>.</p>
</li>
<li className={ styles.listItem }>
<p><A href="https://github.com/gaearon/redux"><strong>Redux</strong></A> is a much better implementation of a fluxโlike, unidirectional data flow. Redux makes actions composable, reduces the boilerplate code and makes hotโreloading possible in the first place. For a good overview of redux check out the talk linked above or the <A href="https://gaearon.github.io/redux/">official documentation</A>!</p>
</li>
<li className={ styles.listItem }>
<p><A href="https://github.com/postcss/postcss"><strong>PostCSS</strong></A> is like Sass, but modular and capable of much more. PostCSS is, in essence, just a wrapper for plugins which exposes an easy to use, but very powerful API. While it is possible to <A href="https://github.com/jonathantneal/precss">replicate Sass features</A> with PostCSS, PostCSS has an <A href="http://postcss.parts">ecosystem of amazing plugins</A> with functionalities Sass cannot even dream about having.</p>
</li>
<li className={ styles.listItem }>
<p><strong>Unit tests</strong> should be an important part of every web application developers toolchain. <A href="https://github.com/mochajs/mocha">Mocha</A> checks your application is working exactly how it should without you lifting a single finger. Congratulations, you just won a First Class ticket to world domaination, fasten your seat belt please!</p>
</li>
<li className={ styles.listItem }>
<p><A href="https://github.com/rackt/react-router"><strong>react-router</strong></A> is used for routing in this boilerplate. react-router makes routing really easy to do and takes care of a lot of the work.</p>
</li>
<li className={ styles.listItem }>
<p><A href="http://www.html5rocks.com/en/tutorials/service-worker/introduction/"><strong>ServiceWorker</strong></A> and <A href="http://www.html5rocks.com/en/tutorials/appcache/beginner/"><strong>AppCache</strong></A> make it possible to use the application offline. As soon as the website has been opened once, it is cached and available without a network connection. <A href="https://developer.chrome.com/multidevice/android/installtohomescreen"><strong><code className={ styles.code }>manifest.json</code></strong></A> is specifically for Chrome on Android. Users can add the website to the homescreen and use it like a native app!</p>
</li>
</ul>
<Button handleRoute= { this.changeRouteToHome } >Home</Button>
</div>
);
}
}
function mapStateToProps(state) {
return {
location: state.get('route').location
};
}
function mapDispatchToProps(dispatch) {
return {
changeRoute: (url) => dispatch(routeActions.push(url))
};
}
export default connect(mapStateToProps, mapDispatchToProps)(FeaturePage);
|
src/svg-icons/notification/live-tv.js
|
hwo411/material-ui
|
import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let NotificationLiveTv = (props) => (
<SvgIcon {...props}>
<path d="M21 6h-7.59l3.29-3.29L16 2l-4 4-4-4-.71.71L10.59 6H3c-1.1 0-2 .89-2 2v12c0 1.1.9 2 2 2h18c1.1 0 2-.9 2-2V8c0-1.11-.9-2-2-2zm0 14H3V8h18v12zM9 10v8l7-4z"/>
</SvgIcon>
);
NotificationLiveTv = pure(NotificationLiveTv);
NotificationLiveTv.displayName = 'NotificationLiveTv';
NotificationLiveTv.muiName = 'SvgIcon';
export default NotificationLiveTv;
|
components/Layout.js
|
Hardyng/weatherforecast-nextjs-redux-ssr
|
import React from 'react';
import cx from 'classnames';
import styled from 'styled-components';
// background-image: url('http://www.sciencemag.org/sites/default/files/styles/article_main_medium/public/images/ss-bird_honeycreeper.jpg?itok=eEm6TBrb');
import Header from './Header';
const Container = styled.div`
background-size: cover;
`;
const Grid = styled.div`
max-width: 1000px;
`
class Layout extends React.Component {
render() {
return (
<Container className='mdl-layout__container'>
<div className="mdl-layout mdl-js-layout mdl-layout--fixed-header">
<Header loading={this.props.loading}></Header>
<main className="mdl-layout__content">
<Grid className="mdl-grid">
{this.props.children}
</Grid>
</main>
</div>
</Container>
)
}
}
export default Layout
|
src/stretchView.js
|
guoyuan94/react-native-stretchview
|
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import {
StyleSheet,
View,
Animated,
} from 'react-native';
const styles = StyleSheet.create({
container: {
flex: 1,
},
});
export default class StretchView extends Component {
constructor(props, context) {
super(props, context);
this.state = {
animateHeight: new Animated.Value(0),
};
}
componentWillMount() {
this.stretch = this.stretch.bind(this);
}
componentWillReceiveProps(nextProps) {
const { expanded } = this.props;
if (nextProps.expanded !== expanded) {
this.stretch(nextProps.expanded);
}
}
stretch(expanded) {
const {
stretchDuration,
animateDistance,
onAnimationStart,
syncAnimations,
onAnimationEnd,
} = this.props;
const { animateHeight } = this.state;
const duration = stretchDuration;
const toValue = expanded ? animateDistance : 0;
if (onAnimationStart) {
onAnimationStart();
}
let animations = [
Animated.timing(animateHeight, {
toValue,
duration,
}),
];
if (syncAnimations) {
animations = animations.concat(syncAnimations());
}
Animated.parallel(animations).start();
if (onAnimationEnd) {
onAnimationEnd(duration, toValue);
}
}
render() {
const {
expanded,
renderTopFace,
renderBottomFace,
} = this.props;
const { animateHeight } = this.state;
const pointerEvents = expanded ? 'box-none' : 'auto';
return (
<View style={styles.container}>
{
renderTopFace()
}
<Animated.View
style={{
height: animateHeight,
overflow: 'hidden',
}}
pointerEvents={pointerEvents}
>
{
renderBottomFace()
}
</Animated.View>
</View>
);
}
}
StretchView.propTypes = {
stretchDuration: PropTypes.number,
renderTopFace: PropTypes.func.isRequired,
renderBottomFace: PropTypes.func.isRequired,
animateDistance: PropTypes.number.isRequired,
expanded: PropTypes.bool.isRequired,
onAnimationEnd: PropTypes.func,
onAnimationStart: PropTypes.func,
syncAnimations: PropTypes.func,
};
StretchView.defaultProps = {
stretchDuration: 250,
};
|
app/components/Main.js
|
luongthomas/React-Portfolio
|
import React from 'react';
import ReactCSSTtransitionGroup from 'react-addons-css-transition-group';
// we can do this syntax because of webpack loaders
import '../main.css';
// Key from react router. CloneElement lets us attach a key to the "would-be component"
// , aka new props
// React keeps track of keys (order) or a list of items and their orders
// ReactCSSTtransitionGroup needs its children to have keys
const Main = React.createClass({
render() {
return (
<div className='main-container'>
<ReactCSSTtransitionGroup
transitionName="appear"
transitionEnterTimeout={500}
transitionLeaveTimeout={500}>
{ React.cloneElement(this.props.children, { key: this.props.location.pathname })}
</ReactCSSTtransitionGroup>
</div>
);
},
});
export default Main;
|
client/src/components/Task/TaskStepBaseClass.js
|
DemocracyGuardians/DGTeam
|
import React from 'react';
import PropTypes from 'prop-types'
class TaskStepBaseClass extends React.Component {
render() {
return (<span></span>)
}
}
TaskStepBaseClass.propTypes = {
store: PropTypes.object.isRequired,
content: PropTypes.oneOfType([PropTypes.string, PropTypes.object]).isRequired,
onStepComplete: PropTypes.func.isRequired,
onRevertProgress: PropTypes.func.isRequired,
hideShowWizardNavigation: PropTypes.func.isRequired
}
export default TaskStepBaseClass;
|
__tests__/LaunchScreen.js
|
fridl8/cold-bacon-client
|
import 'react-native';
import React from 'react';
import LaunchScreen from '../containers/LaunchScreen';
import renderer from 'react-test-renderer';
it('renders correctly', () => {
const tree = renderer.create(<LaunchScreen />).toJSON();
expect(tree).toMatchSnapshot();
});
|
powerpiapp/elements/common/Header.js
|
Knapsacks/power-pi-v2
|
// import library
import React from 'react';
import { Text, View } from 'react-native';
// create a component
const Header = (props) => {
const { textStyle, viewStyle } = styles;
return (
<View style={viewStyle}>
<Text style={textStyle}>{props.headerText}</Text>
</View>
);
};
const styles = {
viewStyle: {
backgroundColor: '#FDFFFC',
alignItems: 'center',
padding: 15,
marginTop: 25,
elevation: 10,
position: 'relative',
},
textStyle: {
fontSize: 20,
color: '#011627',
fontWeight: 'bold'
}
};
// make component available to other part of apps
export { Header };
|
src/components/Datepicker/Date.js
|
wiki1024/sam-bs
|
import React from 'react'
import classnames from 'classnames'
const Date = (props) => {
let {id, date, month, selectDate, selected} = props
let classes = classnames('date', {
'current': date.month() === month,
'future': date.month() > month,
'past': date.month() < month,
'selected': (date.date() === selected.date() && date.month() === selected.month() && date.year() === selected.year()),
})
return (
<div
className={classes}
onClick={ (e)=> { selectDate({id:id,val:date});e.stopPropagation() } }>
{date.date()}
</div>
)
}
export default Date
|
src/List/List.js
|
abouthiroppy/scuba
|
// @flow
import type { CommonProps } from '../CommonTypes';
import React from 'react';
import classnames from 'classnames';
import excludeProps from '../utils/excludeProps';
import styles from './style';
type Props= {
type: 'none' | 'circle' | 'square' | 'decimal';
};
const List = (props: CommonProps & Props) => (
<ul
{...excludeProps(props, ['type'])}
style={Object.assign(styles.ul, { listStyleType: props.type }, props.style)}
className={classnames('scuba-list', props.className)}
>
{props.children}
</ul>
);
export default List;
|
src/CheckboxGroup/test/CheckboxGroupSpec.js
|
suitejs/suite
|
import React from 'react';
import ReactTestUtils from 'react-dom/test-utils';
import { getDOMNode } from '@test/testUtils';
import CheckboxGroup from '../CheckboxGroup';
import Checkbox from '../../Checkbox';
import { globalKey } from '../../utils/prefix';
describe('CheckboxGroup', () => {
it('Should render a checkbox group', () => {
const instance = getDOMNode(
<CheckboxGroup>
<Checkbox>Test1</Checkbox>
<Checkbox>Test2</Checkbox>
</CheckboxGroup>
);
assert.equal(instance.querySelectorAll(`.${globalKey}checkbox`).length, 2);
});
it('Should have a name in input', () => {
const name = 'Test';
const instance = getDOMNode(
<CheckboxGroup name={name}>
<Checkbox>Test1</Checkbox>
<Checkbox>Test2</Checkbox>
</CheckboxGroup>
);
assert.equal(instance.querySelectorAll('input[name="Test"]').length, 2);
});
it('Should have `checkbox-inline` className in checkbox', () => {
const instance = getDOMNode(
<CheckboxGroup inline>
<Checkbox>Test1</Checkbox>
<Checkbox>Test2</Checkbox>
</CheckboxGroup>
);
assert.equal(instance.querySelectorAll(`.${globalKey}checkbox-inline`).length, 2);
});
it('Should output a h1', () => {
const instance = getDOMNode(
<CheckboxGroup inline>
<h1>Group</h1>
<Checkbox>Test1</Checkbox>
</CheckboxGroup>
);
assert.ok(instance.querySelectorAll('.h1'));
});
it('Should be checked when set value', () => {
const instance = getDOMNode(
<CheckboxGroup value={[2, 4, '1']}>
<Checkbox value={1}>Test1</Checkbox>
<Checkbox value={2}>Test2</Checkbox>
<Checkbox value={3}>Test2</Checkbox>
<Checkbox value={4}>Test2</Checkbox>
</CheckboxGroup>
);
const checkboxs = instance.querySelectorAll(`.${globalKey}checkbox`);
const checked = /\bcheckbox-checked\b/;
assert.ok(!checkboxs[0].className.match(checked));
assert.ok(!checkboxs[2].className.match(checked));
assert.ok(checkboxs[1].className.match(checked));
assert.ok(checkboxs[3].className.match(checked));
});
it('Should be checked when set defaultValue', () => {
const instance = getDOMNode(
<CheckboxGroup defaultValue={[2, 4, '1']}>
<Checkbox value={1}>Test1</Checkbox>
<Checkbox value={2}>Test2</Checkbox>
<Checkbox value={3}>Test2</Checkbox>
<Checkbox value={4}>Test2</Checkbox>
</CheckboxGroup>
);
const checkboxs = instance.querySelectorAll(`.${globalKey}checkbox`);
const checked = /\bcheckbox-checked\b/;
assert.ok(!checkboxs[0].className.match(checked));
assert.ok(!checkboxs[2].className.match(checked));
assert.ok(checkboxs[1].className.match(checked));
assert.ok(checkboxs[3].className.match(checked));
});
it('Should call onChange callback', done => {
const instance = getDOMNode(
<CheckboxGroup
onChange={value => {
if (value.length === 1 && value[0] === 3) {
done();
}
}}
>
<Checkbox value={1}>Test1</Checkbox>
<Checkbox value={2}>Test2</Checkbox>
<Checkbox value={3}>Test2</Checkbox>
<Checkbox value={4}>Test2</Checkbox>
</CheckboxGroup>
);
const checkboxs = instance.querySelectorAll(`.${globalKey}checkbox`);
ReactTestUtils.Simulate.change(checkboxs[2].querySelector('input'));
});
it('Should call onChange callback', done => {
let count = 0;
function onDone() {
count++;
if (count === 2) {
done();
}
}
const instance = getDOMNode(
<CheckboxGroup onChange={onDone}>
<Checkbox value={1}>Test1</Checkbox>
<Checkbox value={2}>Test2</Checkbox>
<Checkbox value={3} onChange={onDone}>
Test2
</Checkbox>
<Checkbox value={4}>Test2</Checkbox>
</CheckboxGroup>
);
const checkboxs = instance.querySelectorAll(`.${globalKey}checkbox`);
ReactTestUtils.Simulate.change(checkboxs[2].querySelector('input'));
});
it('Should have a custom className', () => {
const instance = getDOMNode(<CheckboxGroup className="custom" />);
assert.include(instance.className, 'custom');
});
it('Should have a custom style', () => {
const fontSize = '12px';
const instance = getDOMNode(<CheckboxGroup style={{ fontSize }} />);
assert.equal(instance.style.fontSize, fontSize);
});
it('Should have a custom className prefix', () => {
const instance = getDOMNode(<CheckboxGroup classPrefix="custom-prefix" />);
assert.ok(instance.className.match(/\bcustom-prefix\b/));
});
});
|
src/Card/__tests__/CardTitle-test.js
|
react-mdl/react-mdl
|
/* eslint-env mocha */
import chai, { expect } from 'chai';
import chaiEnzyme from 'chai-enzyme';
import { shallow } from 'enzyme';
import React from 'react';
import { CardTitle } from '../';
chai.use(chaiEnzyme());
describe('CardTitle', () => {
it('should render a div with the title css class', () => {
const wrapper = shallow(<CardTitle />);
expect(wrapper).to.have.tagName('div');
expect(wrapper).to.have.className('mdl-card__title');
});
it('should allow custom css classes', () => {
const wrapper = shallow(<CardTitle className="my-title" />);
expect(wrapper).to.have.className('mdl-card__title');
expect(wrapper).to.have.className('my-title');
});
it('should not expand by default', () => {
const wrapper = shallow(<CardTitle />);
expect(wrapper).to.not.have.className('mdl-card--expand');
});
it('should expand when specified', () => {
const wrapper = shallow(<CardTitle expand />);
expect(wrapper).to.have.className('mdl-card--expand');
});
it('should render the title in the default <h2>', () => {
const wrapper = shallow(<CardTitle>My Title</CardTitle>);
expect(wrapper).to.contain(
<h2 className="mdl-card__title-text">My Title</h2>
);
});
it('should render custom complex title', () => {
const wrapper = shallow(<CardTitle><h4>My Title</h4></CardTitle>);
expect(wrapper).to.contain(
<h4>My Title</h4>
);
});
});
|
src/encoded/static/components/form.js
|
T2DREAM/t2dream-portal
|
/* eslint-disable jsx-a11y/label-has-for */
import React from 'react';
import PropTypes from 'prop-types';
import jsonschema from 'jsonschema';
import _ from 'underscore';
import offset from '../libs/offset';
import { FetchedData, Param } from './fetched';
import { parseAndLogError, listingTitles } from './globals';
import { FileInput, ItemPreview, ObjectPicker } from './inputs';
import Layout from './layout';
import DropdownButton from '../libs/bootstrap/button';
import { DropdownMenu } from '../libs/bootstrap/dropdown-menu';
const validator = new jsonschema.Validator();
// Add validator for regex patterns in our schemas
validator.attributes.pattern = function validatePattern(instance, schema) {
let error;
if (typeof instance === 'string') {
if (typeof schema.pattern !== 'string') throw new jsonschema.SchemaError('"pattern" expects a string', schema);
if (!instance.match(schema.pattern)) {
error = `does not match pattern ${JSON.stringify(schema.pattern)}`;
}
}
return error;
};
// Parse object and property from `linkFrom`.
// Backrefs have a linkFrom property in the form
// (object type).(property name)
const parseLinkFrom = function parseLinkFrom(linkFrom) {
const parts = linkFrom.split('.');
return {
type: parts[0],
prop: parts[1],
};
};
// Validate `linkFrom`
validator.attributes.linkFrom = function validateLinkFrom(instance, schema, options, ctx) {
let result;
if (instance !== undefined && instance instanceof Object) {
const linkFrom = parseLinkFrom(schema.linkFrom);
const types = instance['@type'];
if (!_.contains(types, linkFrom.type)) {
result = `expected object of type ${linkFrom.type}`;
}
const subschema = options.schemas[types[0]];
result = this.attributes.properties.call(this, instance, subschema, options, ctx);
}
return result;
};
// Recursively filter an object to remove calculated properties
// (`schema_version`).
// This is used before sending the value to the server.
const filterValue = function filterValue(value) {
let result;
if (Array.isArray(value)) {
result = value.map(filterValue);
} else if (typeof value === 'object') {
result = {};
_.each(value, (v, k) => {
if (k === '@type') {
// We're not allowed to change an existing item's @type
// but the server needs to know it for new items.
if (!value['@id']) {
result['@type'] = v;
}
} else if (k === 'layout') {
// Avoid filtering out @type from layout blocks
result[k] = v;
} else if (k !== 'schema_version') {
result[k] = filterValue(v);
}
});
} else {
result = value;
}
return result;
};
// Given a schema, construct a default object.
// The default object includes the `default` value
// for any property that defines one,
// with the exception of read-only and non-submittable properties.
const defaultValue = function defaultValue(schema) {
if (schema.default !== undefined) {
return schema.default !== undefined ? schema.default : undefined;
} else if (schema.properties !== undefined) {
const value = {};
_.each(schema.properties, (property, name) => {
if (property.notSubmittable) return;
if (!property.readonly) {
const propertyDefault = defaultValue(property);
if (propertyDefault !== undefined) {
value[name] = propertyDefault;
}
}
});
return (Object.keys(value).length ? value : undefined);
}
return schema.default || undefined;
};
const UpdateChildMixin = superclass => class extends superclass {
updateChild(name, subvalue) {
// This is the workhorse for passing for field updates
// up the hierarchy of form fields.
// It constructs a new value for the current element
// by replacing the value of one of its children,
// then propagates the new value to its parent.
const schema = this.props.schema;
let oldValue = this.props.value;
let newValue;
if (schema.type === 'object') {
// Clone the old value so we don't mutate it
newValue = Object.assign({}, oldValue);
// Set the new value unless it is undefined
if (subvalue !== undefined) {
newValue[name] = subvalue;
} else if (newValue[name] !== undefined) {
delete newValue[name];
}
} else if (schema.type === 'array') {
// Construct the old value using slices of the old
// so we don't mutate it
oldValue = oldValue || [];
newValue = oldValue.slice(0, name).concat(subvalue).concat(oldValue.slice(name + 1));
}
// Pass the new value to the parent
this.props.updateChild(this.props.name, newValue);
}
};
class RepeatingItem extends React.Component {
// A form field for editing one item in an array
// (part of a RepeatingFieldset).
// It delegates rendering the field to an actual Field component,
// but also shows a button to remove the item.
constructor() {
super();
// Bind `this` to non-React methods.
this.handleRemove = this.handleRemove.bind(this);
this.updateChild = this.updateChild.bind(this);
}
handleRemove(e) {
// Called when the remove button is clicked.
e.preventDefault();
// eslint-disable-next-line no-alert
if (!confirm('Are you sure you want to remove this item?')) {
return;
}
if (this.props.onRemove) {
this.props.onRemove(this.props.name);
}
}
updateChild(name, value) {
// When the contained field value is updated,
// tell our parent RepeatingFieldset to update the correct index.
this.props.updateChild(this.props.name, value);
}
render() {
const { path, schema, value } = this.props;
return (
<div className="rf-RepeatingFieldset__item">
<Field
path={path} schema={schema}
value={value} updateChild={this.updateChild}
hideLabel
/>
{!this.context.readonly ?
<button
onClick={this.handleRemove}
type="button"
className="rf-RepeatingFieldset__remove"
>×</button>
: ''}
</div>
);
}
}
RepeatingItem.propTypes = {
name: PropTypes.number,
path: PropTypes.string,
schema: PropTypes.object,
onRemove: PropTypes.func,
value: PropTypes.any,
updateChild: PropTypes.func.isRequired,
};
RepeatingItem.defaultProps = {
name: '',
path: '',
schema: {},
onRemove: null,
value: null,
};
RepeatingItem.contextTypes = {
readonly: PropTypes.bool,
};
class RepeatingFieldset extends UpdateChildMixin(React.Component) {
// A form field for editing an array.
// Each item in the array is rendered via RepeatingItem.
// Also shows a button to add a new item.
constructor() {
super();
// Counter which is incremented every time an item is removed.
// This is used as part of the React key for contained RepeatingItems
// to make sure that we re-render all items after one is removed.
// After a removal the same array index may point to a different
// item, so it's not safe to use the array index alone as the key.
this.state = { generation: 0 };
// Bind `this` to non-React methods.
this.onRemove = this.onRemove.bind(this);
this.handleAdd = this.handleAdd.bind(this);
this.updateChild = this.updateChild.bind(this);
}
onRemove(index) {
// Called when a contained RepeatingItem is removed.
// Remove the specified index from the current value.
const oldValue = this.props.value;
let value = oldValue.slice(0, index).concat(oldValue.slice(index + 1));
if (value.length === 0) {
value = undefined;
}
// Increment `this.state.generation` (see explanation in getInitialState)
this.setState({ generation: this.state.generation + 1 });
// Pass the new value for the entire array to parent
this.props.updateChild(this.props.name, value);
}
handleAdd(e) {
// Called when the add button is clicked.
e.preventDefault();
const schema = this.props.schema;
const subtype = e.target.getAttribute('data-subtype');
let newValue;
if (subtype) {
// Construct a child object.
// It needs a reference back to the parent object.
const subschema = this.context.schemas[subtype];
newValue = defaultValue(subschema);
newValue['@type'] = [subtype];
const linkFrom = parseLinkFrom(schema.items.linkFrom);
if (subschema.properties[linkFrom.prop].type === 'array') {
newValue[linkFrom.prop] = [this.context.id];
} else {
newValue[linkFrom.prop] = this.context.id;
}
} else {
// Simple subitem; construct default value from schema;
newValue = defaultValue(schema.items);
}
// Add the new subitem to the end of the array.
const value = (this.props.value || []).concat(newValue);
// Pass the new value for the entire array to parent
this.props.updateChild(this.props.name, value);
}
render() {
const { path, value, schema } = this.props;
const schemas = this.context.schemas;
const linkFrom = schema.items.linkFrom;
const subtypes = linkFrom ? schemas._subtypes[parseLinkFrom(linkFrom).type] : [];
let button = null;
if (!this.context.readonly) {
if (subtypes.length > 1) {
button = (
<DropdownButton title="Add" buttonClasses="rf-RepeatingFieldset__add">
<DropdownMenu>
{subtypes.map(subtype =>
<a
href="#" key={subtype}
data-subtype={subtype}
onClick={this.handleAdd}
>{schemas[subtype].title}</a>)}
</DropdownMenu>
</DropdownButton>
);
} else {
button = (
<button
type="button"
onClick={this.handleAdd}
data-subtype={subtypes.length === 1 ? subtypes[0] : null}
className="rf-RepeatingFieldset__add"
>Add</button>
);
}
}
return (
<div>
<div className="rf-RepeatingFieldset__items">
{value ? value.map((subvalue, key) => {
const props = {
key: `${this.state.generation}.${key}`,
name: key,
path: `${path}.${key}`,
value: subvalue,
schema: schema.items,
updateChild: this.updateChild,
onRemove: this.onRemove,
};
return <RepeatingItem {...props} />;
}) : ''}
</div>
{button}
</div>
);
}
}
RepeatingFieldset.propTypes = {
schema: PropTypes.object,
name: PropTypes.string,
path: PropTypes.string,
value: PropTypes.any,
updateChild: PropTypes.func,
};
RepeatingFieldset.contextTypes = {
schemas: PropTypes.object,
readonly: PropTypes.bool,
id: PropTypes.string,
};
class ObjectField extends React.Component {
// Wrapper to determine which schema to use for an object,
// then render a Field with that schema. Used after ChildObject
// fetches a child object from the server.
render() {
const type = this.props.value['@type'][0];
const schema = this.context.schemas[type];
return <Field {...this.props} schema={schema} />;
}
}
ObjectField.propTypes = {
value: PropTypes.any,
};
ObjectField.defaultProps = {
value: null,
};
ObjectField.contextTypes = {
schemas: PropTypes.object,
};
class ChildObject extends React.Component {
// A form field for editing a child object
// (a subitem of an array property using linkFrom).
// Initially the value is a URI and we render a preview of the object.
// If the user expands the item we fetch its form frame and render form fields.
// If the user updates any fields the new value is the updated object
// rather than just the URI.
constructor(props, context) {
super(props);
const value = this.props.value;
const error = context.errors[this.props.path];
const url = typeof value === 'string' ? value : null;
this.state = {
url,
// Start collapsed for existing children,
// expanded when adding a new one or if there are errors
collapsed: url && !error,
};
// Bind `this` to non-React methods.
this.toggleCollapsed = this.toggleCollapsed.bind(this);
this.updateChild = this.updateChild.bind(this);
}
toggleCollapsed() {
// Toggle collapsed state when collapsible trigger is clicked.
this.setState({ collapsed: !this.state.collapsed });
}
updateChild(name, value) {
// Pass new value up to our parent.
if (this.state.url) {
value['@id'] = this.state.url;
}
this.props.updateChild(this.props.name, value);
}
render() {
const { path, value } = this.props;
let preview;
let fieldset;
if (this.state.url) {
// We have a URI for an existing object.
const previewUrl = this.state.url;
// When collapsed, fetch the object and render it using ItemPreview.
preview = (
<FetchedData>
<Param name="data" url={previewUrl} />
<ItemPreview />
</FetchedData>
);
// When expanded, fetch the form frame and render form fields.
if (typeof value === 'string') {
fieldset = (
<FetchedData>
<Param name="value" url={`${this.state.url}?frame=form`} />
<ObjectField path={path} updateChild={this.updateChild} />
</FetchedData>
);
} else {
fieldset = <ObjectField path={path} value={value} updateChild={this.updateChild} />;
}
} else {
// We don't have a URI yet (it's a new object).
// When collapsed, render a placeholder.
const schema = this.context.schemas[value['@type'][0]];
preview = (
<ul className="nav result-table">
<li>
<div className="accession">{`New ${schema.title}`}</div>
</li>
</ul>
);
// When expanded, render form fields (but there's no form frame to fetch)
fieldset = (<ObjectField
path={path} value={value} updateChild={this.updateChild}
/>);
}
return (
<div className="collapsible">
<button
type="button" className="collapsible-trigger"
onClick={this.toggleCollapsed}
>{this.state.collapsed ? 'โถ ' : 'โผ '}</button>
{this.state.collapsed ? preview : fieldset}
</div>
);
}
}
ChildObject.propTypes = {
name: PropTypes.any,
path: PropTypes.string,
value: PropTypes.any,
updateChild: PropTypes.func.isRequired,
};
ChildObject.defaultProps = {
name: null,
path: '',
value: null,
};
ChildObject.contextTypes = {
schemas: PropTypes.object,
errors: PropTypes.object,
};
ChildObject.childContextTypes = {
id: PropTypes.string,
};
export class Field extends UpdateChildMixin(React.Component) {
// Build form input components based on a JSON schema
// (or a portion thereof).
// An entire form is comprised of a hierarchy of Field components;
// each field propagates updates to its parent (via the `updateChild` prop)
// until it reaches the Form itself.
// For each field we render a label (from the schema `title` and `description`),
// any validation error messages, and the input itself.
// The Field determines what kind of input to render based on the schema:
// - `type: 'object'`: Renders a separate sub-Field for each object property
// except `uuid`, `schema_version`, and computed properties.
// - `type: 'array'`: Renders using `RepeatingFieldset`.
// - `type: 'boolean'`: Renders an HTML checkbox `input` element.
// - `type: 'integer' or 'number'`: Renders an HTML number `input` elemtn.
// - schema with `enum`: Renders an HTML `select` element.
// - schema with `linkTo`: Renders an `ObjectPicker` for searching and selecting other objects.
// - schema with `linkFrom`: Renders using `ChildObject`.
// - schema with `formInput: 'file'`: Renders a `FileInput` to handle file uploads.
// - schema with `formInput: 'textarea`: Renders an HTML `textarea` element.
// - schema with `formInput: 'layout'`: Renders a `Layout` for drag-and-drop placement of content blocks.
// - anything else with `type: 'string'`: Renders an HTML text `input` element.
// - Custom form inputs for particular properties can be specified in the schema's `formInput` property.
// If the schema (or the schema for any parent field) has `readonly: true`,
// the input is disabled and the field value cannot be edited.
constructor() {
super();
// Set intial React state.
this.state = { isDirty: false };
// Bind `this` to non-React methods.
this.handleChange = this.handleChange.bind(this);
this.updateChild = this.updateChild.bind(this);
}
getChildContext() {
// Allow contained fields to tell whether they are inside a readonly field.
return { readonly: !!(this.context.readonly || this.props.schema.readonly) };
}
// Don't update when state is changed.
// (Without this, the update to isDirty from handleChange causes
// the input to re-render before the new value prop has propagated
// from the parent, causing the cursor position to be lost.
// See https://github.com/facebook/react/issues/955)
// This should be safe as long as Field's state only contains isDirty.
shouldComponentUpdate(nextProps) {
return nextProps !== this.props;
}
handleChange(e) {
// Handles change events on (leaf) input elements.
let value;
if (e && e.target) {
// We were passed an event; get the value from its target.
if (e.target.type === 'checkbox') {
value = e.target.checked;
} else {
value = e.target.value;
}
} else {
// We were passed the value itself, not an event.
value = e;
}
// Remove empty and null values so they won't pass validation for required fields.
if (value === null || value === '') {
value = undefined;
}
const type = this.props.schema.type;
if (value && (type === 'integer' || type === 'number')) {
try {
value = parseFloat(value);
} catch (err) {
// Keep string, which should fail schema validation
}
}
// Record that this field was modified.
this.setState({ isDirty: true });
// Pass the new value to the parent.
this.props.updateChild(this.props.name, value);
}
render() {
const { name, path, schema, value } = this.props;
// FIXME Redmine #3413
if (schema === undefined) {
return null;
}
const errors = this.context.errors;
const isValid = !errors[path];
const type = schema.type || 'string';
let classBase = 'rf-Field';
if (type === 'object') {
classBase = 'rf-Fieldset';
} else if (type === 'array') {
classBase = 'rf-RepeatingFieldset';
}
let className = this.props.className;
const readonly = this.context.readonly || schema.readonly;
const inputProps = {
name,
value,
onChange: this.handleChange,
disabled: readonly,
};
let input = schema.formInput;
if (input) {
if (input === 'file') {
input = <FileInput {...inputProps} />;
} else if (input === 'textarea') {
input = <textarea rows="4" {...inputProps} />;
} else if (input === 'layout') {
input = <Layout {...inputProps} editable={!readonly} />;
} else {
// We were passed an arbitrary custom input,
// which we need to clone to specify the correct props.
input = React.cloneElement(input, inputProps);
}
} else if (schema.linkFrom) {
input = (<ChildObject
name={this.props.name} path={path} schema={schema}
value={value} updateChild={this.props.updateChild}
/>);
} else if (type === 'object') {
input = [];
Object.keys(schema.properties).forEach((key) => {
if (key === 'uuid' || key === 'schema_version') return;
const subschema = schema.properties[key];
if (subschema.notSubmittable || subschema.hideFromForms) return;
// Readonly fields are omitted when showReadOnly is false
// (i.e. when adding a new object).
if (!this.context.showReadOnly && subschema.readonly) return;
// we can only edit child objects if we know the current object's id
if (subschema.items && subschema.items.linkFrom && !this.context.id) return;
const required = _.contains((schema.required || []), key);
input.push(<Field
key={key} name={key} path={`${path}.${key}`}
schema={subschema} value={value && value[key]}
updateChild={this.updateChild}
className={required ? 'required' : ''}
/>);
});
} else if (type === 'array') {
input = (<RepeatingFieldset
name={this.props.name} path={path} schema={schema}
value={value} updateChild={this.props.updateChild}
/>);
} else if (schema.enum) {
let options = schema.enum.map(v => <option key={v} value={v}>{v}</option>);
if (!schema.default) {
// "_null_" is a placeholder; it'd be nice if we could actually use null
// to avoid potential collision with real options, but it's not a valid
// React key.
options = [<option key="_null_" value={null} />].concat(options);
}
input = <select className="form-control" {...inputProps}>{options}</select>;
} else if (schema.linkTo) {
// Restrict ObjectPicker to finding the specified type
// FIXME this should handle an array of types too
const restrictions = { type: [schema.linkTo] };
input = (<ObjectPicker
{...inputProps}
searchBase={`?mode=picker&type=${schema.linkTo}`}
restrictions={restrictions}
/>);
} else if (schema.type === 'boolean') {
input = <input type="checkbox" {...inputProps} />;
} else if (schema.type === 'integer' || schema.type === 'number') {
input = <input type="number" {...inputProps} />;
} else {
input = <input type="text" {...inputProps} value={value || ''} />;
}
// Provide a CSS hook to indicate fields with errors
if (!isValid) {
className = `${className} ${classBase}--invalid`;
}
return (
<div className={`${classBase} ${className}`}>
{!this.props.hideLabel ?
<label className={`${classBase}__label rf-Label`}>
<span className="rf-Label__label">{schema.title}</span>
<span className="rf-Hint">{schema.description}</span>
</label>
: ''}
{(this.context.submitted || this.state.isDirty) && errors[path] ?
<span className="rf-Message">{errors[path]}</span>
: ''}
{input}
</div>
);
}
}
Field.propTypes = {
name: PropTypes.any,
path: PropTypes.string,
schema: PropTypes.object,
value: PropTypes.any,
className: PropTypes.string,
updateChild: PropTypes.func.isRequired,
hideLabel: PropTypes.bool,
};
Field.defaultProps = {
name: '',
path: 'instance',
schema: null,
value: '',
hideLabel: false,
className: '',
};
Field.contextTypes = {
submitted: PropTypes.bool,
errors: PropTypes.object,
showReadOnly: PropTypes.bool,
readonly: PropTypes.bool,
id: PropTypes.string,
};
Field.childContextTypes = {
readonly: PropTypes.bool,
};
export class Form extends React.Component {
// The Form component renders a form based on a JSON schema.
// It renders an actual HTML `form` element which contains
// form fields (via the `Field` component)
// and Cancel and Save buttons.
// The initial form value is taken from the `defaultValue` prop.
// The JSON schema is specified in the `schema` prop.
// As the form is edited, validation against the schema
// is performed (on the client side) and errors are reported.
// Once the form has been edited, the user must confirm a dialog
// to navigate away from the form.
// The Save button is enabled if the form has been edited
// and input is valid. Submitting the form
// (by hitting Enter or clicking the Save button)
// serializes the form value to JSON and sends it to the
// server endpoint specified in the `action` and `method`
// props.
// If saving was successful, the form's `onFinish` prop
// is called. Otherwise, it renders error messages
// (either formwide errors below the save button
// or field-specific errors in the context of the field)
// and scrolls to the first one.
// Clicking the Cancel button returns to the homepage.
constructor(props) {
super(props);
// Set initial React state.
this.state = {
isDirty: false,
isValid: true,
value: this.props.defaultValue,
errors: {},
submitted: false,
};
// Bind `this` to non-React methods.
this.validate = this.validate.bind(this);
this.update = this.update.bind(this);
this.canSave = this.canSave.bind(this);
this.save = this.save.bind(this);
this.receive = this.receive.bind(this);
this.showErrors = this.showErrors.bind(this);
this.finish = this.finish.bind(this);
}
getChildContext() {
// Provide various props to contained fields via React's
// `context` mechanism to avoid needing to explicitly
// pass them through multiple layers of nested components.
return {
schemas: this.props.schemas,
canSave: this.canSave,
onTriggerSave: this.save,
errors: this.state.errors,
showReadOnly: this.props.showReadOnly,
id: this.props.id,
submitted: this.state.submitted,
};
}
componentDidUpdate(prevProps, prevState) {
// If form error state changed, scroll to first error message
// to make sure the user notices it.
if (!_.isEqual(prevState.errors, this.state.errors) ||
(this.state.message && (this.state.message !== prevState.message))) {
const message = document.querySelector('.rf-Message,.alert');
if (message) {
window.scrollTo(0, offset(message).top - document.getElementById('navbar').clientHeight);
}
}
}
validate(value) {
// Get validation errors from jsonschema validator.
const validation = validator.validate(value, this.props.schema, {
schemas: this.props.schemas,
// Don't validate `dependencies` in schema,
// because the errors don't get reported at the correct path.
// These should still be reported by server-side validation on form submit.
skipAttributes: ['dependencies'],
});
// `jsonschema` uses field paths like
// `instance.aliases[0]`
// but we use paths like
// `instance.aliases.0`
// so we have to convert them here.
validation.errorsByPath = {};
const errorsByPath = validation.errorsByPath;
validation.errors.forEach((error) => {
let path = error.property.replace(/\[/g, '.').replace(/]/g, '');
// Missing values for required properties are reported
// on the parent property (the one that lists it as required)
// so we have to append the error's `argument`
// to make sure we show the missing value
// in the most helpful place (next to the empty input).
if (error.name === 'required') {
path = `${path}.${error.argument}`;
}
errorsByPath[path] = error.message;
});
return validation;
}
update(name, value) {
// Called whenever the form value was changed.
// (The `name` arg is ignored; most Field components have a
// name and pass it when propagating an update
// to their parent via the `updateChild` prop,
// but the top-level Field does not have a name.)
// for debugging:
// console.log(value);
// Update validation state.
const validation = this.validate(value);
const nextState = {
value,
isDirty: true,
isValid: validation.valid,
errors: validation.errorsByPath,
};
// Notify app that the page is dirty and we should
// show a confirmation dialog before allowing navigation.
if (!this.state.unsavedToken) {
nextState.unsavedToken = this.context.adviseUnsavedChanges();
}
this.setState(nextState);
}
canSave() {
// Called to determine whether to enable the Save button or not.
// It is enabled if the form has been edited, the value is valid
// according to the schema, and the form submission is not in progress.
return this.state.isDirty && this.state.isValid && !this.state.editor_error && !this.communicating;
}
save(e) {
// Send the form value to the server.
// Avoid non-AJAX submission of form.
e.preventDefault();
e.stopPropagation();
const button = e.target.getAttribute('data-button');
// Filter out `schema_version` property
const value = filterValue(this.state.value);
// Make the request
const { method, action, etag } = this.props;
const request = this.context.fetch(action, {
method,
headers: {
'If-Match': etag || '*',
Accept: 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify(value),
});
// Handle errors using `parseAndLogError`;
// otherwise convert response to JSON and pass it to `this.receive`
request.then((response) => {
if (!response.ok) throw response;
return response.json();
})
.catch(parseAndLogError.bind(undefined, 'putRequest'))
.then(this.receive.bind(this, button));
// Set `communicating` to true so the Save button becomes disabled.
this.setState({
message: null,
error: null,
communicating: true,
putRequest: request,
});
}
receive(button, data) {
// Handle a response that is not an HTTP error status.
// Handle server-side validation errors using `this.showErrors`.
const erred = (data['@type'] || []).indexOf('Error') > -1;
if (erred) {
return this.showErrors(data);
}
// Handle a successful form submission using `this.finish`.
return this.finish(button, data);
}
showErrors(data) {
// Translate server-side validation errors.
// The Field component uses paths like
// `instance.aliases.0`
// but the server gives us paths like
// `['aliases', 0]`
// so we have to translate here.
const errors = {};
let error;
if (data.errors !== undefined) {
data.errors.forEach((err) => {
let path = `instance${err.name.length ? `.${err.name.join('.')}` : ''}`;
// Missing values for required properties are reported
// on the parent property (the one that specifies `required`)
// so we have to add the property that is actually missing here.
const match = /^u?'([^']+)' is a required property$/.exec(err.description);
if (match) {
path = `${path}.${match[1]}`;
}
errors[path] = err.description;
});
} else if (data.description) {
// This is a form-wide error rather than a field-specific one.
error = `${data.description} ${data.detail || ''}`;
}
// First clear errors to make sure componentDidUpdate
// will decide we need to scroll again even if the
// errors are the same as the last attempted submission.
this.setState({ errors: {} });
this.setState({
data,
error,
errors,
submitted: true,
communicating: false,
});
}
finish(button, data) {
// Handle a successful form submission.
// Let the app know navigation is now allowed again
// without showing a confirmation dialog
// (i.e. the form is no longer dirty)
if (this.state.unsavedToken) {
this.state.unsavedToken.release();
this.setState({ unsavedToken: null });
}
if (button === 'saveAndAdd') {
const context = data['@graph'][0];
const title = listingTitles.lookup(context)({ context });
let message = `Created ${title}`;
if (context.accession && context.accession !== title) {
message += ` with accession ${context.accession}`;
}
message += '.';
this.setState({ message });
} else if (this.props.onFinish) {
// Default action: defer to the `onFinish` prop.
this.props.onFinish(data);
}
}
render() {
return (
<form
className="rf-Form"
onSubmit={this.save}
>
{this.state.message ? <div className="alert alert-success">{this.state.message}</div> : ''}
<Field
schema={this.props.schema}
value={this.state.value}
updateChild={this.update}
/>
<div className="pull-right">
<a href="" className="btn btn-default">Cancel</a>
{' '}
<button
className="btn btn-success"
onClick={this.save}
disabled={!this.canSave()}
>{this.props.submitLabel}</button>
{' '}
{this.props.showSaveAndAdd ?
<button
data-button="saveAndAdd"
className="btn btn-success"
onClick={this.save}
disabled={!this.canSave()}
>Save & Add Another</button>
: ''}
</div>
{this.state.error ? <div className="alert alert-danger">{this.state.error}</div> : ''}
</form>
);
}
}
Form.propTypes = {
defaultValue: PropTypes.any,
schemas: PropTypes.object,
schema: PropTypes.object.isRequired,
showReadOnly: PropTypes.bool,
showSaveAndAdd: PropTypes.bool,
id: PropTypes.string,
method: PropTypes.string.isRequired,
action: PropTypes.string.isRequired,
etag: PropTypes.string,
onFinish: PropTypes.func.isRequired,
submitLabel: PropTypes.string,
};
Form.defaultProps = {
defaultValue: null,
schemas: null,
id: '',
etag: '',
showReadOnly: true,
showSaveAndAdd: false,
submitLabel: 'Save',
};
Form.contextTypes = {
adviseUnsavedChanges: PropTypes.func,
fetch: PropTypes.func,
};
Form.childContextTypes = {
schemas: PropTypes.object,
canSave: PropTypes.func,
onTriggerSave: PropTypes.func,
errors: PropTypes.object,
showReadOnly: PropTypes.bool,
id: PropTypes.string,
submitted: PropTypes.bool,
};
export class JSONSchemaForm extends React.Component {
// JSONSchemaForm is a wrapper of Form
// that is used from the ItemEdit component after
// it fetches the `schemas` and the `context`
// (which is the edit frame of the object being edited).
// It exists to:
// 1. Look up a specific type schema within the full schemas object.
// 2. Construct a default value, based on the schema,
// if we're adding a new object.
// Other properties are passed through to the Form.
constructor(props) {
super(props);
const { type, schemas } = this.props;
this.state = {
schema: schemas[type],
value: this.props.context || defaultValue(schemas[type]),
};
}
render() {
return (<Form
action={this.props.action} method={this.props.method} etag={this.props.etag}
schemas={this.props.schemas} schema={this.state.schema}
defaultValue={this.state.value} showReadOnly={this.props.showReadOnly}
showSaveAndAdd={this.props.showSaveAndAdd}
id={this.props.id} onFinish={this.props.onFinish}
/>);
}
}
JSONSchemaForm.propTypes = {
type: PropTypes.string.isRequired,
schemas: PropTypes.object,
context: PropTypes.any,
action: PropTypes.string.isRequired,
method: PropTypes.string.isRequired,
etag: PropTypes.string,
showReadOnly: PropTypes.bool,
showSaveAndAdd: PropTypes.bool,
id: PropTypes.string,
onFinish: PropTypes.func.isRequired,
};
JSONSchemaForm.defaultProps = {
schemas: null,
context: null,
id: null,
etag: '',
showReadOnly: true,
showSaveAndAdd: false,
};
|
app/components/Settings.js
|
alfg/somafm
|
import React, { Component } from 'react';
import Nav from './common/Nav';
import SideNav from './common/SideNav';
import styles from './Settings.module.css';
export default class Settings extends Component {
static propTypes = {
};
constructor(props) {
super(props);
this.state = {
};
}
render() {
return (
<div className={styles.settings}>
<SideNav />
<div className={styles.container}>
<Nav />
<h2>Settings</h2>
</div>
</div>
);
}
}
|
basics/lib/root-component.js
|
zpratt/react-tdd-guide
|
import React from 'react';
import {PropTypes} from 'prop-types';
function Root(props) {
const {
users
} = props;
return (
<ul>
{users.map((user, index) => <li key={index}>{user.name}</li>)}
</ul>
);
}
Root.displayName = 'Root';
Root.propTypes = {
users: PropTypes.arrayOf(PropTypes.shape({
name: PropTypes.string
}))
};
export default Root;
|
app/containers/LocaleToggle/index.js
|
andyzeli/Bil
|
/*
*
* LanguageToggle
*
*/
import React from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { createSelector } from 'reselect';
import Toggle from 'components/Toggle';
import Wrapper from './Wrapper';
import messages from './messages';
import { appLocales } from '../../i18n';
import { changeLocale } from '../LanguageProvider/actions';
import { makeSelectLocale } from '../LanguageProvider/selectors';
export class LocaleToggle extends React.PureComponent { // eslint-disable-line react/prefer-stateless-function
render() {
return (
<Wrapper>
<Toggle value={this.props.locale} values={appLocales} messages={messages} onToggle={this.props.onLocaleToggle} />
</Wrapper>
);
}
}
LocaleToggle.propTypes = {
onLocaleToggle: PropTypes.func,
locale: PropTypes.string,
};
const mapStateToProps = createSelector(
makeSelectLocale(),
(locale) => ({ locale })
);
export function mapDispatchToProps(dispatch) {
return {
onLocaleToggle: (evt) => dispatch(changeLocale(evt.target.value)),
dispatch,
};
}
export default connect(mapStateToProps, mapDispatchToProps)(LocaleToggle);
|
client/components/ChooseUserName.js
|
GO345724/pair-programming
|
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import {Form, FormGroup, FormControl, Button, ControlLabel} from 'react-bootstrap';
class ChooseUserName extends Component {
constructor(props) {
super(props);
this.state = {
userName: ''
}
this.updateState = this.updateState.bind(this);
this.triggerChooseUserName = this.triggerChooseUserName.bind(this);
}
updateState(event) {
let userName = event.target.value;
this.setState({userName});
}
triggerChooseUserName(event) {
event.preventDefault();
this.props.chooseUserName(this.state.userName);
}
render() {
return(
<div>
<Form inline>
<FormGroup controlId="formInlineUserName">
<FormControl type="text" defaultValue={this.props.userName} onChange={this.updateState}/>
{' '}
<Button type="submit" onClick={this.triggerChooseUserName} disabled={!this.state.userName}>
Choose Username
</Button>
</FormGroup>
</Form>
</div>
)
}
}
ChooseUserName.propTypes = {
userName: PropTypes.string.isRequired,
chooseUserName: PropTypes.func.isRequired
}
export default ChooseUserName;
|
components/animalNeighbourScene.js
|
marxsk/zobro
|
import React from 'react';
import {
View,
Text,
ListView,
TouchableHighlight, Alert, Image,
} from 'react-native';
import * as scenes from '../scenes';
import styles from '../styles/styles';
import animals from '../animals';
var navigator;
class Cell extends React.Component {
constructor(props) {
super(props);
}
render() {
const animal = animals[this.props.item.animal];
const direction = this.props.item.direction;
let directionArrow = null;
if (direction === 'front') {
directionArrow = require('../images/icon/arrow-front.png');
} else if (direction === 'back') {
directionArrow = require('../images/icon/arrow-back.png');
} else if (direction === 'right') {
directionArrow = require('../images/icon/arrow-right.png');
} else if (direction === 'left') {
directionArrow = require('../images/icon/arrow-left.png');
}
if ((animal === undefined) || (! 'name' in animal)) {
return null;
}
return (
<TouchableHighlight
onPress={() => scenes.navigatePush(navigator, scenes.ANIMAL_DETAIL, {animal: this.props.item.animal})}
underlayColor='#bbbbbb'
>
<View style={[styles.eventItem, {flex: 1, flexDirection: 'row', alignItems: 'center', backgroundColor: this.props.backgroundColor}]}>
<Image style={{height: 50, width: 50, marginRight: 10}} source={directionArrow} resizeMode='contain' />
<Text style={styles.eventItemText}>{animal.name}</Text>
</View>
</TouchableHighlight>
);
}
}
export default class AnimalNeighbourScene extends React.Component {
constructor(props) {
super(props);
navigator = this.props.navigator;
const ds = new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2});
this.state = {
dataSource: ds.cloneWithRows(
animals[this.props.animal].neighbours.map(function(v) { return v })
)};
}
componentWillMount() {
this.props.bg();
}
render() {
const backgroundColors = [
'#37af54',
'#2d9946',
'#267f3b',
'#20642f',
'#0b2611',
'#20642f',
'#267f3b',
'#2d9946',
];
let counter = 0;
return (
<ListView
dataSource={this.state.dataSource}
renderRow={(data) => {
let backgroundColor = backgroundColors[counter % backgroundColors.length];
counter++;
return (<Cell item={data} backgroundColor = {backgroundColor} />);
}}
/>
);
}
}
AnimalNeighbourScene.propTypes = {
bg: React.PropTypes.func.isRequired,
animal: React.PropTypes.string.isRequired,
navigator: React.PropTypes.object.isRequired,
};
|
src/svg-icons/navigation/more-vert.js
|
kasra-co/material-ui
|
import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let NavigationMoreVert = (props) => (
<SvgIcon {...props}>
<path d="M12 8c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"/>
</SvgIcon>
);
NavigationMoreVert = pure(NavigationMoreVert);
NavigationMoreVert.displayName = 'NavigationMoreVert';
NavigationMoreVert.muiName = 'SvgIcon';
export default NavigationMoreVert;
|
src/views/ArticleMain.js
|
fightingm/blog
|
import React from 'react';
import Markdown from 'react-markdown';
import ArticleData from './ArticleData';
import $ from 'jquery';
import hljs from 'highlight.js';
require ('../css/ArticleMain.css');
require ('highlight.js/styles/solarized-light.css');
export default class ArticleMain extends React.Component{
constructor() {
super();
this.article=ArticleData;
}
componentWillMount() {
let location=window.location.hash;
let re=/(\d+)-(\d+)-(\d+)/g;
let newstr=re.exec(location);
this.year=newstr[1];
this.month=newstr[2];
this.day=newstr[3];
let newYear=ArticleData.filter(function(item){
return item.year == this.year;
}.bind(this));
let newMonth=newYear[0].monthes.filter(function(item){
return item.month == this.month;
}.bind(this));
this.newDay=newMonth[0].days.filter(function(item){
return item.day == this.day;
}.bind(this))[0];
}
componentDidMount() {
//hljs.initHighlightingOnLoad();
hljs.configure({
tabReplace: ' '
});
//hljs.initHighlighting();
$('pre code').each(function(i, block) {
hljs.highlightBlock(block);
});
}
render() {
return (
<main className="ArticleMain main-body">
<article className="container">
<div id="article-con" className="article-con result-pane">
<Markdown
source={this.newDay.con}
skipHtml={false}
escapeHtml={false}
/>
</div>
<time className="write-t blue">{this.year}ๅนด{this.month}ๆ{this.day}ๆฅ</time>
</article>
</main>
);
}
}
|
src/js/components/App.js
|
designcreative/react-redux-template
|
import React, { Component } from 'react';
import ItemList from '../containers/item-list';
import ItemDetail from '../containers/item-detail';
require('../../scss/main.scss');
class App extends Component {
render() {
return (
<div>
<h2>Item List</h2>
<ItemList />
<hr/>
<h2>Item Detail</h2>
<ItemDetail />
</div>
);
}
}
export default App;
|
docs/src/app/components/pages/components/DatePicker/ExampleToggle.js
|
hai-cea/material-ui
|
import React from 'react';
import DatePicker from 'material-ui/DatePicker';
import Toggle from 'material-ui/Toggle';
const optionsStyle = {
maxWidth: 255,
marginRight: 'auto',
};
/**
* This example allows you to set a date range, and to toggle `autoOk`, and `disableYearSelection`.
*/
export default class DatePickerExampleToggle extends React.Component {
constructor(props) {
super(props);
const minDate = new Date();
const maxDate = new Date();
minDate.setFullYear(minDate.getFullYear() - 1);
minDate.setHours(0, 0, 0, 0);
maxDate.setFullYear(maxDate.getFullYear() + 1);
maxDate.setHours(0, 0, 0, 0);
this.state = {
minDate: minDate,
maxDate: maxDate,
autoOk: false,
disableYearSelection: false,
};
}
handleChangeMinDate = (event, date) => {
this.setState({
minDate: date,
});
};
handleChangeMaxDate = (event, date) => {
this.setState({
maxDate: date,
});
};
handleToggle = (event, toggled) => {
this.setState({
[event.target.name]: toggled,
});
};
render() {
return (
<div>
<DatePicker
floatingLabelText="Ranged Date Picker"
autoOk={this.state.autoOk}
minDate={this.state.minDate}
maxDate={this.state.maxDate}
disableYearSelection={this.state.disableYearSelection}
/>
<div style={optionsStyle}>
<DatePicker
onChange={this.handleChangeMinDate}
autoOk={this.state.autoOk}
floatingLabelText="Min Date"
defaultDate={this.state.minDate}
disableYearSelection={this.state.disableYearSelection}
/>
<DatePicker
onChange={this.handleChangeMaxDate}
autoOk={this.state.autoOk}
floatingLabelText="Max Date"
defaultDate={this.state.maxDate}
disableYearSelection={this.state.disableYearSelection}
/>
<Toggle
name="autoOk"
value="autoOk"
label="Auto Ok"
toggled={this.state.autoOk}
onToggle={this.handleToggle}
/>
<Toggle
name="disableYearSelection"
value="disableYearSelection"
label="Disable Year Selection"
toggled={this.state.disableYearSelection}
onToggle={this.handleToggle}
/>
</div>
</div>
);
}
}
|
app/components/IntroBlock/index.js
|
daicas/react-boilerplate-examp
|
import React from 'react';
import { FormattedMessage } from 'react-intl';
import Img from 'components/Img';
import styled from 'styled-components';
import {
IntroBlockWapper,
IntroBlockContent,
Title,
IntroBlockDes,
LinkViewMore,
IntroSlider,
IntroSliderItem
} from './style';
class IntroBlock extends React.Component { // eslint-disable-line react/prefer-stateless-function
render(props) {
return (
<IntroBlockWapper>
<IntroSlider>
<IntroSliderItem><Img src={require('static/images/upload/thumb.jpg')} alt="intro 1"/>
</IntroSliderItem>
</IntroSlider>
<IntroBlockContent>
<Title>Welcome to our Web Site !</Title>
<IntroBlockDes>
<p>Lorem Ipsum consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore Lorem ipsum dolor sit amet, conseter sadipscing elitr, sed diam ipsum dolor sit amet, conseter sadipscing elitr, sed diam Lorem Ipsum consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore Lorem ipsum dolor sit amet, conseter sadipscing elitr, sed diam ipsum dolor sit amet, conseter sadipscing elitr, sed diam invidunt ut labore Lorem ipsum dolor sit amet, conseter sadipscing elitr, sed diam ipsum dolor sit amet, conseter conseter sit...</p>
</IntroBlockDes>
<LinkViewMore href="#">View more</LinkViewMore>
</IntroBlockContent>
</IntroBlockWapper>
);
}
}
export default IntroBlock;
|
src/components/WebView.js
|
Root-App/react-native-mock-render
|
import EdgeInsetsPropType from '../propTypes/EdgeInsetsPropType';
import React from 'react';
import PropTypes from 'prop-types';
import createReactClass from 'create-react-class';
import View from './View';
import ScrollView from './ScrollView';
import WebViewManager from '../NativeModules/WebViewManager';
const RCT_WEBVIEW_REF = 'webview';
const NavigationType = {
click: WebViewManager.NavigationType.LinkClicked,
formsubmit: WebViewManager.NavigationType.FormSubmitted,
backforward: WebViewManager.NavigationType.BackForward,
reload: WebViewManager.NavigationType.Reload,
formresubmit: WebViewManager.NavigationType.FormResubmitted,
other: WebViewManager.NavigationType.Other,
};
const JSNavigationScheme = WebViewManager.JSNavigationScheme;
const WebView = createReactClass({
displayName: 'WebView',
propTypes: {
...View.propTypes,
url: PropTypes.string,
html: PropTypes.string,
/**
* Function that returns a view to show if there's an error.
*/
renderError: PropTypes.func, // view to show if there's an error
/**
* Function that returns a loading indicator.
*/
renderLoading: PropTypes.func,
/**
* Invoked when load finish
*/
onLoad: PropTypes.func,
/**
* Invoked when load either succeeds or fails
*/
onLoadEnd: PropTypes.func,
/**
* Invoked on load start
*/
onLoadStart: PropTypes.func,
/**
* Invoked when load fails
*/
onError: PropTypes.func,
/**
* @platform ios
*/
bounces: PropTypes.bool,
/**
* A floating-point number that determines how quickly the scroll view
* decelerates after the user lifts their finger. You may also use string
* shortcuts `"normal"` and `"fast"` which match the underlying iOS settings
* for `UIScrollViewDecelerationRateNormal` and
* `UIScrollViewDecelerationRateFast` respectively.
* - Normal: 0.998
* - Fast: 0.9 (the default for iOS WebView)
* @platform ios
*/
decelerationRate: ScrollView.propTypes.decelerationRate,
/**
* @platform ios
*/
scrollEnabled: PropTypes.bool,
automaticallyAdjustContentInsets: PropTypes.bool,
contentInset: EdgeInsetsPropType,
onNavigationStateChange: PropTypes.func,
startInLoadingState: PropTypes.bool, // force WebView to show loadingView on first load
style: View.propTypes.style,
/**
* Used on Android only, JS is enabled by default for WebView on iOS
* @platform android
*/
javaScriptEnabled: PropTypes.bool,
/**
* Used on Android only, controls whether DOM Storage is enabled or not
* @platform android
*/
domStorageEnabled: PropTypes.bool,
/**
* Sets the JS to be injected when the webpage loads.
*/
injectedJavaScript: PropTypes.string,
/**
* Sets whether the webpage scales to fit the view and the user can change the scale.
* @platform ios
*/
scalesPageToFit: PropTypes.bool,
/**
* Allows custom handling of any webview requests by a JS handler. Return true
* or false from this method to continue loading the request.
* @platform ios
*/
onShouldStartLoadWithRequest: PropTypes.func,
/**
* Determines whether HTML5 videos play inline or use the native full-screen
* controller.
* default value `false`
* **NOTE** : "In order for video to play inline, not only does this
* property need to be set to true, but the video element in the HTML
* document must also include the webkit-playsinline attribute."
* @platform ios
*/
allowsInlineMediaPlayback: PropTypes.bool,
},
statics: {
JSNavigationScheme,
NavigationType,
},
getWebViewHandle() {
// TODO(lmr): React.findNodeHandle
return React.findNodeHandle(this.refs[RCT_WEBVIEW_REF]);
},
reload() {
// do nothing
},
goForward() {
// do nothing
},
goBack() {
// do nothing
},
render() {
return React.createElement('react-native-mock', null, this.props.children);
},
});
module.exports = WebView;
|
src/internal/ClearFix.js
|
hwo411/material-ui
|
import React from 'react';
import PropTypes from 'prop-types';
import BeforeAfterWrapper from './BeforeAfterWrapper';
const styles = {
before: {
content: "' '",
display: 'table',
},
after: {
content: "' '",
clear: 'both',
display: 'table',
},
};
const ClearFix = ({style, children, ...other}) => (
<BeforeAfterWrapper
{...other}
beforeStyle={styles.before}
afterStyle={styles.after}
style={style}
>
{children}
</BeforeAfterWrapper>
);
ClearFix.muiName = 'ClearFix';
ClearFix.propTypes = {
children: PropTypes.node,
/**
* Override the inline-styles of the root element.
*/
style: PropTypes.object,
};
export default ClearFix;
|
src/client/components/Utils/ScrollToTopOnMount.js
|
busyorg/busy
|
import React from 'react';
import { withRouter } from 'react-router';
class ScrollToTopOnMount extends React.Component {
componentDidMount() {
if (window && window.location.hash === '') {
window.scrollTo(0, 0);
}
}
render() {
return null;
}
}
export default withRouter(ScrollToTopOnMount);
|
src/svg-icons/file/file-download.js
|
matthewoates/material-ui
|
import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let FileFileDownload = (props) => (
<SvgIcon {...props}>
<path d="M19 9h-4V3H9v6H5l7 7 7-7zM5 18v2h14v-2H5z"/>
</SvgIcon>
);
FileFileDownload = pure(FileFileDownload);
FileFileDownload.displayName = 'FileFileDownload';
FileFileDownload.muiName = 'SvgIcon';
export default FileFileDownload;
|
src/svg-icons/av/video-call.js
|
lawrence-yu/material-ui
|
import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let AvVideoCall = (props) => (
<SvgIcon {...props}>
<path d="M17 10.5V7c0-.55-.45-1-1-1H4c-.55 0-1 .45-1 1v10c0 .55.45 1 1 1h12c.55 0 1-.45 1-1v-3.5l4 4v-11l-4 4zM14 13h-3v3H9v-3H6v-2h3V8h2v3h3v2z"/>
</SvgIcon>
);
AvVideoCall = pure(AvVideoCall);
AvVideoCall.displayName = 'AvVideoCall';
AvVideoCall.muiName = 'SvgIcon';
export default AvVideoCall;
|
src/native/app/components/Text.js
|
robinpokorny/este
|
import React from 'react';
import theme from '../themes/initial';
import { StyleSheet, Text } from 'react-native';
// https://github.com/facebook/react-native/issues/7877
const round = value => Math.round(value);
const styles = StyleSheet.create({
text: { // eslint-disable-line react-native/no-unused-styles
color: theme.textColor,
fontFamily: theme.fontFamily,
fontSize: theme.fontSize,
lineHeight: round(theme.fontSize * theme.lineHeight),
},
});
// Normalize multiline strings because Text component preserves spaces.
const normalizeMultilineString = message => message.replace(/ +/g, ' ').trim();
class AppText extends React.Component {
static propTypes = {
children: React.PropTypes.node,
style: Text.propTypes.style,
};
onTextRef(text) {
this.text = text;
}
setNativeProps(nativeProps) {
this.text.setNativeProps(nativeProps);
}
getTextStyleWithMaybeComputedLineHeight() {
const { style } = this.props;
if (!style) {
return styles.text;
}
const customFontSize = StyleSheet.flatten(style).fontSize;
if (!Number.isInteger(customFontSize)) {
return [styles.text, style];
}
const lineHeight = round(customFontSize * theme.lineHeight);
return [styles.text, style, { lineHeight }];
}
render() {
const { children } = this.props;
const textStyle = this.getTextStyleWithMaybeComputedLineHeight();
return (
<Text
{...this.props}
ref={text => this.onTextRef(text)}
style={textStyle}
>
{typeof children === 'string'
? normalizeMultilineString(children)
: children
}
</Text>
);
}
}
export default AppText;
|
components/checkbox/__tests__/Checkbox.spec.js
|
react-material-design/react-material-design
|
import React from 'react';
import { mount } from 'enzyme';
import Checkbox from '../index';
jest.mock('uuid', () => ({
v4: jest.fn(() => '2e732f05-f466-4fba-acb5-2f3be58daf75'),
}));
describe('<Checkbox />', () => {
it('should be able to render', () => {
const checkbox = mount(<Checkbox />);
expect(checkbox).toMatchSnapshot();
});
it('should be able to render with a label', () => {
const label = 'My Checkbox Label';
const checkbox = mount(<Checkbox label={label} />);
expect(checkbox).toMatchSnapshot();
});
it('should render as checked', () => {
const label = 'My Checkbox Label';
const checked = true;
const checkbox = mount(<Checkbox checked={checked} label={label} />);
expect(checkbox).toMatchSnapshot();
});
it('should render as disabled', () => {
const label = 'My Checkbox Label';
const disable = true;
const checkbox = mount(<Checkbox disable={disable} label={label} />);
expect(checkbox).toMatchSnapshot();
});
it('should render indeterminate', () => {
const label = 'My Checkbox Label';
const indeterminate = true;
const checkbox = mount(<Checkbox indeterminate={indeterminate} label={label} />);
expect(checkbox).toMatchSnapshot();
});
});
|
helloWorld/HelloWorld.spec.js
|
sagasu/reactPlayground
|
import {expect} from 'chai'
import React from 'react'
import {createRenderer} from 'react-addons-test-utils'
import HelloWorld from './HelloWorld'
describe('HelloWorld component', () => {
it('should render correctly', () => {
const renderer = createRenderer()
// this is a cool usage of HelloWorld variable from an import
renderer.render(<HelloWorld/>)
const actual = renderer.getRenderOutput()
expect(actual.type).to.equal('div')
expect(actual.props).to.deep.equal({children: 'Hello world'})
})
})
|
src/svg-icons/maps/flight.js
|
barakmitz/material-ui
|
import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let MapsFlight = (props) => (
<SvgIcon {...props}>
<path d="M10.18 9"/><path d="M21 16v-2l-8-5V3.5c0-.83-.67-1.5-1.5-1.5S10 2.67 10 3.5V9l-8 5v2l8-2.5V19l-2 1.5V22l3.5-1 3.5 1v-1.5L13 19v-5.5l8 2.5z"/>
</SvgIcon>
);
MapsFlight = pure(MapsFlight);
MapsFlight.displayName = 'MapsFlight';
MapsFlight.muiName = 'SvgIcon';
export default MapsFlight;
|
packages/wix-style-react/src/FunnelChart/FunnelBar/FunnelBar.js
|
wix/wix-style-react
|
import React from 'react';
import { st, classes } from './FunnelBar.st.css';
export const FunnelBar = ({ height, dataHook }) => {
return (
<div className={st(classes.root)} data-hook={dataHook}>
<div style={{ height: `${height}%` }} className={classes.filledBar} />
</div>
);
};
|
frontend/app_v2/src/common/icons/Copy.js
|
First-Peoples-Cultural-Council/fv-web-ui
|
import React from 'react'
import PropTypes from 'prop-types'
function Copy({ styling }) {
return (
<svg className={styling} xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<title>Copy</title>
<path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z" />
</svg>
)
}
// PROPTYPES
const { string } = PropTypes
Copy.propTypes = {
styling: string,
}
export default Copy
|
lms/static/js/student_account/components/spec/PasswordResetConfirmation_spec.js
|
kmoocdev2/edx-platform
|
/* globals setFixtures */
import ReactDOM from 'react-dom';
import React from 'react';
import sinon from 'sinon'; // eslint-disable-line import/no-extraneous-dependencies
import { PasswordResetConfirmation } from '../PasswordResetConfirmation';
describe('PasswordResetConfirmation', () => {
beforeEach(() => {
setFixtures('<div id="wrapper"></div>');
sinon.stub(window, 'fetch');
});
afterEach(() => {
window.fetch.restore();
});
function init(submitError) {
ReactDOM.render(
React.createElement(PasswordResetConfirmation, {
csrfToken: 'csrfToken',
errorMessage: submitError,
}, null),
document.getElementById('wrapper'),
);
}
function triggerValidation() {
$('#new_password1').focus();
$('#new_password1').val('a');
$('#new_password2').focus();
expect(window.fetch.calledWithMatch(
'/api/user/v1/validation/registration',
{ body: JSON.stringify({ password: 'a' }) },
));
}
function prepareValidation(validationError, done) {
window.fetch.reset();
window.fetch.callsFake(() => {
done();
return Promise.resolve({
json: () => ({ validation_decisions: { password: validationError } }),
});
});
}
it('shows submit error', () => {
init('Submit error.');
expect($('.alert-dialog')).toExist();
expect($('.alert-dialog')).not.toBeHidden();
expect($('.alert-dialog')).toHaveText('Submit error.');
});
describe('validation', () => {
beforeEach((done) => {
init('');
prepareValidation('Validation error.', done);
triggerValidation();
});
it('shows validation error', () => {
expect($('#error-new_password1')).toContainText('Validation error.');
});
});
});
|
src/server.js
|
cbellino/roster
|
/**
* React Starter Kit (https://www.reactstarterkit.com/)
*
* Copyright ยฉ 2014-2016 Kriasoft, LLC. All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE.txt file in the root directory of this source tree.
*/
import 'babel-polyfill';
import path from 'path';
import express from 'express';
import React from 'react';
import ReactDOM from 'react-dom/server';
import Router from './routes';
import Html from './components/Html';
import assets from './assets';
import { port } from './config';
const server = global.server = express();
//
// Register Node.js middleware
// -----------------------------------------------------------------------------
server.use(express.static(path.join(__dirname, 'public')));
//
// Register server-side rendering middleware
// -----------------------------------------------------------------------------
server.get('*', async (req, res, next) => {
try {
let statusCode = 200;
const data = { title: '', description: '', css: '', body: '', entry: assets.main.js };
const css = [];
const context = {
insertCss: styles => css.push(styles._getCss()),
onSetTitle: value => data.title = value,
onSetMeta: (key, value) => data[key] = value,
onPageNotFound: () => statusCode = 404,
};
await Router.dispatch({ path: req.path, query: req.query, context }, (state, component) => {
data.css = css.join('');
});
const html = ReactDOM.renderToStaticMarkup(<Html {...data} />);
res.status(statusCode).send(`<!doctype html>\n${html}`);
} catch (err) {
next(err);
}
});
//
// Launch the server
// -----------------------------------------------------------------------------
server.listen(port, () => {
/* eslint-disable no-console */
console.log(`The server is running at http://localhost:${port}/`);
});
|
src/Components/BadgeComponent.js
|
Xeroeta/nkcgo-webapp
|
import React, { Component } from 'react';
import {
ShareButtons,
ShareCounts,
generateShareIcon,
} from 'react-share';
const {
FacebookShareButton,
GooglePlusShareButton,
LinkedinShareButton,
TwitterShareButton,
PinterestShareButton,
VKShareButton,
OKShareButton,
TelegramShareButton,
WhatsappShareButton,
RedditShareButton,
EmailShareButton,
} = ShareButtons;
const {
FacebookShareCount,
GooglePlusShareCount,
LinkedinShareCount,
PinterestShareCount,
VKShareCount,
OKShareCount,
RedditShareCount,
} = ShareCounts;
const FacebookIcon = generateShareIcon('facebook');
const TwitterIcon = generateShareIcon('twitter');
const GooglePlusIcon = generateShareIcon('google');
const LinkedinIcon = generateShareIcon('linkedin');
const PinterestIcon = generateShareIcon('pinterest');
const VKIcon = generateShareIcon('vk');
const OKIcon = generateShareIcon('ok');
const TelegramIcon = generateShareIcon('telegram');
const WhatsappIcon = generateShareIcon('whatsapp');
const RedditIcon = generateShareIcon('reddit');
const EmailIcon = generateShareIcon('email');
const shareUrl = 'http://nkcgo.com';
const title = 'NKCGo - My Badge';
export default class BadgeComponent extends Component {
constructor(props) {
super(props);
this.state = {
badges: props.badges
};
console.log('initial Props');
console.log(props.badges);
}
componentWillReceiveProps(nextProps) {
console.log('nextProps.VenuesData');
console.log(nextProps.badges);
this.setState({ badges: nextProps.badges });
}
goTo(route) {
// alert(route);
this.props.history.replace(`/${route}`)
}
render() {
return (
<div>
<center>
<p style={styles.introText}> If you see any badge below, you can claim your associated badges from the NKC Business Council at 320 Armour Road (suite 220, 2nd floor) from 8:30 AM to 3:30 PM on Tuesday (12 Sept) to Thursday (14 Sept).</p>
<p style={styles.navigationText}> <a href='https://www.google.com/maps/dir/?api=1&dir_action=navigate&travelmode=walking&destination=320 Armour Road, North Kansas City, MO 64116'>(Navigate to the NKC Business Council building.) </a> </p>
<p> ------------------------------- </p>
</center>
{
this.state.badges.map((mybadge) => (
<div
style={styles.badgeInfo}
key={mybadge.id}
>
<center>
<img style={styles.imageBadge}
alt=""
src={mybadge.image_url}
/>
<p style={styles.badgeTitle}>{mybadge.badgeName}{'\n\n'}</p>
</center>
<div className="Nkcgo_social-network">
<center>
<FacebookShareButton
url={shareUrl}
quote={title}
className="Nkcgo_social-network__share-button">
<FacebookIcon
size={32}
round />
</FacebookShareButton>
<FacebookShareCount
url={shareUrl}
className="Nkcgo_social-network__share-count">
{count => count}
</FacebookShareCount>
<TwitterShareButton
url={shareUrl}
title={title}
className="Nkcgo_social-network__share-button">
<TwitterIcon
size={32}
round />
</TwitterShareButton>
<div className="Nkcgo_social-network__share-count">
</div>
</center>
</div>
</div>
))
}
</div>
);
}
}
const styles = {
imageBadge: {
width: screen.width/4,
height: screen.width/4,
justifyContent: 'center',
alignItems: 'center'
},
badgeTitle: {
fontSize: 20
},
badgeInfo: {
marginBottom: 10
},
introText: {
color: '#000',
fontSize: 20,
fontWeight: 'bold',
},
navigationText: {
color: '#000',
fontSize: 16,
fontWeight: 'bold',
}
};
|
app/components/App/SideBar/index.js
|
basask/react-router-material-ui-seed
|
import React from 'react';
import { Drawer, MenuItem, AppBar, IconButton } from 'material-ui';
import { Link } from 'react-router';
import NavigationClose from 'material-ui/svg-icons/navigation/close';
import constants from '../constants';
class SideBar extends React.Component {
constructor(props){
super(props);
this.tap = this.tap.bind(this);
}
tap(path){
if(path)
this.context.router.push(path);
if(this.props.onMenuItemClick)
this.props.onMenuItemClick();
}
render() {
return (
<Drawer open={this.props.drawerOpen}>
<AppBar
title={constants.appTitle}
showMenuIconButton={this.props.showMenuIconButton}
onTitleTouchTap={()=>this.tap('/home')}
iconElementLeft={<IconButton><NavigationClose /></IconButton>}
onLeftIconButtonTouchTap={()=>this.tap()}/>
<MenuItem onTouchTap={()=>this.tap('/home')}>Home</MenuItem>
<MenuItem onTouchTap={()=>this.tap('/theme')}>Theme</MenuItem>
</Drawer>
);
}
}
SideBar.contextTypes = {
router: React.PropTypes.object.isRequired
}
export default SideBar;
|
src/svg-icons/image/filter-tilt-shift.js
|
rscnt/material-ui
|
import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let ImageFilterTiltShift = (props) => (
<SvgIcon {...props}>
<path d="M11 4.07V2.05c-2.01.2-3.84 1-5.32 2.21L7.1 5.69c1.11-.86 2.44-1.44 3.9-1.62zm7.32.19C16.84 3.05 15.01 2.25 13 2.05v2.02c1.46.18 2.79.76 3.9 1.62l1.42-1.43zM19.93 11h2.02c-.2-2.01-1-3.84-2.21-5.32L18.31 7.1c.86 1.11 1.44 2.44 1.62 3.9zM5.69 7.1L4.26 5.68C3.05 7.16 2.25 8.99 2.05 11h2.02c.18-1.46.76-2.79 1.62-3.9zM4.07 13H2.05c.2 2.01 1 3.84 2.21 5.32l1.43-1.43c-.86-1.1-1.44-2.43-1.62-3.89zM15 12c0-1.66-1.34-3-3-3s-3 1.34-3 3 1.34 3 3 3 3-1.34 3-3zm3.31 4.9l1.43 1.43c1.21-1.48 2.01-3.32 2.21-5.32h-2.02c-.18 1.45-.76 2.78-1.62 3.89zM13 19.93v2.02c2.01-.2 3.84-1 5.32-2.21l-1.43-1.43c-1.1.86-2.43 1.44-3.89 1.62zm-7.32-.19C7.16 20.95 9 21.75 11 21.95v-2.02c-1.46-.18-2.79-.76-3.9-1.62l-1.42 1.43z"/>
</SvgIcon>
);
ImageFilterTiltShift = pure(ImageFilterTiltShift);
ImageFilterTiltShift.displayName = 'ImageFilterTiltShift';
export default ImageFilterTiltShift;
|
boilerplates/project/pcNative/app/components/Main/Main.js
|
FuluUE/vd-generator
|
import React from 'react';
import styles from './less/main.less';
class Main extends React.Component {
render() {
return (
<div className={styles.main}>
aa
</div>
);
}
}
export default Main;
|
src/components/Dot.js
|
wu0792/gallery-by-react
|
import React from 'react'
class Dot extends React.Component{
constructor(props){
super(props);
this.state = {};
this.state.reverse = props.reverse || false;
this.state.active = props.active || false;
}
render(){
return (<li className={'nav_dot' + (this.state.active?' active':'')} onClick={this.props.onClick}></li>);
}
}
export default Dot;
|
node_modules/react-bootstrap/es/Tab.js
|
superKaigon/TheCave
|
import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn';
import _inherits from 'babel-runtime/helpers/inherits';
import _extends from 'babel-runtime/helpers/extends';
import React from 'react';
import PropTypes from 'prop-types';
import TabContainer from './TabContainer';
import TabContent from './TabContent';
import TabPane from './TabPane';
var propTypes = _extends({}, TabPane.propTypes, {
disabled: PropTypes.bool,
title: PropTypes.node,
/**
* tabClassName is used as className for the associated NavItem
*/
tabClassName: PropTypes.string
});
var Tab = function (_React$Component) {
_inherits(Tab, _React$Component);
function Tab() {
_classCallCheck(this, Tab);
return _possibleConstructorReturn(this, _React$Component.apply(this, arguments));
}
Tab.prototype.render = function render() {
var props = _extends({}, this.props);
// These props are for the parent `<Tabs>` rather than the `<TabPane>`.
delete props.title;
delete props.disabled;
delete props.tabClassName;
return React.createElement(TabPane, props);
};
return Tab;
}(React.Component);
Tab.propTypes = propTypes;
Tab.Container = TabContainer;
Tab.Content = TabContent;
Tab.Pane = TabPane;
export default Tab;
|
src/containers/Router.js
|
scenario-generator/frontend
|
import React, { Component } from 'react';
import { StyleRoot } from 'radium';
import { Router } from 'react-router';
import ReactGA from 'react-ga';
// Constants
import Strings from '../constants/strings';
// Components
import routes from '../routes';
import Head from '../components/Head'
/**
* Component is exported for conditional usage in Root.js
*/
class RouterComponent extends Component {
componentDidMount() {
ReactGA.initialize(process.env.REACT_APP_GOOGLE_ANALYTICS_KEY);
}
logPageView() {
ReactGA.set({ page: window.location.pathname });
ReactGA.pageview(window.location.pathname);
}
render() {
var history = this.props.history;
return (
<div>
<Head title={Strings.rootPageTitle} />
<StyleRoot>
<Router
history={history}
onUpdate={this.logPageView}>
{ routes }
</Router>
</StyleRoot>
</div>
);
}
};
export default RouterComponent;
|
src/dumb/editor/custom_field/preview_templates/AssetSelectionPreviewTemplate.js
|
jeckhummer/wf-constructor
|
import React from 'react';
import {Form} from "semantic-ui-react";
export const AssetSelectionPreviewTemplate = ({label}) => {
const options = [
{text: 'asset 1', value: 'asset 1'},
{text: 'asset 2', value: 'asset 2'},
{text: 'asset 3', value: 'asset 3'},
{text: '...', value: '...'},
];
return (
<div>
<Form>
<Form.Select label={label || "[NO TEXT PROVIDED]"} options={options} placeholder="--"/>
</Form>
<br/>
<span style={{fontSize: '0.85em'}}>
* Dropdown items will be populated from SPM.
</span>
</div>
);
};
|
test/integration/basic/pages/stateless.js
|
nikvm/next.js
|
import React from 'react'
export default () => <h1>My component!</h1>
|
information/blendle-frontend-react-source/app/modules/premiumSignup/components/ResetPassword/index.js
|
BramscoChill/BlendleParser
|
import React from 'react';
import PropTypes from 'prop-types';
import ResetPasswordView from 'components/login/ResetPassword';
import CSS from './styles.scss';
const ResetPassword = (props) => {
const { route, onClickLogin } = props;
return (
<div className={CSS.resetPassword}>
<ResetPasswordView showBack active={route.activeStepIndex === 2} onLoginLink={onClickLogin} />
</div>
);
};
ResetPassword.propTypes = {
route: PropTypes.object.isRequired,
onClickLogin: PropTypes.func.isRequired,
disabled: PropTypes.bool,
};
export default ResetPassword;
// WEBPACK FOOTER //
// ./src/js/app/modules/premiumSignup/components/ResetPassword/index.js
|
amp-stories/src/component/view/LinkComponentsStoryView/pages/StoryPage3.js
|
ampproject/samples
|
import React from 'react';
import styled, {keyframes} from 'styled-components';
import {TextHighlightBanner, Button as SharedButton} from '../shared';
import {BannerWrapper} from '/component/base/TextHighlight';
import AmpStoryPage from '/component/amp/AmpStoryPage';
import AmpImage from '/component/amp/AmpImage';
const tada = keyframes`
from {
transform: scale3d(1, 1, 1);
}
10%,
20% {
transform: scale3d(0.9, 0.9, 0.9) rotate3d(0, 0, 1, -3deg);
}
30%,
50%,
70%,
90% {
transform: scale3d(1.1, 1.1, 1.1) rotate3d(0, 0, 1, 3deg);
}
40%,
60%,
80% {
transform: scale3d(1.1, 1.1, 1.1) rotate3d(0, 0, 1, -3deg);
}
to {
transform: scale3d(1, 1, 1);
}
`;
const rotate = keyframes`
from {
transform: translate(-63%, -7%) rotate(0deg);
}
to {
transform: translate(-63%, -7%) rotate(360deg);
}
`;
const Button = styled(SharedButton)`
width: 100%;
`;
const ButtonWrapper = styled.div`
display: flex;
justify-content: center;
align-items: center;
padding: 32px;
`;
const trajectory = (rotate, translate) => keyframes`
from {
opacity: 0
}
50% {
opacity: 1;
}
to {
transform: rotate(${rotate}) translate(${translate},0);
opacity: 0;
}
`;
const Exploder = styled.div`
width: 15px
height: 5px;
position: absolute;
background-color: ${({theme}) => theme.colors.storiesLolliPink};
border-radius: 25%;
right: 158px;
bottom: 187px;
`;
const Exploder1 = styled(Exploder)`
opacity: 0;
transform: rotate(45deg) translate(0, 0);
[active] & {
animation: ${trajectory('45deg', '-70px')} 0.3s 0.3s ease-out forwards;
}
`;
const Exploder2 = styled(Exploder)`
opacity: 0;
transform: rotate(-10deg) translate(0, 0);
[active] & {
animation: ${trajectory('-10deg', '-50px')} 0.3s 0.3s ease-out forwards;
}
`;
const Exploder3 = styled(Exploder)`
opacity: 0;
transform: rotate(100deg) translate(0, 0);
[active] & {
animation: ${trajectory('100deg', '-60px')} 0.3s 0.3s ease-out forwards;
}
`;
const draw = keyframes`
to {
stroke-dashoffset: 0;
}
`;
const Arrow = styled((props) => (
<svg
width="184px"
height="202px"
viewBox="0 0 184 202"
version="1.1"
xmlns="http://www.w3.org/2000/svg"
{...props}
>
<g
id="HiFi-v3"
stroke="none"
strokeWidth="1"
fill="none"
fillRule="evenodd"
strokeLinecap="round"
>
<g id="5C" transform="translate(-176.000000, -394.000000)">
<g
id="Group-3"
transform="translate(196.000000, 280.000000)"
stroke="#FF4F89"
strokeWidth="40"
>
<path
d="M334.343528,376.290966 C364.212765,88.6133172 291.433577,-20.5588405 116.005963,48.7744929"
id="Path-4"
transform="translate(228.434067, 202.434067) rotate(-225.000000) translate(-228.434067, -202.434067) "
/>
<polyline
id="Path-5"
strokeLinejoin="round"
transform="translate(41.711841, 172.500000) scale(-1, 1) rotate(-360.000000) translate(-41.711841, -172.500000) "
points="-5.68434189e-14 134 83.4236811 134 83.4236811 211"
/>
</g>
</g>
</g>
</svg>
))`
position: absolute;
bottom: 0;
right: 0;
z-index: 3;
[active] & path,
[active] & polyline {
stroke-dasharray: 1000;
stroke-dashoffset: -1000;
animation: ${draw} 0.3s linear forwards;
}
`;
const Curve = styled(AmpImage).attrs({
src: '/static/stories/story5/curve.svg',
layout: 'fixed',
width: '434px',
height: '187px',
})`
position: absolute;
left: 0;
bottom: 0;
transform: translate(-63%, -7%) rotate(0deg);
`;
const Page = styled((props) => <AmpStoryPage {...props} />)`
&[active] ${Button} {
animation: ${tada} 0.5s 0.3s ease-in-out;
}
&[active] ${Curve} {
animation: ${rotate} 8s linear infinite;
}
`;
const StoryPage3 = () => (
<Page id="click-cta" backgroundColor="storiesBkLolliPink">
<amp-story-grid-layer template="fill">
<div>
<Exploder1 />
<Exploder2 />
<Exploder3 />
<Arrow />
<Curve />
</div>
</amp-story-grid-layer>
<amp-story-grid-layer template="vertical">
<BannerWrapper>
<TextHighlightBanner>And your CTAs</TextHighlightBanner>
<TextHighlightBanner>can live</TextHighlightBanner>
<TextHighlightBanner>anywhere on</TextHighlightBanner>
<TextHighlightBanner>your pages</TextHighlightBanner>
</BannerWrapper>
</amp-story-grid-layer>
<amp-story-grid-layer template="fill">
<ButtonWrapper>
<Button href="https://amp.dev/about/stories/">You can click me</Button>
</ButtonWrapper>
</amp-story-grid-layer>
</Page>
);
export default StoryPage3;
|
src/Home.js
|
camposa03/FormDemo
|
import React, { Component } from 'react';
import { Link } from 'react-router-dom';
class Home extends Component {
render() {
return (
<div>
<h2><Link to="/form">Apply</Link></h2>
</div>
);
}
}
export default Home;
|
app/app.js
|
commanderking/alliancechemistry
|
/**
* app.js
*
* This is the entry file for the application, only setup and boilerplate
* code.
*/
// Needed for redux-saga es6 generator support
import 'babel-polyfill';
// Import all the third party stuff
import React from 'react';
import ReactDOM from 'react-dom';
import { Provider } from 'react-redux';
import { applyRouterMiddleware, Router, browserHistory } from 'react-router';
import { syncHistoryWithStore } from 'react-router-redux';
import FontFaceObserver from 'fontfaceobserver';
import { useScroll } from 'react-router-scroll';
import 'sanitize.css/sanitize.css';
// Import root app
import App from 'containers/App';
// Import selector for `syncHistoryWithStore`
import { makeSelectLocationState } from 'containers/App/selectors';
// Import Language Provider
import LanguageProvider from 'containers/LanguageProvider';
// Load the favicon, the manifest.json file and the .htaccess file
/* eslint-disable import/no-webpack-loader-syntax */
import '!file-loader?name=[name].[ext]!./favicon.ico';
import '!file-loader?name=[name].[ext]!./manifest.json';
import 'file-loader?name=[name].[ext]!./.htaccess'; // eslint-disable-line import/extensions
/* eslint-enable import/no-webpack-loader-syntax */
import configureStore from './store';
// Import i18n messages
import { translationMessages } from './i18n';
// Import CSS reset and Global Styles
import './global-styles';
// Import routes
import createRoutes from './routes';
// Observe loading of Open Sans (to remove open sans, remove the <link> tag in
// the index.html file and this observer)
const openSansObserver = new FontFaceObserver('Open Sans', {});
// When Open Sans is loaded, add a font-family using Open Sans to the body
openSansObserver.load().then(() => {
document.body.classList.add('fontLoaded');
}, () => {
document.body.classList.remove('fontLoaded');
});
// Create redux store with history
// this uses the singleton browserHistory provided by react-router
// Optionally, this could be changed to leverage a created history
// e.g. `const browserHistory = useRouterHistory(createBrowserHistory)();`
const initialState = {};
const store = configureStore(initialState, browserHistory);
// Sync history and store, as the react-router-redux reducer
// is under the non-default key ("routing"), selectLocationState
// must be provided for resolving how to retrieve the "route" in the state
const history = syncHistoryWithStore(browserHistory, store, {
selectLocationState: makeSelectLocationState(),
});
// Set up the router, wrapping all Routes in the App component
const rootRoute = {
component: App,
childRoutes: createRoutes(store),
};
const render = (messages) => {
ReactDOM.render(
<Provider store={store}>
<LanguageProvider messages={messages}>
<Router
history={history}
routes={rootRoute}
render={
// Scroll to top when going to a new page, imitating default browser
// behaviour
applyRouterMiddleware(useScroll())
}
/>
</LanguageProvider>
</Provider>,
document.getElementById('app')
);
};
// Hot reloadable translation json files
if (module.hot) {
// modules.hot.accept does not accept dynamic dependencies,
// have to be constants at compile-time
module.hot.accept('./i18n', () => {
render(translationMessages);
});
}
// Chunked polyfill for browsers without Intl support
if (!window.Intl) {
(new Promise((resolve) => {
resolve(import('intl'));
}))
.then(() => Promise.all([
import('intl/locale-data/jsonp/en.js'),
import('intl/locale-data/jsonp/de.js'),
]))
.then(() => render(translationMessages))
.catch((err) => {
throw err;
});
} else {
render(translationMessages);
}
// Install ServiceWorker and AppCache in the end since
// it's not most important operation and if main code fails,
// we do not want it installed
if (process.env.NODE_ENV === 'production') {
require('offline-plugin/runtime').install(); // eslint-disable-line global-require
}
|
src/FlexBox.js
|
RafalFilipek/just-box
|
// @flow
import React from 'react';
import omit from 'lodash/omit';
import Box, { type BoxProps } from './Box';
import isReactNative from './isReactNative';
type FlexProps = {
f1?: boolean,
f2?: boolean,
f3?: boolean,
f4?: boolean,
row?: boolean,
column?: boolean,
wrap?: boolean,
alignStart?: boolean,
alignEnd?: boolean,
alignCenter?: boolean,
alignBaseline?: boolean,
alignStretch?: boolean,
selfStart?: boolean,
selfEnd?: boolean,
selfCenter?: boolean,
selfBaseline?: boolean,
selfStretch?: boolean,
justifyStart?: boolean,
justifyEnd?: boolean,
justifyCenter?: boolean,
justifyBetween?: boolean,
justifyAround?: boolean,
contentStart?: boolean,
contentEnd?: boolean,
contentCenter?: boolean,
contentBetween?: boolean,
contentAround?: boolean,
contentStretch?: boolean,
};
const flexMap = {
f1: { name: 'flex', value: 1 },
f2: { name: 'flex', value: 2 },
f3: { name: 'flex', value: 3 },
f4: { name: 'flex', value: 4 },
row: { name: 'flexDirection', value: 'row' },
column: { name: 'flexDirection', value: 'column' },
wrap: { name: 'flexWrap', value: 'wrap' },
alignStart: { name: 'alignItems', value: 'flex-start' },
alignEnd: { name: 'alignItems', value: 'flex-end' },
alignCenter: { name: 'alignItems', value: 'center' },
alignBaseline: { name: 'alignItems', value: 'baseline' },
alignStretch: { name: 'alignItems', value: 'stretch' },
selfStart: { name: 'alignSelf', value: 'flex-start' },
selfEnd: { name: 'alignSelf', value: 'flex-end' },
selfCenter: { name: 'alignSelf', value: 'center' },
selfBaseline: { name: 'alignSelf', value: 'baseline' },
selfStretch: { name: 'alignSelf', value: 'stretch' },
justifyStart: { name: 'justifyContent', value: 'flex-start' },
justifyEnd: { name: 'justifyContent', value: 'flex-end' },
justifyCenter: { name: 'justifyContent', value: 'center' },
justifyBetween: { name: 'justifyContent', value: 'space-between' },
justifyAround: { name: 'justifyContent', value: 'space-around' },
contentStart: { name: 'justifyContent', value: 'flex-end' },
contentEnd: { name: 'alignContent', value: 'flex-start' },
contentCenter: { name: 'alignContent', value: 'center' },
contentBetween: { name: 'alignContent', value: 'flex-end' },
contentAround: { name: 'alignContent', value: 'space-around' },
contentStretch: { name: 'alignContent', value: 'stretch' },
};
const flexKeys = Object.keys(flexMap);
type FlexBoxProps = FlexProps & BoxProps;
const FlexBox = (props: FlexBoxProps) => {
const flex = Object.keys(props).reduce((memo, name) => {
const el = flexMap[name];
if (el) {
memo[el.name] = el.value;
}
return memo;
}, {});
const additionalStyles = isReactNative ? {} : { display: 'flex' };
return <Box {...additionalStyles} {...flex} {...omit(props, flexKeys)} />;
};
FlexBox.displayName = 'Flex(Box)';
export default FlexBox;
|
linksa/CalendarInfo.js
|
liuhui219/linksa
|
import React from 'react';
import {
View,
StyleSheet,
Navigator,
TouchableOpacity,
TouchableHighlight,
Text,
ToastAndroid,
ActivityIndicator,
TextInput,
ScrollView,
Dimensions,
BackAndroid,
Image
} from 'react-native';
import Communications from 'react-native-communications';
import Icon from 'react-native-vector-icons/FontAwesome';
import Token from './Token';
export default class ContactInfo extends React.Component {
constructor(props) {
super(props);
this._pressButton = this._pressButton.bind(this);
BackAndroid.addEventListener('hardwareBackPress', this._pressButton);
this.state = {id: '',uid:'',datas:{},dataA:[],imgs:[],textaera:'',loaded: false,};
}
_pressButton() {
const { navigator } = this.props;
if(navigator) {
//ๅพ็ๆๅง๏ผๅ
ฅๆ ๅบๆ ~ ๆๅฝๅ็้กต้ขpopๆ๏ผ่ฟ้ๅฐฑ่ฟๅๅฐไบไธไธไธช้กต้ขไบ
navigator.pop();
return true;
}
return false;
}
componentDidMount() {
//่ฟ้่ทๅไผ ้่ฟๆฅ็ๅๆฐ: name
this.setState({
id: this.props.id,
uid: this.props.uid,
});
this.timer = setTimeout(
() => {this.fetchData('' + data.data.domain + '/index.php?app=Calendar2&m=CalendarApi&a=Calendar_list&uid='+this.props.uid+'&id='+this.props.id+'&access_token=' + data.data.token + '');},800);
}
componentWillUnmount() {
this.timer && clearTimeout(this.timer);
BackAndroid.removeEventListener('hardwareBackPress', this._pressButton);
}
fetchData(url) {
fetch(url)
.then((response) => response.json())
.then((responseData) => {
this.setState({
datas: responseData.array,
dataA : responseData.list,
loaded: true,
});
var aa=[];
var that=this;
if(responseData.list != null){
responseData.list.forEach((img, i) => {
key={i}
var IMG = {uri:data.data.domain.slice(0,-6) + img.src.slice(1)}
aa.push(IMG)
that.setState({
imgs: aa,
});
})
}
})
.done(
);
}
toQueryString(obj) {
return obj ? Object.keys(obj).sort().map(function (key) {
var val = obj[key];
if (Array.isArray(val)) {
return val.sort().map(function (val2) {
return encodeURIComponent(key) + '=' + encodeURIComponent(val2);
}).join('&');
}
return encodeURIComponent(key) + '=' + encodeURIComponent(val);
}).join('&') : '';
}
trim(str)
{
return str.replace(/(^\s*)|(\s*$)/g, ""); ใใ
}
_send(){
this.setState({
loaded: false,
});
var that = this
if(this.trim(this.state.textaera) == ''){
ToastAndroid.show('่ฏ่ฎบๅ
ๅฎนไธ่ฝไธบ็ฉบ๏ผ๏ผ๏ผ', ToastAndroid.SHORT)
return false;
}else{
fetch('' + data.data.domain + '/index.php?app=Calendar2&m=CalendarApi&a=answer&access_token=' + data.data.token + '', {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
body: this.toQueryString({
'id': this.props.id,
'uid':this.props.uid,
'comment':this.state.textaera
})
})
.then(function (response) {
return response.json();
})
.then(function (result) {
if(result.statu == 1){
that.setState({
textaera: '',
loaded: true,
});
that.fetchData('' + data.data.domain + '/index.php?app=Calendar2&m=CalendarApi&a=Calendar_list&uid='+that.props.uid+'&id='+that.props.id+'&access_token=' + data.data.token + '');
}
})
}
}
render() {
return (
<View style={{flex:1,flexDirection:'column',}}>
<View style={styles.card}>
<View style={{flex:1,justifyContent:'center'}}>
<TouchableOpacity onPress={this._pressButton.bind(this)}>
<View style={{justifyContent:'flex-start',flexDirection:'row',alignItems:'center',}}>
<Image source={require('./imgs/back.png')} style={{width: 25, height: 25,marginLeft:5,}} />
<Text allowFontScaling={false} adjustsFontSizeToFit={false} style={{color:'white',fontSize:16,marginLeft:-5,}}>่ฟๅ</Text>
</View>
</TouchableOpacity>
</View>
<View style={{flex:1,alignItems:'center',justifyContent:'center'}}>
<View style={{justifyContent:'center',flexDirection:'row',alignItems:'center'}}>
<Text allowFontScaling={false} adjustsFontSizeToFit={false} style={{color:'white',fontSize:18}}>ๆฅ็จ่ฏฆๆ
</Text>
</View>
</View>
<View style={{flex:1,justifyContent:'center'}}>
</View>
</View>
<ScrollView style={{flex:1,flexDirection:'column',backgroundColor:'#fff'}}>
<View style={{backgroundColor:'#fff',flexDirection:'column',}}>
<View style={{borderBottomWidth:0.5,borderColor:'#bbb',flexDirection:'row',height:50,alignItems:'center',paddingLeft:15,flex:1, }}>
<Icon name="calendar" color="#666"size={20} />
<Text allowFontScaling={false} adjustsFontSizeToFit={false} style={{fontSize:16,paddingLeft:5,}}>{this.state.datas.type}</Text>
</View>
<View style={{borderBottomWidth:0.5,borderColor:'#bbb',flexDirection:'column',height:60,marginLeft:15,justifyContent:'center', }}>
<Text allowFontScaling={false} adjustsFontSizeToFit={false} style={{fontSize:16,}}>
{this.state.datas.title}
</Text>
<Text allowFontScaling={false} adjustsFontSizeToFit={false} style={{fontSize:14,color:'#aaa',paddingTop:5,}}>
{this.state.datas.start}โโ{this.state.datas.end}
</Text>
</View>
<View style={{marginLeft:15,flexDirection:'row',borderBottomWidth:0.5,borderColor:'#bbb',alignItems:'center',justifyContent:'space-between',height:50,paddingRight:15,}}>
<Text allowFontScaling={false} adjustsFontSizeToFit={false}>ไผๅ
็ญ็บง</Text>
<Text allowFontScaling={false} adjustsFontSizeToFit={false}>{this.state.datas.important_name}</Text>
</View>
<View style={{marginLeft:15,flexDirection:'row',borderBottomWidth:0.5,borderColor:'#bbb',alignItems:'center',justifyContent:'space-between',height:50,paddingRight:15,}}>
<Text allowFontScaling={false} adjustsFontSizeToFit={false}>ๆๅ้็ฅ</Text>
<Text allowFontScaling={false} adjustsFontSizeToFit={false}>{this.state.datas.tixintime}</Text>
</View>
<View style={{flexDirection:'row',borderBottomWidth:1,borderColor:'#bbb',alignItems:'center',paddingRight:15,paddingTop:15,paddingBottom:15,}}>
<Text allowFontScaling={false} adjustsFontSizeToFit={false} style={{width:80,marginLeft:15,alignSelf:'flex-start',}}>ๅ
ๅฎน</Text>
<Text allowFontScaling={false} adjustsFontSizeToFit={false} style={{flexWrap:'wrap',flex:1,fontSize:14}}>{this.state.datas.contents}</Text>
</View>
</View>
<View style={{height:15,backgroundColor:'#ececec'}}></View>
<View style={{backgroundColor:'#fff',flexDirection:'column',flex:1,}}>
<View style={{borderBottomWidth:0.5,borderColor:'#bbb',flexDirection:'row',height:50,alignItems:'center',paddingLeft:15,paddingRight:15,}}>
<Icon name="comments-o" color="#666"size={20} />
<Text allowFontScaling={false} adjustsFontSizeToFit={false} style={{fontSize:16,paddingLeft:5,}}>่ฏ่ฎบ</Text>
<Text allowFontScaling={false} adjustsFontSizeToFit={false} style={{fontSize:14,paddingLeft:5,paddingLeft:10,color:'#bbb',flex:1,textAlign:'right',}}>ๅ
ฑๆ{this.state.dataA == null ? 0 : this.state.dataA.length}ๆกๅๅค</Text>
</View>
{this.state.dataA == null ? <View style={{height:100,alignItems:'center', justifyContent:'center'}}>
<Text allowFontScaling={false} adjustsFontSizeToFit={false} style={{fontSize:18,}}>ๆๆ ่ฏ่ฎบ</Text>
</View> : this.state.dataA.map((tab, i) => {
return <View key={i} style={{flexDirection:'row',paddingTop:15,paddingLeft:15,}}>
<View style={{width: 40, height: 40,borderRadius:20,backgroundColor:'#718DC1',alignItems:'center', justifyContent:'center'}}>
<Image source={this.state.imgs[i]} style={{width: 40, height: 40,borderRadius:20,}} />
</View>
<View style={{flexDirection:'column',marginLeft:15,flex:1, borderBottomWidth:0.5,borderColor:'#aaa',paddingBottom:15,paddingRight:15,}}>
<View style={{flexDirection:'row',alignItems:'center', justifyContent:'space-between'}}>
<Text allowFontScaling={false} adjustsFontSizeToFit={false}>{tab.u_name}</Text>
<Text allowFontScaling={false} adjustsFontSizeToFit={false}>{tab.time}</Text>
</View>
<Text allowFontScaling={false} adjustsFontSizeToFit={false} style={{color:'#aaa',fontSize:14,flexWrap:'wrap',flex:1,}}>{tab.comment}
</Text>
</View>
</View>
})}
</View>
</ScrollView>
{!this.state.loaded ? <View style={{justifyContent: 'center',alignItems: 'center',height:Dimensions.get('window').height,overflow:'hidden',position:'absolute',top:0,left:0,width:Dimensions.get('window').width,}}>
<View style={styles.loading}>
<ActivityIndicator color="white"/>
<Text allowFontScaling={false} adjustsFontSizeToFit={false} style={styles.loadingTitle}>ๅ ่ฝฝไธญโฆโฆ</Text>
</View>
</View> : <View></View>}
<View style={{height:60,flexDirection:'row',paddingLeft:10,paddingRight:10, backgroundColor:'#ededed',justifyContent:'center',paddingTop:10, }}>
<View style={{flex:1,borderWidth:1,borderColor:'#4385f4',borderRadius:3, height:40, }}>
<TextInput
onChangeText={(textaera) => this.setState({textaera})}
placeholderTextColor={'#999'}
style={{ color:'#666',fontSize:14, height:40,textAlignVertical:'bottom', }}
placeholder='่ฏ่ฎบๅ
ๅฎน(ๅฟ
ๅกซ)'
value={this.state.textaera}
underlineColorAndroid={'transparent'}
/>
</View>
<TouchableOpacity onPress={this._send.bind(this)} style={{backgroundColor:'#4385f4',height:40,width:70,borderRadius:3,marginLeft:10,alignItems:'center',justifyContent:'center',}}>
<Text allowFontScaling={false} adjustsFontSizeToFit={false} style={{color:'#fff',fontSize:16,}}>ๅ้</Text>
</TouchableOpacity>
</View>
</View>
);
}
}
const styles = StyleSheet.create({
tabView: {
flex: 1,
flexDirection: 'column',
backgroundColor:'#fafafa',
},
card: {
height:45,
backgroundColor:'#4385f4',
flexDirection:'row'
},
loading: {
backgroundColor: 'gray',
height: 80,
width: 100,
borderRadius: 10,
justifyContent: 'center',
alignItems: 'center',
},
loadingTitle: {
marginTop: 10,
fontSize: 14,
color: 'white'
},
default: {
height: 37,
borderWidth: 0,
borderColor: 'rgba(0,0,0,0.55)',
flex: 1,
fontSize: 13,
},
});
|
example/src/index.js
|
topcatcreatives/react-date-scroll
|
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
ReactDOM.render(
<App />,
document.getElementById('date-scroll-app')
);
|
client/src/components/Main.js
|
nickbreaton/spare-page
|
import React from 'react'
import styled from 'styled-components'
const MainStyles = styled.main`
display: flex;
flex: 1 0 auto;
flex-direction: column;
min-height: 100vh;
flex-basis: 100%;
align-items: flex-start;
margin: auto;
max-width: calc(${props => props.theme.breakpoint} - 4em);
width: 100%;
padding-top: 2em;
@media(max-width: ${props => props.theme.breakpoint}) {
max-width: 100%;
padding-top: 0em;
}
`
// IE 11 flex-box min-heigt fixe
// http://codepen.io/chriswrightdesign/pen/emQNGZ/
const Main = (props) => (
<div style={{ display: 'flex', flexDirection: 'row' }}>
<MainStyles {...props}/>
</div>
)
export default Main
|
js/components/Header.js
|
SKrishnan602/funnas1.0
|
import React from 'react';
import Relay from 'react-relay';
var ReactBootstrap = require('react-bootstrap');
class Header extends React.Component {
onReload() {
this.props.relay.forceFetch();
}
componentWillMount() {
document.body.style.backgroundColor = "#e9ebee";
}
componentWillUnmount(){
document.body.style.backgroundColor = null;
}
render() {
var Navbar = ReactBootstrap.Navbar;
var Nav = ReactBootstrap.Nav;
var NavItem = ReactBootstrap.NavItem;
var DropdownButton = ReactBootstrap.DropdownButton;
var MenuItem = ReactBootstrap.MenuItem;
var NavDropdown = ReactBootstrap.Dropdown;
return (
<div>
<Navbar inverse collapseOnSelect fluid style={{width: "100%", background: "#4267b2"}}>
<Navbar.Header style={{width: "100%" , background: "#4267b2"}}>
<Navbar.Brand>
<span>
<a href="#" style={{width: "100%", backgroundColor: "transparent",fontSize: "14px", fontWeight: "bold",
fontFamily: "Helvetica",color: "white"}}>Funnas - Place for great deals !!!</a>
</span>
</Navbar.Brand>
<Navbar.Toggle />
</Navbar.Header>
</Navbar>
</div>
);
}
}
export default Relay.createContainer(Header, {
fragments: {
},
});
|
src/parser/warrior/arms/modules/core/Execute/Rend.js
|
ronaldpereira/WoWAnalyzer
|
import React from 'react';
import { formatPercentage } from 'common/format';
import SPELLS from 'common/SPELLS';
import SpellLink from 'common/SpellLink';
import Analyzer, { SELECTED_PLAYER } from 'parser/core/Analyzer';
import Events from 'parser/core/Events';
import ExecuteRange from './ExecuteRange';
class RendAnalyzer extends Analyzer {
static dependencies = {
executeRange: ExecuteRange,
};
rends = 0;
rendsInExecuteRange = 0;
constructor(...args) {
super(...args);
this.active = this.selectedCombatant.hasTalent(SPELLS.REND_TALENT.id);
this.addEventListener(Events.cast.by(SELECTED_PLAYER).spell(SPELLS.REND_TALENT), this._onRendCast);
}
_onRendCast(event) {
this.rends += 1;
if (this.executeRange.isTargetInExecuteRange(event)) {
this.rendsInExecuteRange += 1;
event.meta = event.meta || {};
event.meta.isInefficientCast = true;
event.meta.inefficientCastReason = 'This Rend was used on a target in Execute range.';
}
}
get executeRendsThresholds() {
return {
actual: this.rendsInExecuteRange / this.rends,
isGreaterThan: {
minor: 0,
average: 0.05,
major: 0.1,
},
style: 'percent',
};
}
suggestions(when) {
when(this.executeRendsThresholds).addSuggestion((suggest, actual, recommended) => {
return suggest(<>Try to avoid using <SpellLink id={SPELLS.REND_TALENT.id} icon /> on a target in <SpellLink id={SPELLS.EXECUTE.id} icon /> range.</>)
.icon(SPELLS.REND_TALENT.icon)
.actual(`Rend was used ${formatPercentage(actual)}% of the time on a target in execute range.`)
.recommended(`${formatPercentage(recommended)}% is recommended`);
});
}
}
export default RendAnalyzer;
|
website/modules/components/Guide.js
|
asaf/react-router
|
import React from 'react'
import PropTypes from 'prop-types'
import { Redirect, Route } from 'react-router-dom'
import { Block } from 'jsxstyle'
import ScrollToDoc from './ScrollToDoc'
import MarkdownViewer from './MarkdownViewer'
// almost identical to `API`, but I'm lazy rn
const Guide = ({ match, data }) => {
const { params: { mod, header: headerParam, environment } } = match
const doc = data.guides.find(doc => mod === doc.title.slug)
const header = doc && headerParam ? doc.headers.find(h => h.slug === headerParam) : null
return !doc ? (
<Redirect to={`/${environment}`}/>
) : (
<Block
className="api-doc-wrapper"
fontSize="80%"
>
<Block className="api-doc">
<ScrollToDoc doc={doc} header={header}/>
<MarkdownViewer html={doc.markup}/>
</Block>
<Route
path={`${match.path}/:header`}
render={({ match: { params: { header: slug }}}) => {
const header = doc.headers.find(h => h.slug === slug )
return header ? (
<ScrollToDoc doc={doc} header={header}/>
) : (
<Redirect to={`/${environment}/guides/${mod}`}/>
)
}}
/>
</Block>
)
}
Guide.propTypes = {
match: PropTypes.object,
data: PropTypes.object
}
export default Guide
|
src/svg-icons/communication/invert-colors-off.js
|
ArcanisCz/material-ui
|
import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let CommunicationInvertColorsOff = (props) => (
<SvgIcon {...props}>
<path d="M20.65 20.87l-2.35-2.35-6.3-6.29-3.56-3.57-1.42-1.41L4.27 4.5 3 5.77l2.78 2.78c-2.55 3.14-2.36 7.76.56 10.69C7.9 20.8 9.95 21.58 12 21.58c1.79 0 3.57-.59 5.03-1.78l2.7 2.7L21 21.23l-.35-.36zM12 19.59c-1.6 0-3.11-.62-4.24-1.76C6.62 16.69 6 15.19 6 13.59c0-1.32.43-2.57 1.21-3.6L12 14.77v4.82zM12 5.1v4.58l7.25 7.26c1.37-2.96.84-6.57-1.6-9.01L12 2.27l-3.7 3.7 1.41 1.41L12 5.1z"/>
</SvgIcon>
);
CommunicationInvertColorsOff = pure(CommunicationInvertColorsOff);
CommunicationInvertColorsOff.displayName = 'CommunicationInvertColorsOff';
CommunicationInvertColorsOff.muiName = 'SvgIcon';
export default CommunicationInvertColorsOff;
|
src/components/GuestModal/GuestModal.js
|
joyvuu-dave/comeals-ui-react
|
// rendered by MealView
import React from 'react'
import Modal from 'react-modal'
type Props = {
data: {
open: boolean,
host: string,
resident_id: number,
multiplier: number,
vegetarian: boolean
},
actions: {
close: Function,
toggleVeg: Function,
toggleMultiplier: Function,
addGuest: Function
}
};
const customStyles = {
content: {
top: '50%',
left: '50%',
right: 'auto',
bottom: 'auto',
marginRight: '-50%',
transform: 'translate(-50%, -50%)'
}
}
export class GuestModal extends React.Component<void, Props, void> {
constructor () {
super()
this.handleAddGuestClick = this.handleAddGuestClick.bind(this)
}
handleAddGuestClick (e) {
this.props.actions.addGuest({
resident_id: this.props.data.resident_id,
multiplier: this.props.data.multiplier,
vegetarian: this.props.data.vegetarian
})
this.props.actions.close()
}
render () {
return (
<Modal
isOpen={this.props.data.open}
onRequestClose={this.props.actions.close}
style={customStyles} >
<h2>{this.props.data.host}'s Guest</h2>
<form>
<input
type='radio'
checked={this.props.data.multiplier === 2}
onChange={this.props.actions.toggleMultiplier}
name='multiplier'
value='2' />{' '}Adult{' '}
<input
type='radio'
checked={this.props.data.multiplier === 1}
onChange={this.props.actions.toggleMultiplier}
name='multiplier'
value='1' />{' '}Child{' '}
<p>{' '}</p>
<section>
<input
type='checkbox'
checked={this.props.data.vegetarian}
onChange={this.props.actions.toggleVeg} />{' '}Veg
</section>
<p>{' '}</p>
<button
type='button'
onClick={this.props.actions.close}>cancel</button>{' '}
<button
type='button'
onClick={this.handleAddGuestClick}>submit
</button>
</form>
</Modal>
)
}
}
export default GuestModal
|
src/client/react/components/presentational/Result.js
|
nloomans/rooster.hetmml.nl
|
/**
* Copyright (C) 2018 Noah Loomans
*
* This file is part of rooster.hetmml.nl.
*
* rooster.hetmml.nl is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* rooster.hetmml.nl is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with rooster.hetmml.nl. If not, see <http://www.gnu.org/licenses/>.
*
*/
import React from 'react';
import PropTypes from 'prop-types';
import classnames from 'classnames';
import users from '../../users';
import IconFromUserType from './IconFromUserType';
import './Result.scss';
class Result extends React.Component {
static propTypes = {
userId: PropTypes.string.isRequired,
isSelected: PropTypes.bool.isRequired,
onClick: PropTypes.func.isRequired,
};
render() {
const { onClick, isSelected, userId } = this.props;
return (
/* eslint-disable jsx-a11y/click-events-have-key-events */
/* eslint-disable jsx-a11y/no-static-element-interactions */
<div
className={classnames('Result', { isSelected })}
onClick={onClick}
>
<div className="iconWrapper">
<IconFromUserType userType={users.byId[userId].type} />
</div>
<div className="text">
{users.byId[userId].value}
{users.byId[userId].alt && (
<span className="alt">
{` ${users.byId[userId].alt}`}
</span>
)}
</div>
</div>
);
}
}
export default Result;
|
test/deprecate-Link-location-props-test.js
|
rackt/rackt-codemod
|
import React from 'react';
const ACTIVE = { color: 'red' };
class App extends React.Component {
render() {
return (
<div>
<h1>APP!</h1>
<ul>
<li><Link to="/" activeStyle={ACTIVE}>/</Link></li>
<li><IndexLink to="/" activeStyle={ACTIVE}>/ IndexLink</IndexLink></li>
<li><Link to="/users" activeStyle={ACTIVE}>/users</Link></li>
<li><IndexLink to="/users" activeStyle={ACTIVE}>/users IndexLink</IndexLink></li>
<li><Link to="/users/ryan" activeStyle={ACTIVE}>/users/ryan</Link></li>
<li><Link to="/users/ryan" query={{ foo: 'bar' }} activeStyle={ACTIVE}>/users/ryan?foo=bar</Link></li>
<li><Link to="/about" activeStyle={ACTIVE}>/about</Link></li>
</ul>
{this.props.children}
</div>
)
}
}
|
src/server.js
|
HasanSa/hackathon
|
import Express from 'express';
import React from 'react';
import ReactDOM from 'react-dom/server';
import config from './config';
import favicon from 'serve-favicon';
import compression from 'compression';
import httpProxy from 'http-proxy';
import path from 'path';
import createStore from './redux/create';
import ApiClient from './helpers/ApiClient';
import Html from './helpers/Html';
import PrettyError from 'pretty-error';
import http from 'http';
import { match } from 'react-router';
import { syncHistoryWithStore } from 'react-router-redux';
import { ReduxAsyncConnect, loadOnServer } from 'redux-async-connect';
import createHistory from 'react-router/lib/createMemoryHistory';
import {Provider} from 'react-redux';
import getRoutes from './routes';
const targetUrl = config.apiHost + ':' + config.apiPort;
const pretty = new PrettyError();
const app = new Express();
const server = new http.Server(app);
const proxy = httpProxy.createProxyServer({
target: targetUrl,
changeOrigin: true,
ws: false
});
function guid() {
function s4() {
return Math.floor((1 + Math.random()) * 0x10000)
.toString(16)
.substring(1);
}
return s4() + s4() + '-' + s4() + '-' + s4() + '-' +
s4() + '-' + s4() + s4() + s4();
}
app.use(compression());
app.use(favicon(path.join(__dirname, '..', 'static', 'favicon.ico')));
app.use(Express.static(path.join(__dirname, '..', 'static')));
// Proxy to API server
app.use('/api', (req, res) => {
const reqId = guid();
const requestTimeRecived = (new Date()).getTime();
res.on('finish', () => console.log('Proxy request ID: ' + reqId + ' was processed in ' + ((new Date()).getTime() - requestTimeRecived) + ' milliseconds. Status: 200'));
console.log('Proxy received request id: ' + reqId + ' to URL: ' + req.url);
proxy.web(req, res, {target: targetUrl}, function() {
console.log('Proxy request ID: ' + reqId + ' was processed in ' + ((new Date()).getTime() - requestTimeRecived) + ' milliseconds. Status: error');
});
});
app.use('/ws', (req, res) => {
proxy.web(req, res, {target: targetUrl + '/ws'});
});
server.on('upgrade', (req, socket, head) => {
proxy.ws(req, socket, head);
});
// added the error handling to avoid https://github.com/nodejitsu/node-http-proxy/issues/527
proxy.on('error', (error, req, res) => {
let json;
if (error.code !== 'ECONNRESET') {
console.error('proxy error', error);
}
if (!res.headersSent) {
res.writeHead(500, {'content-type': 'application/json'});
}
console.log('Proxy error for url request: ' + req.url + '. Error is: ' + error.message );
json = {error: 'proxy_error', reason: error.message};
res.end(JSON.stringify(json));
});
app.use((req, res) => {
if (__DEVELOPMENT__) {
// Do not cache webpack stats: the script file would change since
// hot module replacement is enabled in the development env
webpackIsomorphicTools.refresh();
}
const client = new ApiClient(req);
const memoryHistory = createHistory(req.originalUrl);
const store = createStore(memoryHistory, client);
const history = syncHistoryWithStore(memoryHistory, store);
function hydrateOnClient() {
res.send('<!doctype html>\n' +
ReactDOM.renderToString(<Html assets={webpackIsomorphicTools.assets()} store={store}/>));
}
if (__DISABLE_SSR__) {
hydrateOnClient();
return;
}
const reqId = guid();
const requestTimeRecived = (new Date()).getTime();
match({ history, routes: getRoutes(store), location: req.originalUrl }, (error, redirectLocation, renderProps) => {
if (redirectLocation) {
res.redirect(redirectLocation.pathname + redirectLocation.search);
console.log('Request ID: ' + reqId + ' , to URL: ' + req.url + ' was processed in ' + ((new Date()).getTime() - requestTimeRecived) + ' milliseconds. Status: redirect');
} else if (error) {
console.error('ROUTER ERROR:', pretty.render(error));
res.status(500);
hydrateOnClient();
console.log('Request ID: ' + reqId + ' , to URL: ' + req.url + ' was processed in ' + ((new Date()).getTime() - requestTimeRecived) + ' milliseconds. Status: 500');
} else if (renderProps) {
loadOnServer({...renderProps, store, helpers: {client}, filter: item => !item.deferred}).then(() => {
const component = (
<Provider store={store} key="provider">
<ReduxAsyncConnect {...renderProps}/>
</Provider>
);
res.status(200);
global.navigator = {userAgent: req.headers['user-agent']};
res.send('<!doctype html>\n' +
ReactDOM.renderToString(<Html assets={webpackIsomorphicTools.assets()} component={component} store={store}/>));
console.log('Request ID: ' + reqId + ' , to URL: ' + req.url + ' was processed in ' + ((new Date()).getTime() - requestTimeRecived) + ' milliseconds. Status: 200');
});
} else {
res.status(404).send('Not found');
console.log('Request ID: ' + reqId + ' , to URL: ' + req.url + ' was processed in ' + ((new Date()).getTime() - requestTimeRecived) + ' milliseconds. Status: 404');
}
});
});
if (config.port) {
server.listen(config.port, (err) => {
if (err) {
console.error(err);
}
console.info('----\n==> โ
%s is running, talking to API server on %s.', config.app.title, config.apiPort);
console.info('==> ๐ป Open http://%s:%s in a browser to view the app.', config.host, config.port);
});
} else {
console.error('==> ERROR: No PORT environment variable has been specified');
}
|
examples/js/selection/multi-select-table.js
|
dana2208/react-bootstrap-table
|
/* eslint max-len: 0 */
import React from 'react';
import { BootstrapTable, TableHeaderColumn } from 'react-bootstrap-table';
const products = [];
function addProducts(quantity) {
const startId = products.length;
for (let i = 0; i < quantity; i++) {
const id = startId + i;
products.push({
id: id,
name: 'Item name ' + id,
price: 2100 + i
});
}
}
addProducts(5);
const selectRowProp = {
mode: 'checkbox'
};
export default class MultiSelectTable extends React.Component {
render() {
return (
<BootstrapTable data={ products } selectRow={ selectRowProp }>
<TableHeaderColumn dataField='id' isKey={ true }>Product ID</TableHeaderColumn>
<TableHeaderColumn dataField='name'>Product Name</TableHeaderColumn>
<TableHeaderColumn dataField='price'>Product Price</TableHeaderColumn>
</BootstrapTable>
);
}
}
|
wrappers/md.js
|
ahonn/gatsby-blog
|
/* eslint-disable */
import React from 'react'
import Helmet from 'react-helmet'
import { config } from 'config'
import Article from '../src/layouts/Article'
import Page from '../src/layouts/Page'
module.exports = React.createClass({
propTypes () {
return {
router: React.PropTypes.object,
}
},
render () {
const { page } = this.props.route
const { layout } = page.data
if (layout === 'page') {
return <Page {...this.props} />
}
return (
<Article {...this.props} />
)
},
})
|
src/containers/SalesChance/Information/Information.js
|
UncleYee/crm-ui
|
import React from 'react';
import ChanceInfo from './ChanceInfo';
export default class Information extends React.Component {
static propTypes = {
dataInfo: React.PropTypes.object,
editFlag: React.PropTypes.string,
updateChanceData: React.PropTypes.func,
updateLogInfo: React.PropTypes.func,
};
constructor(props) {
super(props);
}
render() {
const dataInfo = this.props.dataInfo || {};
// console.log(this.props.chanceInfo);
return (
<div>
{ /* ๆบไผ่ตๆ */ }
<ChanceInfo updateLogInfo={this.props.updateLogInfo} updateChanceData={this.props.updateChanceData} editFlag={this.props.editFlag} dataInfo={dataInfo} />
</div>
);
}
}
|
react/react-svg/src/index.js
|
yuanzhaokang/myAwesomeSimpleDemo
|
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/features/movie-detail-tv/index.js
|
rldona/react-native-tab-view-seed
|
import React, { Component } from 'react';
import {
Text,
Image,
View,
TouchableOpacity,
ScrollView,
StyleSheet,
Dimensions,
Share,
InteractionManager
} from 'react-native';
import {connect} from 'react-redux';
import {bindActionCreators} from 'redux';
import * as historialActions from '../../redux/actions/historialActions';
import * as firebase from 'firebase';
import * as userService from '../../services/user-service';
import * as themoviedb from '../../services/movies-service';
import * as colors from '../../common/colors';
import Icon from 'react-native-vector-icons/MaterialIcons';
import Header from '../../common/header';
import Loading from '../../common/loading';
import Score from '../../common/score';
import SwitchLists from '../../common/switch-lists';
import MoviesListHorizontal from '../../common/movie-list-horizontal';
const { width, height } = Dimensions.get('window');
class MovieDetailTv extends Component {
constructor(props) {
super(props);
this.state = {
// movie: null,
// loaded: false,
movie: themoviedb.getCurrentMovie(),
loaded: true,
cast: {
director: '-',
writer: '-',
actors: []
},
overviewNumberLines: 2
}
}
componentWillMount() {
InteractionManager.runAfterInteractions(() => {
themoviedb.getMovie('tv', themoviedb.getCurrentMovie().id).then((data) => {
this.setState({
movie: data,
loaded: true
});
});
themoviedb.getCredits('tv', themoviedb.getCurrentMovie().id).then((data) => {
let cast = {
actors: [
data.cast[0].name,
data.cast[1].name,
data.cast[2].name,
data.cast[3].name,
data.cast[4].name
]
};
this.setState({cast: cast});
}).catch((error) => {
console.log(error);
});
});
}
_onActionSelected = (action) => {
switch (action) {
case 'left':
themoviedb.getNavigator().pop();
break;
case 'right':
this.share();
break;
}
}
share() {
Share.share({
message: 'Te recomiendo esta serie: https://filmist.es/movies/' + this.state.movie.id
})
.then(() => console.log('ok'))
.catch((error) => this.setState({result: 'error: ' + error.message}));
}
_onExtendOverview = () => {
if (this.state.overviewNumberLines <= 2) {
this.setState({overviewNumberLines: 100});
} else {
this.setState({overviewNumberLines: 2});
}
}
_renderMoreLinesText = () => {
if (this.state.overviewNumberLines <= 2) {
return 'LEER MรS';
} else {
return 'LEER MENOS';
}
}
_renderMoreLinesIcon = () => {
if (this.state.overviewNumberLines <= 2) {
return 'expand-more';
} else {
return 'expand-less';
}
}
renderSwitchLists() {
let currentUser = userService.getCurrentUser();
return (
<SwitchLists user={currentUser} />
);
}
renderInfoPlus() {
if (this.state.cast.actors.length === 0) {
return (
<View style={{paddingHorizontal: 15, paddingVertical: 10, backgroundColor: colors.getList().secondary}}>
<View style={{flexDirection: 'row', alignItems: 'flex-start', justifyContent: 'space-between', marginBottom: 15}}>
<View>
<Text style={{fontSize: 15, color: "#FFF", marginBottom: 10, fontWeight: '400', backgroundColor: '#333', paddingVertical: 5, width: 150}}></Text>
<Text style={{fontSize: 12, color: "#CCC", marginBottom: 0, fontWeight: '400', backgroundColor: '#333', paddingVertical: 5, width: width - 50}}></Text>
</View>
</View>
<View>
<Text style={{fontSize: 15, color: "#FFF", marginBottom: 10, fontWeight: '400', backgroundColor: '#333', paddingVertical: 5, width: 150}}></Text>
<Text style={{fontSize: 12, color: "#CCC", marginBottom: 0, fontWeight: '400', backgroundColor: '#333', paddingVertical: 5, width: width - 50}}></Text>
</View>
</View>
);
}
return (
<View style={{paddingHorizontal: 15, paddingVertical: 15, backgroundColor: colors.getList().secondary}}>
<View style={{flexDirection: 'row', alignItems: 'flex-start', justifyContent: 'space-between', marginBottom: 10}}>
<View>
<Text style={{fontSize: 15, color: "#FFF", marginBottom: 3, fontWeight: '400'}}>Temporadas</Text>
<Text style={{fontSize: 12, color: "#CCC", marginBottom: 8, fontWeight: '400'}}>{this.state.movie.number_of_seasons}</Text>
</View>
<View style={{minWidth: 100}}>
<Text style={{fontSize: 15, color: "#FFF", marginBottom: 3, fontWeight: '400'}}>Capรญtulos</Text>
<Text style={{fontSize: 12, color: "#CCC", marginBottom: 8, fontWeight: '400'}}>{this.state.movie.number_of_episodes}</Text>
</View>
<View style={{minWidth: 60}}>
<Text style={{fontSize: 15, color: "#FFF", marginBottom: 3, fontWeight: '400'}}>Aรฑo</Text>
<Text style={{fontSize: 12, color: "#CCC", marginBottom: 0, fontWeight: '400'}}>{this.state.movie.first_air_date.split('-')[0]}</Text>
</View>
</View>
<View>
<Text style={{fontSize: 15, color: "#FFF", marginBottom: 3, fontWeight: '400'}}>Reparto</Text>
<Text style={{fontSize: 12, color: "#CCC", marginBottom: 8, fontWeight: '400'}}>{this.state.cast.actors[0]}, {this.state.cast.actors[1]}, {this.state.cast.actors[2]}, {this.state.cast.actors[3]}, {this.state.cast.actors[4]}</Text>
</View>
</View>
);
}
render() {
if (!this.state.loaded) {
return (
<View style={{backgroundColor: colors.getList().primary, height: height}}>
<View style={{backgroundColor: colors.getList().secondary, height: 190}}>
<Header
isTransparent={true}
title=""
actions={{ left: { icon: 'arrow-back' }, right: { icon: 'share' } }}
onActionSelected={this._onActionSelected.bind(this)} />
</View>
<View style={{padding: 0, marginTop: 0}}>
<View style={{padding: 15}}>
<View style={{marginVertical: 10, marginBottom: 20}}>
<Text style={{width: width-200, height: 20, backgroundColor: '#222'}}></Text>
</View>
<View>
<Text style={{width: width-150, height: 20, backgroundColor: colors.getList().secondary, marginBottom: 10}}></Text>
<Text style={{width: width-40, height: 20, backgroundColor: colors.getList().secondary, marginBottom: 10}}></Text>
<Text style={{width: width-40, height: 20, backgroundColor: colors.getList().secondary, marginBottom: 10}}></Text>
<Text style={{width: width-40, height: 20, backgroundColor: colors.getList().secondary, marginBottom: 10}}></Text>
</View>
</View>
<View style={{height: height, backgroundColor: '#000', paddingHorizontal: 15, paddingVertical: 20}}>
<Text style={{width: width-150, height: 20, backgroundColor: '#111', marginBottom: 10}}></Text>
<Text style={{width: width-150, height: 20, backgroundColor: '#111', marginBottom: 10}}></Text>
<Text style={{width: width-150, height: 20, backgroundColor: '#111', marginBottom: 10}}></Text>
<Text style={{width: width-150, height: 20, backgroundColor: '#111', marginBottom: 10}}></Text>
</View>
</View>
</View>
);
}
return (
<ScrollView
renderToHardwareTextureAndroid={true}
showsVerticalScrollIndicator={false}
style={{ backgroundColor: colors.getList().primary, height: height }}>
<View>
<Image
resizeMode={'cover'}
style={{height: 200, backfaceVisibility: 'hidden', borderBottomWidth: 0, borderColor: colors.getList().app}}
source={{uri: 'http://image.tmdb.org/t/p/w500' + this.state.movie.backdrop_path}}>
<View style={{position: 'absolute', top: 0, left:0 , width: width, height: 200, backgroundColor: 'rgba(0, 0, 0, 0.25)'}}></View>
<Header
isTransparent={true}
title=""
actions={{ left: { icon: 'arrow-back' }, right: { icon: 'share' } }}
onActionSelected={this._onActionSelected.bind(this)} />
</Image>
</View>
<View style={{padding: 0, marginTop: 0}}>
<View style={{padding: 15, paddingBottom: 10}}>
<Text style={{fontSize: 18, fontWeight: '600', color: '#FFF', marginBottom: 2}}>
{this.state.movie.name}
</Text>
<View style={{marginTop: 5}}>
<Score score={this.state.movie.vote_average} />
</View>
<Text
numberOfLines={this.state.overviewNumberLines}
style={{fontSize: 15, lineHeight: 26, fontWeight: '300', color: '#FFF', marginTop: 0, marginBottom: 0, textAlign: 'auto' }}>
{this.state.movie.overview ? this.state.movie.overview : 'Sinopsis no disponible'}
</Text>
<View style={{paddingVertical: 5}}></View>
{
this.state.movie.overview ?
<TouchableOpacity
style={{flexDirection: 'row', alignItems: 'center', alignSelf: 'center', marginBottom: 0}}
onPress={this._onExtendOverview}
activeOpacity={0.9}>
<Text style={{textAlign: 'center', color: '#666', fontSize: 12}}>
{this._renderMoreLinesText()}
</Text>
<Icon color='#666' name={this._renderMoreLinesIcon()} style={{fontSize: 25}} />
</TouchableOpacity> : null
}
</View>
</View>
<SwitchLists movie={this.state.movie} />
{this.renderInfoPlus()}
<MoviesListHorizontal
title="Descubre del mismo gรฉnero"
type="tv"
collection="similar"
position="horizontal"
{...this.props} />
<View style={{paddingVertical: 10}}></View>
</ScrollView>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
},
bgFake: {
height: 220,
},
button: {
backgroundColor: '#AAA',
padding: 20
},
infoContainer: {
flex: 1,
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'space-between',
width: 200,
position: 'absolute',
top: -48,
left: 140,
},
infoItem: {
fontSize: 15,
marginBottom: 10,
backgroundColor: colors.getList().secondary,
padding: 10,
color: '#FFF',
minWidth: 60,
textAlign: 'center',
marginRight: 10,
borderRadius: 3
},
infoItemFake: {
fontSize: 15,
marginBottom: 10,
backgroundColor: colors.getList().secondary,
padding: 10,
color: colors.getList().secondary,
minWidth: 60,
textAlign: 'center',
marginRight: 10,
borderRadius: 3
},
extendInfo: {
elevation: 10,
backgroundColor: '#171717',
padding: 15,
marginBottom: 10
},
extendInfoRow: {
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'flex-start',
paddingVertical: 5
},
extendInfoTitle: {
color: '#999',
minWidth: 130
},
extendInfoText: {
color: '#FFF'
}
});
function mapStateToProps(state, ownProps) {
return {
historial: state.historial
};
}
function mapDispatchToProps(dispatch) {
return {
actions: {
historial: bindActionCreators(historialActions, dispatch)
}
};
}
export default connect(mapStateToProps, mapDispatchToProps)(MovieDetailTv);
|
src/Containers/NotificationsContainer.js
|
sashasushko/moira-front
|
// @flow
import React from 'react';
import type { ContextRouter } from 'react-router-dom';
import type { IMoiraApi } from '../Api/MoiraAPI';
import type { Notification } from '../Domain/Notification';
import { withMoiraApi } from '../Api/MoiraApiInjection';
import Layout from '../Components/Layout/Layout';
type Props = ContextRouter & { moiraApi: IMoiraApi };
type State = {|
loading: boolean;
error: boolean;
list: ?Array<Notification>;
total: number;
|};
class NotificationsContainer extends React.Component {
props: Props;
state: State = {
loading: true,
error: true,
list: null,
total: 0,
};
componentDidMount() {
this.getData();
}
async getData(): Promise<void> {
const { moiraApi } = this.props;
try {
const notifications = await moiraApi.getNotificationList();
this.setState({ loading: false, ...notifications });
}
catch (error) {
this.setState({ error: true });
}
}
render(): React.Element<*> {
const { loading, error, list } = this.state;
return (
<Layout loading={loading} loadingError={error}>
<Layout.Content>
<pre>{JSON.stringify(list, null, 2)}</pre>
</Layout.Content>
</Layout>
);
}
}
export default withMoiraApi(NotificationsContainer);
|
src/components/ui/FeatureList.js
|
meetfranz/franz
|
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { defineMessages, intlShape } from 'react-intl';
import { FeatureItem } from './FeatureItem';
import { PLANS } from '../../config';
const messages = defineMessages({
availableRecipes: {
id: 'pricing.features.recipes',
defaultMessage: '!!!Choose from more than 70 Services',
},
accountSync: {
id: 'pricing.features.accountSync',
defaultMessage: '!!!Account Synchronisation',
},
desktopNotifications: {
id: 'pricing.features.desktopNotifications',
defaultMessage: '!!!Desktop Notifications',
},
unlimitedServices: {
id: 'pricing.features.unlimitedServices',
defaultMessage: '!!!Add unlimited services',
},
upToThreeServices: {
id: 'pricing.features.upToThreeServices',
defaultMessage: '!!!Add up to 3 services',
},
upToSixServices: {
id: 'pricing.features.upToSixServices',
defaultMessage: '!!!Add up to 6 services',
},
spellchecker: {
id: 'pricing.features.spellchecker',
defaultMessage: '!!!Spellchecker support',
},
workspaces: {
id: 'pricing.features.workspaces',
defaultMessage: '!!!Workspaces',
},
customWebsites: {
id: 'pricing.features.customWebsites',
defaultMessage: '!!!Add Custom Websites',
},
onPremise: {
id: 'pricing.features.onPremise',
defaultMessage: '!!!On-premise & other Hosted Services',
},
thirdPartyServices: {
id: 'pricing.features.thirdPartyServices',
defaultMessage: '!!!Install 3rd party services',
},
serviceProxies: {
id: 'pricing.features.serviceProxies',
defaultMessage: '!!!Service Proxies',
},
teamManagement: {
id: 'pricing.features.teamManagement',
defaultMessage: '!!!Team Management',
},
appDelays: {
id: 'pricing.features.appDelays',
defaultMessage: '!!!No Waiting Screens',
},
adFree: {
id: 'pricing.features.adFree',
defaultMessage: '!!!Forever ad-free',
},
appDelayEnabled: {
id: 'pricing.features.appDelaysEnabled',
defaultMessage: '!!!Occasional Waiting Screens',
},
});
export class FeatureList extends Component {
static propTypes = {
className: PropTypes.string,
featureClassName: PropTypes.string,
plan: PropTypes.oneOf(Object.keys(PLANS)),
};
static defaultProps = {
className: '',
featureClassName: '',
plan: false,
}
static contextTypes = {
intl: intlShape,
};
render() {
const {
className,
featureClassName,
plan,
} = this.props;
const { intl } = this.context;
const features = [];
if (plan === PLANS.FREE) {
features.push(
messages.appDelayEnabled,
messages.upToThreeServices,
messages.availableRecipes,
messages.accountSync,
messages.desktopNotifications,
);
} else if (plan === PLANS.PERSONAL) {
features.push(
messages.upToSixServices,
messages.spellchecker,
messages.appDelays,
messages.adFree,
);
} else if (plan === PLANS.PRO) {
features.push(
messages.unlimitedServices,
messages.workspaces,
messages.customWebsites,
// messages.onPremise,
messages.thirdPartyServices,
// messages.serviceProxies,
);
} else {
features.push(
messages.unlimitedServices,
messages.spellchecker,
messages.workspaces,
messages.customWebsites,
messages.onPremise,
messages.thirdPartyServices,
messages.serviceProxies,
messages.teamManagement,
messages.appDelays,
messages.adFree,
);
}
return (
<ul className={className}>
{features.map(feature => <FeatureItem name={intl.formatMessage(feature)} className={featureClassName} />)}
</ul>
);
}
}
export default FeatureList;
|
src/interface/icons/Intellect.js
|
fyruna/WoWAnalyzer
|
import React from 'react';
const icon = props => (
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="16 17 32 32" className="icon" {...props}>
<path d="M28.832,44.802h6.559v-1.101h-6.559V44.802z M29.91,47.004h4.402v-1.101H29.91V47.004z M32.156,18.379c-0.012,0-0.031,0-0.045,0c-0.014,0-0.033,0-0.045,0c-1.078,0-9.704,0.127-9.704,11.01 c0,2.696,1.5,4.496,2.949,6.234c1.255,1.507,2.442,2.928,2.442,4.776V42.6h8.715v-2.202c0-1.848,1.187-3.269,2.442-4.776 c1.449-1.737,2.949-3.537,2.949-6.234C41.86,18.506,33.235,18.379,32.156,18.379z" />
</svg>
);
export default icon;
|
storybook/container.js
|
Byndyusoft/ui.molecules
|
import React from 'react';
export default story => <div style={{ padding: 16 }}>{ story() }</div>;
|
src/components/Icons.js
|
stefcot/react-design-easier
|
import React from 'react';
import * as ActionTypes from './../actions/ActionTypes';
const Icons = {};
/**
*
* @type {React.Component}
*/
Icons[ActionTypes.SELECT] = class extends React.Component {
render() {
let iconId = `${this.props.name}_Icon`;
let fillId = `${this.props.name}_FILL`;
let fillIdRef = `#${fillId}`;
return React.createElement('g', null, <g id={iconId} transform="matrix( 1, 0, 0, 1, 0, 0)">
<defs>
<g id={fillId}>
<path fill={this.props.color} fillOpacity={0.5} stroke="none" d="
M 6 2
L 5 2 5 12 6 12 6 2 Z"/>
<path fill={this.props.color} stroke="none" d="
M 6 2
L 6 1 5 1 5 0 4 0 4 14 5 14 5 13 6 13 6 12 5 12 5 2 6 2
M 12 8
L 12 7 11 7 11 6 10 6 10 5 9 5 9 4 8 4 8 3 7 3 7 2 6 2
6 12 7 12 7 11 8 11 8 13 9 13 9 15 10 15 10 17 12 17 12
14 11 14 11 12 10 12 10 10 14 10 14 9 13 9 13 8 12 8 Z"/>
</g>
</defs>
<g transform="matrix( 1, 0, 0, 1, 0, 0)">
<use xlinkHref={fillIdRef}/>
</g>
</g>);
}
};
/**
*
* @type {React.Component}
*/
Icons[ActionTypes.SEND_TO_BACK] = class extends React.Component {
render() {
let iconId = `${this.props.name}_Icon`;
let fillId = `${this.props.name}_FILL`;
let fillIdRef = `#${fillId}`;
return React.createElement('g', null, <g id={iconId} transform="matrix( 1, 0, 0, 1, 0, 0)">
<defs>
<g id={fillId}>
<path fill={this.props.color} stroke="none" d="
M 9 11
L 7 11 7 12 9 12 9 11
M 10 12
L 9 12 9 13 10 13 10 12
M 5 10
L 5 11 7 11 7 10 5 10
M 1 9
L 0 9 0 10 1 10 1 9
M 1 7
L 0 7 0 8 1 8 1 7
M 3 9
L 3 8 1 8 1 9 3 9
M 5 9
L 3 9 3 10 5 10 5 9
M 4 4
L 3 4 3 5 4 5 4 4
M 2 6
L 1 6 1 7 2 7 2 6
M 2 5
L 2 6 3 6 3 5 2 5
M 5 3
L 4 3 4 4 5 4 5 3
M 6 3
L 6 2 5 2 5 3 6 3
M 7 2
L 7 1 6 1 6 2 7 2
M 8 1
L 8 0 7 0 7 1 8 1
M 10 2
L 10 1 8 1 8 2 10 2
M 16 7
L 16 6 15 6 15 7 16 7
M 16 7
L 16 8 17 8 17 7 16 7
M 12 9
L 12 10 13 10 13 9 12 9
M 12 11
L 12 10 11 10 11 11 12 11
M 11 12
L 11 11 10 11 10 12 11 12
M 13 8
L 13 9 14 9 14 10 13 10 13 11 12 11 12 12 11 12 11 13 10 13 10 14 9 14 9 13 7 13 7 12 5 12 5 11 3 11 3 10 1 10 1 11 0 11 0 12 1 12 1 13 3 13 3 14 5 14 5 15 7 15 7 16 9 16 9 17 10 17 10 16 11 16 11 15 12 15 12 14 13 14 13 13 14 13 14 12 15 12 15 11 16 11 16 10 17 10 17 9 16 9 16 8 15 8 15 8.95 14 8.95 14 8 13 8
M 15 7
L 14 7 14 8 15 8 15 7
M 12 3
L 12 2 10 2 10 3 12 3
M 14 4
L 14 3 12 3 12 4 14 4
M 16 5
L 16 4 14 4 14 5 16 5
M 17 5
L 16 5 16 6 17 6 17 5 Z"/>
</g>
</defs>
<g transform="matrix( 1, 0, 0, 1, 0,0) ">
<use xlinkHref={fillIdRef} />
</g>
</g>);
}
};
/**
*
* @type {React.Component}
*/
Icons[ActionTypes.SEND_TO_FRONT] = class extends React.Component {
render() {
let iconId = `${this.props.name}_Icon`;
let fillId = `${this.props.name}_FILL`;
let fillIdRef = `#${fillId}`;
return React.createElement('g', null, <g id={iconId} transform="matrix( 1, 0, 0, 1, 0, 0)">
<defs>
<g id={fillId}>
<path fill={this.props.color} stroke="none" d="
M 11 14
L 11 15 12 15 12 14 11 14
M 13 14
L 13 13 12 13 12 14 13 14
M 3 14
L 5 14 5 13 3 13 3 14
M 10 15
L 10 16 11 16 11 15 10 15
M 7 16
L 9 16 9 15 7 15 7 16
M 10 16
L 9 16 9 17 10 17 10 16
M 7 15
L 7 14 5 14 5 15 7 15
M 9 14
L 9 15 10 15 10 14 9 14
M 9 14
L 9 13 7 13 7 14 9 14
M 10 13
L 10 14 11 14 11 13 10 13
M 7 12
L 5 12 5 13 7 13 7 12
M 3 12
L 1 12 1 13 3 13 3 12
M 5 12
L 5 11 3 11 3 12 5 12
M 1 12
L 1 11 0 11 0 12 1 12
M 1 10
L 1 11 3 11 3 10 1 10
M 1 9
L 0 9 0 10 1 10 1 9
M 17 9
L 16 9 16 10 17 10 17 9
M 16 7
L 16 8 17 8 17 7 16 7
M 14 12
L 13 12 13 13 14 13 14 12
M 15 10
L 15 11 16 11 16 10 15 10
M 13 11
L 14 11 14 10 13 10 13 11
M 14 11
L 14 12 15 12 15 11 14 11
M 12 11
L 12 12 13 12 13 11 12 11
M 12 12
L 11 12 11 13 12 13 12 12
M 15 8
L 15 9 16 9 16 8 15 8
M 15 9
L 14 9 14 10 15 10 15 9
M 16 5
L 16 4 14 4 14 3 12 3 12 2 10 2 10 1 8 1 8 0 7 0 7 1 6 1 6 2 5 2 5 3 4 3 4 4 3 4 3 5 2 5 2 6 1 6 1 7 0 7 0 8 1 8 1 9 3 9 3 10 5 10 5 11 7 11 7 12 9 12 9 13 10 13 10 12 11 12 11 11 12 11 12 10 13 10 13 9 14 9 14 8 15 8 15 7 16 7 16 6 17 6 17 5 16 5 Z"/>
</g>
</defs>
<g transform="matrix( 1, 0, 0, 1, 0,0) ">
<use xlinkHref={fillIdRef} />
</g>
</g>);
}
};
/**
*
* @type {React.Component}
*/
Icons[ActionTypes.SAVE] = class extends React.Component {
render() {
let iconId = `${this.props.name}_Icon`;
let fillId = `${this.props.name}_FILL`;
let fillIdRef = `#${fillId}`;
return React.createElement('g', null, <g id={iconId} transform="matrix( 1, 0, 0, 1, 0, 0)">
<defs>
<g id={fillId}>
<path fill={this.props.color}
stroke="none" d="
M 2 16
L 2 17 17 17 17 0 0 0 0 15 1 15 1 16 2 16
M 14 1
L 14 6 3 6 3 1 14 1
M 15 1
L 16 1 16 2 15 2 15 1
M 4 12
L 13 12 13 16 4 16 4 12
M 7 13
L 5 13 5 15 7 15 7 13 Z"/>
</g>
</defs>
<g transform="matrix( 1, 0, 0, 1, 0, 0)">
<use xlinkHref={fillIdRef} />
</g>
</g>);
}
};
/**
*
* @type {React.Component}
*/
Icons[ActionTypes.ERASE] = class extends React.Component {
render() {
let iconId = `${this.props.name}_Icon`;
let fillId = `${this.props.name}_FILL`;
let fillIdRef = `#${fillId}`;
return React.createElement('g', null, <g id={iconId} transform="matrix( 1, 0, 0, 1, 0, 0)">
<defs>
<g id={fillId}>
<path fill={this.props.color}
stroke="none" d="
M 6 6
L 5 6 5 7 6 7 6 6
M 10 12
L 9 12 9 13 10 13 10 12
M 1 12
L 0 12 0 14 9 14 9 13 8 13 8 12 7 12 7 13 1 13 1 12
M 2 12
L 2 10 1 10 1 12 2 12
M 4 8
L 3 8 3 9 2 9 2 10 8 10 8 12 9 12 9 10 10 10 10 9 4 9 4 8
M 5 8
L 5 7 4 7 4 8 5 8
M 7 4
L 7 5 8 5 8 4 7 4
M 7 6
L 7 5 6 5 6 6 7 6
M 9 3
L 8 3 8 4 9 4 9 3
M 16 5
L 15 5 15 7 16 7 16 5
M 12 10
L 13 10 13 9 12 9 12 10
M 12 10
L 11 10 11 11 12 11 12 10
M 11 12
L 11 11 10 11 10 12 11 12
M 12 7
L 11 7 11 8 12 8 12 7
M 11 9
L 11 8 10 8 10 9 11 9
M 14 8
L 13 8 13 9 14 9 14 8
M 14 7
L 14 8 15 8 15 7 14 7
M 13 6
L 12 6 12 7 13 7 13 6
M 15 5
L 15 4 14 4 14 5 15 5
M 13 6
L 14 6 14 5 13 5 13 6
M 17 5
L 17 2 9 2 9 3 15 3 15 4 16 4 16 5 17 5 Z"/>
</g>
</defs>
<g transform="matrix( 1, 0, 0, 1, 0, 0)">
<use xlinkHref={fillIdRef} />
</g>
</g>);
}
};
/**
*
* @type {React.Component}
*/
Icons[ActionTypes.UNDO] = class extends React.Component {
render() {
let iconId = `${this.props.name}_Icon`;
let fillId = `${this.props.name}_FILL`;
let fillIdRef = `#${fillId}`;
return React.createElement('g', null, <g id={iconId} transform="matrix( 1, 0, 0, 1, 0, 0)">
<defs>
<g id={fillId}>
<path fill={this.props.color}
stroke="none" d="
M 5.1 6.95
L 5.75 3 0 8.5 6.75 13 5.15 9.4
Q 11.7 7.9 17 11.4
L 17 10.25
Q 12.1 6.3 5.1 6.95 Z"/>
</g>
</defs>
<g transform="matrix( 1, 0, 0, 1, 0, 0)">
<use xlinkHref={fillIdRef} />
</g>
</g>);
}
};
/**
*
* @type {React.Component}
*/
Icons[ActionTypes.REDO] = class extends React.Component {
render() {
let iconId = `${this.props.name}_Icon`;
let fillId = `${this.props.name}_FILL`;
let fillIdRef = `#${fillId}`;
return React.createElement('g', null, <g id={iconId} transform="matrix( 1, 0, 0, 1, 0, 0)">
<defs>
<g id={fillId}>
<path fill={this.props.color}
stroke="none" d="
M 11.9 6.95
Q 4.9 6.3 0 10.25
L 0 11.4
Q 5.3 7.9 11.85 9.4
L 10.25 13 17 8.5 11.25 3 11.9 6.95 Z"/>
</g>
</defs>
<g transform="matrix( 1, 0, 0, 1, 0, 0)">
<use xlinkHref={fillIdRef} />
</g>
</g>);
}
};
/**
*
* @type {React.Component}
*/
Icons[ActionTypes.HELP] = class extends React.Component {
render() {
let iconId = `${this.props.name}_Icon`;
let fillId = `${this.props.name}_FILL`;
let fillIdRef = `#${fillId}`;
return React.createElement('g', null, <g id={iconId} transform="matrix( 1, 0, 0, 1, 0, 0)">
<defs>
<g id={fillId}>
<path fill={this.props.color}
stroke="none" d="
M 9.55 13.55
Q 9.55 12.9 9.15 12.5 8.7 12.05 8.1 12.05 7.55 12.05 7.1 12.5 6.65 12.9 6.65 13.55 6.65 14.2 7.1 14.65 7.55 15 8.1 15 8.7 15 9.15 14.65 9.55 14.2 9.55 13.55
M 11.5 6.5
Q 12 5.8 12 4.9 12 3.7 11.1 2.85 10.15 2 8.45 2 6.8 2 5.95 2.85 5 3.65 5 4.75 5 5.35 5.3 5.7 5.65 6.05 6.15 6.05 6.6 6.05 6.95 5.75 7.2 5.45 7.2 5 7.2 4.5 6.8 3.8 6.65 3.45 6.65 3.35 6.65 3.15 6.9 2.9 7.25 2.65 7.75 2.65 8.3 2.65 8.8 3.25 9.3 3.8 9.3 5 9.3 5.8 9.15 6.35 9 6.9 8.5 7.8 8.05 8.7 7.95 9.2 7.8 9.7 7.8 10.75
L 8.2 10.75
Q 8.25 9.75 8.55 9.3 8.8 8.8 9.7 8.2 11.1 7.3 11.5 6.5 Z"/>
</g>
</defs>
<g transform="matrix( 1, 0, 0, 1, 0, 0)">
<use xlinkHref={fillIdRef} />
</g>
</g>);
}
};
/**
*
* @type {React.Component}
*/
Icons[ActionTypes.RECT] = class extends React.Component {
render() {
let iconId = `${this.props.name}_Icon`;
let fillId = `${this.props.name}_FILL`;
let fillIdRef = `#${fillId}`;
return React.createElement('g', null, <g id={iconId} transform="matrix( 1, 0, 0, 1, 0, 0)">
<defs>
<g id={fillId}>
<path fill={this.props.color}
stroke="none" d="
M 17 2
L 0 2 0 15 17 15 17 2 Z"/>
</g>
</defs>
<g transform="matrix( 1, 0, 0, 1, 0, 0)">
<use xlinkHref={fillIdRef} />
</g>
</g>);
}
};
/**
*
* @type {React.Component}
*/
Icons[ActionTypes.WHITE_RECT] = class extends React.Component {
render() {
let iconId = `${this.props.name}_Icon`;
let fillId = `${this.props.name}_FILL`;
let fillIdRef = `#${fillId}`;
return React.createElement('g', null, <g id={iconId} transform="matrix( 1, 0, 0, 1, 0, 0)">
<defs>
<g id={fillId}>
<path stroke={this.props.color}
strokeWidth="1"
strokeLinejoin="miter"
strokeLinecap="square"
fill="none" d="
M 17.5 2.5
L 17.5 14.5 0.5 14.5 0.5 2.5 17.5 2.5"/>
</g>
</defs>
<g transform="matrix( 1, 0, 0, 1, 0, 0)">
<use xlinkHref={fillIdRef} />
</g>
</g>);
}
};
/**
*
* @type {React.Component}
*/
Icons[ActionTypes.CIRCLE] = class extends React.Component {
render() {
let iconId = `${this.props.name}_Icon`;
let fillId = `${this.props.name}_FILL`;
let fillIdRef = `#${fillId}`;
return React.createElement('g', null, <g id={iconId} transform="matrix( 1, 0, 0, 1, 0, 0)">
<defs>
<g id={fillId}>
<path fill={this.props.color}
stroke="none" d="
M 16 8.5
Q 16 5.35 13.8 3.15 12.15 1.55 9.95 1.15 9.25 1 8.5 1
8.45 1 8.4 1 5.3 1 3.15 3.15 1 5.3 1 8.4 1 8.45 1 8.5
1 9.25 1.15 9.95 1.55 12.15 3.15 13.8 5.35 16 8.5 16
11.65 16 13.8 13.8 16 11.65 16 8.5 Z"/>
</g>
</defs>
<g transform="matrix( 1, 0, 0, 1, 0, 0)">
<use xlinkHref={fillIdRef} />
</g>
</g>);
}
};
/**
*
* @type {React.Component}
*/
Icons[ActionTypes.WHITE_CIRCLE] = class extends React.Component {
render() {
let iconId = `${this.props.name}_Icon`;
let fillId = `${this.props.name}_FILL`;
let fillIdRef = `#${fillId}`;
return React.createElement('g', null, <g id={iconId} transform="matrix( 1, 0, 0, 1, 0, 0)">
<defs>
<g id={fillId}>
<path stroke={this.props.color}
strokeWidth="1"
strokeLinejoin="round"
strokeLinecap="round"
fill="none" d="
M 15.5 8.5
Q 15.5 11.45 13.45 13.45 11.45 15.5 8.5 15.5 5.55 15.5 3.5
13.45 2 11.9 1.65 9.85 1.5 9.2 1.5 8.5 1.5 8.45 1.5 8.4 1.5
5.5 3.5 3.5 5.5 1.5 8.4 1.5 8.45 1.5 8.5 1.5 9.2 1.5 9.85 1.65
11.9 2 13.45 3.5 15.5 5.55 15.5 8.5 Z"/>
</g>
</defs>
<g transform="matrix( 1, 0, 0, 1, 0, 0)">
<use xlinkHref={fillIdRef} />
</g>
</g>);
}
};
/**
*
* @type {React.Component}
*/
Icons[ActionTypes.ARC] = class extends React.Component {
render() {
let iconId = `${this.props.name}_Icon`;
let fillId = `${this.props.name}_FILL`;
let fillIdRef = `#${fillId}`;
return React.createElement('g', null, <g id={iconId} transform="matrix( 1, 0, 0, 1, 0, 0)">
<defs>
<g id={fillId}>
<path fill={this.props.color}
stroke="none" d="
M 3 3
L 3 0 0 0 0 3 1 3
Q 1.1 5.5 2.15 7.9 3.2 10.35 4.95 12.05 6.65 13.8 9.1 14.85 11.5 15.85 14 15.95
L 14 16.95 17 16.95 17 13.95 14 13.95 14 14.95
Q 11.75 14.85 9.5 13.9 7.2 12.95 5.65 11.35 4.05 9.8 3.1 7.5 2.1 5.25 2 3
L 3 3
M 1 1
L 2 1 2 2 1 2 1 1
M 16 14.95
L 16 15.95 15 15.95 15 14.95 16 14.95 Z"/>
</g>
</defs>
<g transform="matrix( 1, 0, 0, 1, 0, 0)">
<use xlinkHref={fillIdRef} />
</g>
</g>);
}
};
/**
*
* @type {React.Component}
*/
Icons[ActionTypes.PLAIN_STROKE] = class extends React.Component {
render() {
let iconId = `${this.props.name}_Icon`;
let fillId = `${this.props.name}_FILL`;
let fillIdRef = `#${fillId}`;
return React.createElement('g', null, <g id={iconId} transform="matrix( 1, 0, 0, 1, 0, 0)">
<defs>
<g id={fillId}>
<path fill={this.props.color}
stroke="none" d="
M 14 14
L 14 15 15 15 15 14 14 14
M 13 14
L 14 14 14 13 13 13 13 14
M 16 16
L 16 15 15 15 15 16 16 16
M 16 16
L 16 17 17 17 17 16 16 16
M 10 9
L 9 9 9 10 10 10 10 9
M 8 9
L 9 9 9 8 8 8 8 9
M 8 8
L 8 7 7 7 7 8 8 8
M 4 4
L 4 5 5 5 5 4 4 4
M 1 2
L 2 2 2 1 1 1 1 2
M 0 1
L 1 1 1 0 0 0 0 1
M 3 3
L 3 2 2 2 2 3 3 3
M 4 3
L 3 3 3 4 4 4 4 3
M 6 6
L 6 5 5 5 5 6 6 6
M 7 6
L 6 6 6 7 7 7 7 6
M 11 11
L 11 10 10 10 10 11 11 11
M 13 12
L 12 12 12 13 13 13 13 12
M 11 11
L 11 12 12 12 12 11 11 11 Z"/>
</g>
</defs>
<g transform="matrix( 1, 0, 0, 1, 0, 0)">
<use xlinkHref={fillIdRef} />
</g>
</g>);
}
};
/**
*
* @type {React.Component}
*/
Icons[ActionTypes.DOTTED_STROKE] = class extends React.Component {
render() {
let iconId = `${this.props.name}_Icon`;
let fillId = `${this.props.name}_FILL`;
let fillIdRef = `#${fillId}`;
return React.createElement('g', null, <g id={iconId} transform="matrix( 1, 0, 0, 1, 0, 0)">
<defs>
<g id={fillId}>
<path fill={this.props.color}
stroke="none" d="
M 14 15
L 15 15 15 14 14 14 14 15
M 16 16
L 16 17 17 17 17 16 16 16
M 8 9
L 9 9 9 8 8 8 8 9
M 4 4
L 4 5 5 5 5 4 4 4
M 0 0
L 0 1 1 1 1 0 0 0
M 3 3
L 3 2 2 2 2 3 3 3
M 7 6
L 6 6 6 7 7 7 7 6
M 11 11
L 11 10 10 10 10 11 11 11
M 13 12
L 12 12 12 13 13 13 13 12 Z"/>
</g>
</defs>
<g transform="matrix( 1, 0, 0, 1, 0, 0)">
<use xlinkHref={fillIdRef} />
</g>
</g>);
}
};
/**
*
* @type {React.Component}
*/
Icons[ActionTypes.DASHED_STROKE] = class extends React.Component {
render() {
let iconId = `${this.props.name}_Icon`;
let fillId = `${this.props.name}_FILL`;
let fillIdRef = `#${fillId}`;
return React.createElement('g', null, <g id={iconId} transform="matrix( 1, 0, 0, 1, 0, 0)">
<defs>
<g id={fillId}>
<path fill={this.props.color}
stroke="none" d="
M 16 16
L 16 15 15 15 15 16 16 16
M 16 16
L 16 17 17 17 17 16 16 16
M 0 1
L 1 1 1 0 0 0 0 1
M 1 2
L 2 2 2 1 1 1 1 2
M 4 4
L 4 5 5 5 5 4 4 4
M 4 3
L 3 3 3 4 4 4 4 3
M 8 8
L 8 7 7 7 7 8 8 8
M 7 6
L 6 6 6 7 7 7 7 6
M 10 9
L 9 9 9 10 10 10 10 9
M 11 11
L 11 10 10 10 10 11 11 11
M 14 13
L 13 13 13 14 14 14 14 13
M 13 12
L 12 12 12 13 13 13 13 12 Z"/>
</g>
</defs>
<g transform="matrix( 1, 0, 0, 1, 0, 0)">
<use xlinkHref={fillIdRef} />
</g>
</g>);
}
};
/**
*
* @type {React.Component}
*/
Icons[ActionTypes.PEN] = class extends React.Component {
render() {
let iconId = `${this.props.name}_Icon`;
let fillId = `${this.props.name}_FILL`;
let fillIdRef = `#${fillId}`;
return React.createElement('g', null, <g id={iconId} transform="matrix( 1, 0, 0, 1, 0, 0)">
<defs>
<g id={fillId}>
<path fill={this.props.color}
stroke="none" d="
M 1 15
L 1 13 0 13 0 17 4 17 4 16 2 16 2 15 1 15
M 4 14
L 3 14 3 15 4 15 4 14
M 3 14
L 3 13 2 13 2 14 3 14
M 5 15
L 4 15 4 16 5 16 5 15
M 7 14
L 7 13 6 13 6 14 7 14
M 6 15
L 6 14 5 14 5 15 6 15
M 8 12
L 7 12 7 13 8 13 8 12
M 10 10
L 9 10 9 11 10 11 10 10
M 9 11
L 8 11 8 12 9 12 9 11
M 6 7
L 6 8 7 8 7 7 6 7
M 3 11
L 4 11 4 10 3 10 3 11
M 2 11
L 2 12 3 12 3 11 2 11
M 2 12
L 1 12 1 13 2 13 2 12
M 5 8
L 5 9 6 9 6 8 5 8
M 5 9
L 4 9 4 10 5 10 5 9
M 8 6
L 7 6 7 7 8 7 8 6
M 9 6
L 9 5 8 5 8 6 9 6
M 10 5
L 10 4 9 4 9 5 10 5
M 11 10
L 11 9 10 9 10 10 11 10
M 11 8
L 11 9 12 9 12 8 11 8
M 13 8
L 13 7 12 7 12 8 13 8
M 12 3
L 12 2 11 2 11 3 10 3 10 4 11 4 11 5 12 5 12 6 13 6 13 7 14 7 14 6 15 6 15 5 14 5 14 4 13 4 13 3 12 3
M 13 2
L 13 1 12 1 12 2 13 2
M 15 1
L 14 1 14 2 15 2 15 1
M 14 1
L 14 0 13 0 13 1 14 1
M 16 3
L 16 2 15 2 15 3 16 3
M 17 3
L 16 3 16 4 17 4 17 3
M 16 5
L 16 4 15 4 15 5 16 5 Z"/>
</g>
</defs>
<g transform="matrix( 1, 0, 0, 1, 0, 0)">
<use xlinkHref={fillIdRef} />
</g>
</g>);
}
};
/**
*
* @type {React.Component}
*/
Icons[ActionTypes.TEXTFIELD] = class extends React.Component {
render() {
let iconId = `${this.props.name}_Icon`;
let fillId = `${this.props.name}_FILL`;
let fillIdRef = `#${fillId}`;
return React.createElement('g', null, <g id={iconId} transform="matrix( 1, 0, 0, 1, 0, 0)">
<defs>
<g id={fillId}>
<path fill={this.props.color}
stroke="none" d="
M 13 17
L 14 17 14 16 13 16 13 17
M 11 17
L 12 17 12 16 11 16 11 17
M 16 17
L 16 16 15 16 15 17 16 17
M 16 15
L 16 14 15 14 15 15 16 15
M 4 16
L 3 16 3 17 4 17 4 16
M 1 16
L 1 17 2 17 2 16 1 16
M 2 15
L 2 14 1 14 1 15 2 15
M 10 16
L 9 16 9 17 10 17 10 16
M 6 17
L 6 16 5 16 5 17 6 17
M 7 16
L 7 17 8 17 8 16 7 16
M 1 10
L 1 11 2 11 2 10 1 10
M 2 12
L 1 12 1 13 2 13 2 12
M 2 9
L 2 8 1 8 1 9 2 9
M 1 5
L 2 5 2 4 1 4 1 5
M 2 6
L 1 6 1 7 2 7 2 6
M 2 0
L 1 0 1 1 2 1 2 0
M 1 3
L 2 3 2 2 1 2 1 3
M 4 1
L 4 0 3 0 3 1 4 1
M 6 1
L 6 0 5 0 5 1 6 1
M 10 1
L 10 0 9 0 9 1 10 1
M 8 1
L 8 0 7 0 7 1 8 1
M 16 7
L 16 6 15 6 15 7 16 7
M 16 12
L 15 12 15 13 16 13 16 12
M 15 10
L 15 11 16 11 16 10 15 10
M 15 8
L 15 9 16 9 16 8 15 8
M 12 4
L 12 5 13 5 13 3 4 3 4 5 5 5 5 4 8 4 8 13 7 13 7 14 10 14 10 13 9 13 9 4 12 4
M 12 0
L 11 0 11 1 12 1 12 0
M 14 0
L 13 0 13 1 14 1 14 0
M 16 5
L 16 4 15 4 15 5 16 5
M 16 3
L 16 2 15 2 15 3 16 3
M 16 1
L 16 0 15 0 15 1 16 1 Z"/>
</g>
</defs>
<g transform="matrix( 1, 0, 0, 1, 0, 0)">
<use xlinkHref={fillIdRef} />
</g>
</g>);
}
};
/**
*
* @type {React.Component}
*/
Icons[ActionTypes.DIMENSION] = class extends React.Component {
render() {
let iconId = `${this.props.name}_Icon`;
let fillId = `${this.props.name}_FILL`;
let fillIdRef = `#${fillId}`;
return React.createElement('g', null, <g id={iconId} transform="matrix( 1, 0, 0, 1, 0, 0)">
<defs>
<g id={fillId}>
<path fill={this.props.color}
stroke="none" d="
M 6 4
L 6 5 7.95 5 7.95 3 6.95 3 6.95 4 6 4
M 6.95 3
L 6.95 2 5 2 5 3 6.95 3
M 10 3
L 9 3 9 4 10 4 10 3
M 11 5
L 11 4 10 4 10 5 11 5
M 11 3
L 11 2 10 2 10 3 11 3
M 12 3
L 11 3 11 4 12 4 12 3
M 3 8
L 3 9 4 9 4 8 3 8
M 4 5
L 4 4 3 4 3 5 4 5
M 13 9
L 14 9 14 8 13 8 13 9
M 13 4
L 13 5 14 5 14 4 13 4
M 17 3
L 16 3 16 6 15 6 15 5 14 5 14 6 3 6 3 5 2 5 2 6 1 6 1 3 0 3 0 15 1 15 1 7 2 7 2 8 3 8 3 7 14 7 14 8 15 8 15 7 16 7 16 15 17 15 17 3 Z"/>
</g>
</defs>
<g transform="matrix( 1, 0, 0, 1, 0, 0)">
<use xlinkHref={fillIdRef} />
</g>
</g>);
}
};
/**
*
* @type {React.Component}
*/
Icons[ActionTypes.WINDOW] = class extends React.Component {
render() {
let iconId = `${this.props.name}_Icon`;
let fillId = `${this.props.name}_FILL`;
let fillIdRef = `#${fillId}`;
return React.createElement('g', null, <g id={iconId} transform="matrix( 1, 0, 0, 1, 0, 0)">
<defs>
<g id={fillId}>
<path fill={this.props.color}
stroke="none" d="
M 16 11
L 17 11 17 6 16 6 16 7 1 7 1 6 0 6 0 11 1 11 1 10 16 10 16 11
M 16 8
L 16 9 1 9 1 8 16 8 Z"/>
</g>
</defs>
<g transform="matrix( 1, 0, 0, 1, 0, 0)">
<use xlinkHref={fillIdRef} />
</g>
</g>);
}
};
/**
*
* @type {React.Component}
*/
Icons[ActionTypes.DOOR] = class extends React.Component {
render() {
let iconId = `${this.props.name}_Icon`;
let fillId = `${this.props.name}_FILL`;
let fillIdRef = `#${fillId}`;
return React.createElement('g', null, <g id={iconId} transform="matrix( 1, 0, 0, 1, 0, 0)">
<defs>
<g id={fillId}>
<path fill={this.props.color}
stroke="none" d="
M 1 4
L 1 3 0 3 0 14 1 14 1 4
M 17 3
L 16 3 16 4 16 14 17 14 17 3 Z"/>
<path fill={this.props.color}
fillOpacity={0.5}
stroke="none" d="
M 16 3
Q 12.8 3.2 10.5 5.75 9.1 7.25 8.5 9.1 7.9 7.25 6.55 5.75
L 6.55 5.8
Q 4.3 3.2 1.1 3
L 1 3 1 4 1.05 4
Q 3.85 4.2 5.8 6.45 7.95 8.8 8 12.2
L 8.05 13.7 8.95 13.7 9 12.2
Q 9.05 8.8 11.25 6.45 13.25 4.2 16 4
L 16 3 Z"/>
</g>
</defs>
<g transform="matrix( 1, 0, 0, 1, 0, 0)">
<use xlinkHref={fillIdRef} />
</g>
</g>);
}
};
/**
*
* @type {React.Component}
*/
Icons[ActionTypes.DOUBLE_DOOR] = class extends React.Component {
render() {
let iconId = `${this.props.name}_Icon`;
let fillId = `${this.props.name}_FILL`;
let fillIdRef = `#${fillId}`;
return React.createElement('g', null, <g id={iconId} transform="matrix( 1, 0, 0, 1, 0, 0)">
<defs>
<g id={fillId}>
<path fill={this.props.color}
stroke="none" d="
M 1 1.05
L 1 0.05
Q 0.75 0 0.5 0
L 0 0 0 17 1 17 1 1.05 Z"/>
<path fill={this.props.color}
fillOpacity={0.5}
stroke="none" d="
M 1 1.05
Q 1.15 1.05 1.35 1.05
L 1.4 1.05
Q 7.2 1.35 11.45 5.4 16 9.65 16 15.75
L 16 17 17 17 17 15.75
Q 17 9.25 12.15 4.65 7.6 0.35 1.45 0.05 1.2 0.05 1 0.05
L 1 1.05 Z"/>
</g>
</defs>
<g transform="matrix( 1, 0, 0, 1, 0, 0)">
<use xlinkHref={fillIdRef} />
</g>
</g>);
}
};
/**
*
* @type {React.Component}
*/
Icons[ActionTypes.BIDET] = class extends React.Component {
render() {
let iconId = `${this.props.name}_Icon`;
let fillId = `${this.props.name}_FILL`;
let fillIdRef = `#${fillId}`;
return React.createElement('g', null, <g id={iconId} transform="matrix( 1, 0, 0, 1, 0, 0)">
<defs>
<g id={fillId}>
<path fill={this.props.color}
stroke="none" d="
M 12 15
L 11 15 11 16 13 16 13 14 12 14 12 15
M 6 16
L 6 17 11 17 11 16 6 16
M 6 16
L 6 15 5 15 5 14 4 14 4 16 6 16
M 4 11
L 3 11 3 14 4 14 4 11
M 3 6
L 2 6 2 11 3 11 3 6
M 4 6
L 4 5 3 5 3 6 4 6
M 4 1
L 3 1 3 4 4 4 4 1
M 14 11
L 13 11 13 14 14 14 14 11
M 10 12
L 10 14 11 14 11 12 10 12
M 10 15
L 10 14 7 14 7 15 10 15
M 7 12
L 6 12 6 14 7 14 7 12
M 5 7
L 5 12 6 12 6 7 5 7
M 11 7
L 11 6 6 6 6 7 11 7
M 7 10
L 8 10 8 9 7 9 7 10
M 8 11
L 9 11 9 10 8 10 8 11
M 10 9
L 9 9 9 10 10 10 10 9
M 8 8
L 8 9 9 9 9 8 8 8
M 11 12
L 12 12 12 7 11 7 11 12
M 14 5
L 13 5 13 6 14 6 14 5
M 13 5
L 13 4 4 4 4 5 13 5
M 15 6
L 14 6 14 11 15 11 15 6
M 14 1
L 13 1 13 4 14 4 14 1
M 13 1
L 13 0 4 0 4 1 13 1 Z"/>
</g>
</defs>
<g transform="matrix( 1, 0, 0, 1, 0, 0)">
<use xlinkHref={fillIdRef} />
</g>
</g>);
}
};
/**
*
* @type {React.Component}
*/
Icons[ActionTypes.SHOWER] = class extends React.Component {
render() {
let iconId = `${this.props.name}_Icon`;
let fillId = `${this.props.name}_FILL`;
let fillIdRef = `#${fillId}`;
return React.createElement('g', null, <g id={iconId} transform="matrix( 1, 0, 0, 1, 0, 0)">
<defs>
<g id={fillId}>
<path fill={this.props.color}
stroke="none" d="
M 0 16.95
L 17 16.95 17 0 0 0 0 16.95
M 16 15.95
L 1 15.95 1 1 16 1 16 15.95
M 12 8.95
L 11 8.95 11 9.95 12 9.95 12 8.95
M 11 8.95
L 11 7.95 10 7.95 10 8.95 11 8.95
M 11 7.95
L 12 7.95 12 6.95 11 6.95 11 7.95
M 13 8.95
L 13 7.95 12 7.95 12 8.95 13 8.95
M 3 13.95
L 3 14.95 14 14.95 14 13.95 3 13.95
M 3 2.95
L 2 2.95 2 13.95 3 13.95 3 2.95
M 14 2.95
L 14 1.95 3 1.95 3 2.95 14 2.95
M 15 2.95
L 14 2.95 14 13.95 15 13.95 15 2.95 Z"/>
</g>
</defs>
<g transform="matrix( 1, 0, 0, 1, 0, 0)">
<use xlinkHref={fillIdRef} />
</g>
</g>);
}
};
/**
*
* @type {React.Component}
*/
Icons[ActionTypes.BATH] = class extends React.Component {
render() {
let iconId = `${this.props.name}_Icon`;
let fillId = `${this.props.name}_FILL`;
let fillIdRef = `#${fillId}`;
return React.createElement('g', null, <g id={iconId} transform="matrix( 1, 0, 0, 1, 0, 0)">
<defs>
<g id={fillId}>
<path fill={this.props.color}
stroke="none" d="
M 2 12
L 2 11 1 11 1 13 3 13 3 12 2 12
M 3 3
L 3 4 16 4 16 13 3 13 3 14 17 14 17 3 3 3
M 1 6
L 2 6 2 5 3 5 3 4 1 4 1 6
M 11 9
L 11 8 10 8 10 9 11 9
M 12 9
L 11 9 11 10 12 10 12 9
M 12 7
L 11 7 11 8 12 8 12 7
M 13 9
L 13 8 12 8 12 9 13 9
M 1 6
L 0 6 0 11 1 11 1 6 Z"/>
<path fill={this.props.color}
fillOpacity={0.5}
stroke="none" d="
M 3 10
L 3 7 2 7 2 10 3 10
M 4 11
L 4 10 3 10 3 11 4 11
M 4 6
L 3 6 3 7 4 7 4 6
M 15 12
L 15 5 4 5 4 6 14 6 14 11 4 11 4 12 15 12 Z"/>
</g>
</defs>
<g transform="matrix( 1, 0, 0, 1, 0, 0)">
<use xlinkHref={fillIdRef} />
</g>
</g>);
}
};
/**
*
* @type {React.Component}
*/
Icons[ActionTypes.WASHBASIN] = class extends React.Component {
render() {
let iconId = `${this.props.name}_Icon`;
let fillId = `${this.props.name}_FILL`;
let fillIdRef = `#${fillId}`;
return React.createElement('g', null, <g id={iconId} transform="matrix( 1, 0, 0, 1, 0, 0)">
<defs>
<g id={fillId}>
<path fill={this.props.color}
stroke="none" d="
M 11 15
L 13 15 13 14 11 14 11 15
M 6 15
L 6 16 11 16 11 15 6 15
M 4 14
L 4 15 6 15 6 14 4 14
M 3 12
L 2 12 2 14 4 14 4 13 3 13 3 12
M 2 9
L 1 9 1 12 2 12 2 9
M 1 4
L 0 4 0 9 1 9 1 4
M 2 3
L 1 3 1 4 2 4 2 3
M 15 9
L 15 12 16 12 16 9 15 9
M 15 12
L 14 12 14 13 13 13 13 14 15 14 15 12
M 15 3
L 15 2 2 2 2 3 15 3
M 11 12
L 6 12 6 13 11 13 11 12
M 5 11
L 5 10 4 10 4 12 6 12 6 11 5 11
M 4 7
L 3 7 3 10 4 10 4 7
M 13 7
L 13 6 4 6 4 7 13 7
M 11 11
L 11 12 13 12 13 10 12 10 12 11 11 11
M 8 9
L 9 9 9 8 8 8 8 9
M 14 7
L 13 7 13 10 14 10 14 7
M 17 4
L 16 4 16 9 17 9 17 4
M 16 4
L 16 3 15 3 15 4 16 4 Z"/>
</g>
</defs>
<g transform="matrix( 1, 0, 0, 1, 0, 0)">
<use xlinkHref={fillIdRef} />
</g>
</g>);
}
};
/**
*
* @type {React.Component}
*/
Icons[ActionTypes.COOKER] = class extends React.Component {
render() {
let iconId = `${this.props.name}_Icon`;
let fillId = `${this.props.name}_FILL`;
let fillIdRef = `#${fillId}`;
return React.createElement('g', null, <g id={iconId} transform="matrix( 1, 0, 0, 1, 0, 0)">
<defs>
<g id={fillId}>
<path fill={this.props.color}
stroke="none" d="
M 3.55 16
L 3.55 17 13.55 17 13.55 16 17 16 17 0 0 0 0 16 3.55 16
M 16 15
L 1 15 1 1 16 1 16 15
M 4 13
L 4 14 6 14 6 13 4 13
M 7 11
L 6 11 6 13 7 13 7 11
M 4 10
L 4 11 6 11 6 10 4 10
M 4 11
L 3 11 3 13 4 13 4 11
M 4 7
L 4 8 6 8 6 7 4 7
M 4 6
L 3 6 3 7 4 7 4 6
M 2 4
L 2 6 3 6 3 4 2 4
M 4 3
L 3 3 3 4 4 4 4 3
M 7 4
L 7 6 8 6 8 4 7 4
M 7 6
L 6 6 6 7 7 7 7 6
M 7 3
L 6 3 6 4 7 4 7 3
M 6 3
L 6 2 4 2 4 3 6 3
M 14 13
L 12 13 12 14 14 14 14 13
M 15 11
L 14 11 14 13 15 13 15 11
M 12 11
L 11 11 11 13 12 13 12 11
M 14 10
L 12 10 12 11 14 11 14 10
M 14 6
L 12 6 12 7 14 7 14 6
M 14 4
L 14 3 12 3 12 4 14 4
M 14 4
L 14 6 15 6 15 4 14 4
M 12 4
L 11 4 11 6 12 6 12 4 Z"/>
</g>
</defs>
<g transform="matrix( 1, 0, 0, 1, 0, 0)">
<use xlinkHref={fillIdRef} />
</g>
</g>);
}
};
/**
*
* @type {React.Component}
*/
Icons[ActionTypes.SINK] = class extends React.Component {
render() {
let iconId = `${this.props.name}_Icon`;
let fillId = `${this.props.name}_FILL`;
let fillIdRef = `#${fillId}`;
return React.createElement('g', null, <g id={iconId} transform="matrix( 1, 0, 0, 1, 0, 0)">
<defs>
<g id={fillId}>
<path fill={this.props.color}
stroke="none" d="
M 17 3
L 0 3 0 14 17 14 17 3
M 16 13
L 1 13 1 4 16 4 16 13
M 5 7
L 5 8 6 8 6 7 5 7
M 3 11
L 3 12 8 12 8 11 3 11
M 3 6
L 2 6 2 11 3 11 3 6
M 9 6
L 8 6 8 11 9 11 9 6
M 8 6
L 8 5 3 5 3 6 8 6
M 15 7
L 15 6 10 6 10 7 15 7
M 15 9
L 15 8 10 8 10 9 15 9
M 15 11
L 15 10 10 10 10 11 15 11 Z"/>
</g>
</defs>
<g transform="matrix( 1, 0, 0, 1, 0, 0)">
<use xlinkHref={fillIdRef} />
</g>
</g>);
}
};
export default Icons;
|
app/javascript/mastodon/features/ui/util/react_router_helpers.js
|
rainyday/mastodon
|
import React from 'react';
import PropTypes from 'prop-types';
import { Switch, Route } from 'react-router-dom';
import ColumnLoading from '../components/column_loading';
import BundleColumnError from '../components/bundle_column_error';
import BundleContainer from '../containers/bundle_container';
// Small wrapper to pass multiColumn to the route components
export class WrappedSwitch extends React.PureComponent {
render () {
const { multiColumn, children } = this.props;
return (
<Switch>
{React.Children.map(children, child => React.cloneElement(child, { multiColumn }))}
</Switch>
);
}
}
WrappedSwitch.propTypes = {
multiColumn: PropTypes.bool,
children: PropTypes.node,
};
// Small Wrapper to extract the params from the route and pass
// them to the rendered component, together with the content to
// be rendered inside (the children)
export class WrappedRoute extends React.Component {
static propTypes = {
component: PropTypes.func.isRequired,
content: PropTypes.node,
multiColumn: PropTypes.bool,
componentParams: PropTypes.object,
};
static defaultProps = {
componentParams: {},
};
renderComponent = ({ match }) => {
const { component, content, multiColumn, componentParams } = this.props;
return (
<BundleContainer fetchComponent={component} loading={this.renderLoading} error={this.renderError}>
{Component => <Component params={match.params} multiColumn={multiColumn} {...componentParams}>{content}</Component>}
</BundleContainer>
);
}
renderLoading = () => {
return <ColumnLoading />;
}
renderError = (props) => {
return <BundleColumnError {...props} />;
}
render () {
const { component: Component, content, ...rest } = this.props;
return <Route {...rest} render={this.renderComponent} />;
}
}
|
website/pages/404.js
|
rofrischmann/fela
|
import React from 'react'
import { Box } from 'kilvin'
import Head from 'next/head'
import { useFela } from 'react-fela'
import Layout from '../components/Layout'
import Button from '../components/Button'
export default function Page() {
const { theme } = useFela()
return (
<>
<Layout>
<Box space={4} paddingTop={10} paddingBottom={10}>
<h1>Not Found!</h1>
<Box as="p" extend={{ fontSize: 20 }}>
Sorry, the page your looking for could not be found.
</Box>
<br />
<Box as="p">
Are you searching for a specific documentation page?
<br />
We recently rewrote the whole website and sadly the links have
changed. <br />
But, the documentation structure mostly remained the same!
<br />
</Box>
<Box alignSelf="flex-start" paddingTop={2} space={2} direction="row">
<Button href="/docs">Documentation</Button>
<Button
href="https://github.com/robinweser/fela/discussions"
variant="secondary">
Ask For Help
</Button>
</Box>
</Box>
</Layout>
</>
)
}
|
examples/3-complex/src/index/home/App.js
|
chikara-chan/react-power
|
import React from 'react'
import styles from './App.scss'
function App() {
return (
<div>
<h1 className={styles.title}>Home</h1>
</div>
)
}
export default App
|
actor-apps/app-web/src/app/components/modals/CreateGroup.react.js
|
JeeLiu/actor-platform
|
import React from 'react';
import CreateGroupActionCreators from 'actions/CreateGroupActionCreators';
import CreateGroupStore from 'stores/CreateGroupStore';
import CreateGroupForm from './create-group/Form.react';
import Modal from 'react-modal';
import { KeyCodes } from 'constants/ActorAppConstants';
const appElement = document.getElementById('actor-web-app');
Modal.setAppElement(appElement);
const getStateFromStores = () => {
return {
isShown: CreateGroupStore.isModalOpen()
};
};
class CreateGroup extends React.Component {
constructor(props) {
super(props);
this.state = getStateFromStores();
CreateGroupStore.addChangeListener(this.onChange);
document.addEventListener('keydown', this.onKeyDown, false);
}
componentWillUnmount() {
CreateGroupStore.removeChangeListener(this.onChange);
document.removeEventListener('keydown', this.onKeyDown, false);
}
render() {
const isShown = this.state.isShown;
return (
<Modal className="modal-new modal-new--create-group" closeTimeoutMS={150} isOpen={isShown}>
<header className="modal-new__header">
<a className="modal-new__header__close material-icons" onClick={this.onClose}>clear</a>
<h3 className="modal-new__header__title">Create group</h3>
</header>
<CreateGroupForm/>
</Modal>
);
}
onChange = () => {
this.setState(getStateFromStores());
}
onClose = () => {
CreateGroupActionCreators.closeModal();
}
onKeyDown = (event) => {
if (event.keyCode === KeyCodes.ESC) {
event.preventDefault();
this.onClose();
}
}
}
CreateGroup.displayName = 'CreateGroup';
export default CreateGroup;
|
src/components/CountyMap/CountyMap.js
|
Swizec/h1b-software-salaries
|
import React, { Component } from 'react';
import * as d3 from 'd3';
import * as topojson from 'topojson';
import _ from 'lodash';
import County from './County';
class CountyMap extends Component {
// Setup default D3 objects
// projection - defines our geo projection, how the map looks
// geoPath - calculates d attribute of <path> so it looks like a map
// quantize - threshold scale with 9 buckets
constructor(props) {
super(props);
this.projection = d3.geoAlbersUsa()
.scale(1280);
this.geoPath = d3.geoPath()
.projection(this.projection);
this.quantize = d3.scaleQuantize()
.range(d3.range(9));
this.updateD3(props);
}
// update D3 objects when props update
componentWillReceiveProps(newProps) {
this.updateD3(newProps);
}
// Re-center the geo projection
// Update domain of quantize scale
updateD3(props) {
this.projection
.translate([props.width / 2, props.height / 2])
.scale(props.width*1.3);
if (props.zoom && props.usTopoJson) {
const us = props.usTopoJson,
statePaths = topojson.feature(us, us.objects.states).features,
id = _.find(props.USstateNames, {code: props.zoom}).id;
this.projection.scale(props.width*4.5);
const centroid = this.geoPath.centroid(_.find(statePaths, {id: id})),
translate = this.projection.translate();
this.projection.translate([
translate[0] - centroid[0] + props.width / 2,
translate[1] - centroid[1] + props.height / 2
]);
}
if (props.values) {
this.quantize.domain([d3.quantile(props.values, 0.15, d => d.value),
d3.quantile(props.values, 0.85, d => d.value)]);
}
}
// If no data, do nothing (we might mount before data loads into props)
render() {
if (!this.props.usTopoJson) {
return null;
}else{
// Translate topojson data into geojson data for drawing
// Prepare a mesh for states and a list of features for counties
const us = this.props.usTopoJson,
statesMesh = topojson.mesh(us, us.objects.states, (a, b) => a !== b),
counties = topojson.feature(us, us.objects.counties).features;
const countyValueMap = _.fromPairs(this.props.values
.map(d => [d.countyID, d.value]));
// Loop through counties and draw <County> components
// Add a single <path> for state borders
return (
<g>
{counties.map((feature) => (
<County geoPath={this.geoPath}
feature={feature}
zoom={this.props.zoom}
key={feature.id}
quantize={this.quantize}
value={countyValueMap[feature.id]} />
))}
<path d={this.geoPath(statesMesh)} style={{fill: 'none',
stroke: '#fff',
strokeLinejoin: 'round'}} />
</g>
);
}
}
}
export default CountyMap;
|
src/svg-icons/action/settings-applications.js
|
kasra-co/material-ui
|
import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let ActionSettingsApplications = (props) => (
<SvgIcon {...props}>
<path d="M12 10c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm7-7H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.11 0 2-.9 2-2V5c0-1.1-.89-2-2-2zm-1.75 9c0 .23-.02.46-.05.68l1.48 1.16c.13.11.17.3.08.45l-1.4 2.42c-.09.15-.27.21-.43.15l-1.74-.7c-.36.28-.76.51-1.18.69l-.26 1.85c-.03.17-.18.3-.35.3h-2.8c-.17 0-.32-.13-.35-.29l-.26-1.85c-.43-.18-.82-.41-1.18-.69l-1.74.7c-.16.06-.34 0-.43-.15l-1.4-2.42c-.09-.15-.05-.34.08-.45l1.48-1.16c-.03-.23-.05-.46-.05-.69 0-.23.02-.46.05-.68l-1.48-1.16c-.13-.11-.17-.3-.08-.45l1.4-2.42c.09-.15.27-.21.43-.15l1.74.7c.36-.28.76-.51 1.18-.69l.26-1.85c.03-.17.18-.3.35-.3h2.8c.17 0 .32.13.35.29l.26 1.85c.43.18.82.41 1.18.69l1.74-.7c.16-.06.34 0 .43.15l1.4 2.42c.09.15.05.34-.08.45l-1.48 1.16c.03.23.05.46.05.69z"/>
</SvgIcon>
);
ActionSettingsApplications = pure(ActionSettingsApplications);
ActionSettingsApplications.displayName = 'ActionSettingsApplications';
ActionSettingsApplications.muiName = 'SvgIcon';
export default ActionSettingsApplications;
|
examples/demos/dndOutsideSource.js
|
TeaBough/react-big-calendar
|
import React from 'react'
import events from '../events'
import { Calendar, Views } from 'react-big-calendar'
import withDragAndDrop from 'react-big-calendar/lib/addons/dragAndDrop'
import Layout from 'react-tackle-box/Layout'
import Card from '../Card'
import 'react-big-calendar/lib/addons/dragAndDrop/styles.scss'
const DragAndDropCalendar = withDragAndDrop(Calendar)
const formatName = (name, count) => `${name} ID ${count}`
class Dnd extends React.Component {
constructor(props) {
super(props)
this.state = {
events: events,
draggedEvent: null,
counters: {
item1: 0,
item2: 0,
},
displayDragItemInCell: true,
}
}
handleDragStart = event => {
this.setState({ draggedEvent: event })
}
handleDisplayDragItemInCell = () => {
this.setState({
displayDragItemInCell: !this.state.displayDragItemInCell,
})
}
dragFromOutsideItem = () => {
return this.state.draggedEvent
}
customOnDragOver = event => {
// check for undroppable is specific to this example
// and not part of API. This just demonstrates that
// onDragOver can optionally be passed to conditionally
// allow draggable items to be dropped on cal, based on
// whether event.preventDefault is called
if (this.state.draggedEvent !== 'undroppable') {
console.log('preventDefault')
event.preventDefault()
}
}
onDropFromOutside = ({ start, end, allDay }) => {
const { draggedEvent, counters } = this.state
const event = {
title: formatName(draggedEvent.name, counters[draggedEvent.name]),
start,
end,
isAllDay: allDay,
}
const updatedCounters = {
...counters,
[draggedEvent.name]: counters[draggedEvent.name] + 1,
}
this.setState({ draggedEvent: null, counters: updatedCounters })
this.newEvent(event)
}
moveEvent = ({ event, start, end, isAllDay: droppedOnAllDaySlot }) => {
const { events } = this.state
const idx = events.indexOf(event)
let allDay = event.allDay
if (!event.allDay && droppedOnAllDaySlot) {
allDay = true
} else if (event.allDay && !droppedOnAllDaySlot) {
allDay = false
}
const updatedEvent = { ...event, start, end, allDay }
const nextEvents = [...events]
nextEvents.splice(idx, 1, updatedEvent)
this.setState({
events: nextEvents,
})
// alert(`${event.title} was dropped onto ${updatedEvent.start}`)
}
resizeEvent = ({ event, start, end }) => {
const { events } = this.state
const nextEvents = events.map(existingEvent => {
return existingEvent.id == event.id
? { ...existingEvent, start, end }
: existingEvent
})
this.setState({
events: nextEvents,
})
//alert(`${event.title} was resized to ${start}-${end}`)
}
newEvent = event => {
let idList = this.state.events.map(a => a.id)
let newId = Math.max(...idList) + 1
let hour = {
id: newId,
title: event.title,
allDay: event.isAllDay,
start: event.start,
end: event.end,
}
this.setState({
events: this.state.events.concat([hour]),
})
}
render() {
return (
<div>
<Card className="examples--header" style={{ display: 'flex' }}>
<div
style={{
display: 'flex',
flex: 1,
justifyContent: 'center',
flexWrap: 'wrap',
}}
>
<h4 style={{ color: 'gray', width: '100%' }}>
Outside Drag Sources
</h4>
{Object.entries(this.state.counters).map(([name, count]) => (
<div
style={{
border: '2px solid gray',
borderRadius: '4px',
width: '100px',
margin: '10px',
}}
draggable="true"
key={name}
onDragStart={() =>
this.handleDragStart({ title: formatName(name, count), name })
}
>
{formatName(name, count)}
</div>
))}
<div
style={{
border: '2px solid gray',
borderRadius: '4px',
width: '100px',
margin: '10px',
}}
draggable="true"
key={name}
onDragStart={() => this.handleDragStart('undroppable')}
>
Draggable but not for calendar.
</div>
</div>
<div>
<label>
<input
style={{ marginRight: 5 }}
type="checkbox"
checked={this.state.displayDragItemInCell}
onChange={this.handleDisplayDragItemInCell}
/>
Display dragged item in cell while dragging over
</label>
</div>
</Card>
<DragAndDropCalendar
selectable
localizer={this.props.localizer}
events={this.state.events}
onEventDrop={this.moveEvent}
dragFromOutsideItem={
this.state.displayDragItemInCell ? this.dragFromOutsideItem : null
}
onDropFromOutside={this.onDropFromOutside}
onDragOver={this.customOnDragOver}
resizable
onEventResize={this.resizeEvent}
onSelectSlot={this.newEvent}
onD
defaultView={Views.MONTH}
defaultDate={new Date(2015, 3, 12)}
/>
</div>
)
}
}
export default Dnd
|
client/extensions/woocommerce/app/dashboard/setup/notices.js
|
Automattic/woocommerce-connect-client
|
/** @format */
/**
* External dependencies
*/
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { get } from 'lodash';
import { localize } from 'i18n-calypso';
/**
* Internal dependencies
*/
import { getCurrentUser, isCurrentUserEmailVerified } from 'state/current-user/selectors';
import Notice from 'components/notice';
class SetupNotices extends Component {
static propTypes = {
currentUserEmail: PropTypes.string,
currentUserEmailVerified: PropTypes.bool,
translate: PropTypes.func,
};
possiblyRenderEmailWarning = () => {
const { currentUserEmail, currentUserEmailVerified, translate } = this.props;
if ( ! currentUserEmail || currentUserEmailVerified ) {
return null;
}
return (
<Notice
status="is-warning"
showDismiss={ false }
text={ translate(
"You need to confirm your email address to activate your account. We've sent " +
'an email to {{strong}}%(email)s{{/strong}} with instructions for you to follow.',
{
components: {
strong: <strong />,
},
args: {
email: currentUserEmail,
},
}
) }
/>
);
};
render = () => {
return <div>{ this.possiblyRenderEmailWarning() }</div>;
};
}
function mapStateToProps( state ) {
const currentUser = getCurrentUser( state );
const currentUserEmail = get( currentUser, 'email', '' );
const currentUserEmailVerified = isCurrentUserEmailVerified( state );
return {
currentUserEmail,
currentUserEmailVerified,
};
}
export default connect( mapStateToProps )( localize( SetupNotices ) );
|
submissions/pasieronen/client.js
|
gterzian/flux-challenge
|
import React from 'react';
import Dispatcher from './Dispatcher';
import * as JediConstants from './JediConstants';
import JediApp from './JediApp';
import * as JediStore from './JediStore';
window.onload = () =>
Dispatcher.dispatch(JediConstants.START, {
firstJediId: 3616,
firstJediUrl: "http://localhost:3000/dark-jedis/3616",
websocketUrl: "ws://localhost:4000"
});
React.render(
<JediApp stateObservable={JediStore.state} />,
document.getElementById("content")
);
|
src/client/time.js
|
dvorakjan/noderunner-gui
|
import React from 'react';
export default class Time extends React.Component {
constructor(props) {
super(props);
this.state = this.update();
setInterval(() => self.update(), 1000);
}
update() {
var state = {delta: this.props.started > 0 ? Math.round((Date.now()/1000 - this.props.started)) : 0};
this.setState(state);
return state;
}
render() {
return (
<div>{this.state.delta}</div>
);
}
}
|
app/javascript/mastodon/features/notifications/components/clear_column_button.js
|
MitarashiDango/mastodon
|
import React from 'react';
import PropTypes from 'prop-types';
import { FormattedMessage } from 'react-intl';
import Icon from 'mastodon/components/icon';
export default class ClearColumnButton extends React.PureComponent {
static propTypes = {
onClick: PropTypes.func.isRequired,
};
render () {
return (
<button className='text-btn column-header__setting-btn' tabIndex='0' onClick={this.props.onClick}><Icon id='eraser' /> <FormattedMessage id='notifications.clear' defaultMessage='Clear notifications' /></button>
);
}
}
|
src/routes/blog/BlogContent.js
|
yvanwangl/UniversalBlog
|
import React from 'react';
import PropTypes from 'prop-types';
import ReadEditor from '../../components/ReadEditor/ReadEditor';
import withStyles from 'isomorphic-style-loader/lib/withStyles';
import s from './index.css';
class BlogContent extends React.Component {
constructor(props) {
super(props);
}
render() {
let {content, title} = this.props.blog;
return (
<div className={s.container}>
<h1>{title}</h1>
<ReadEditor id={'blogContent'} content={content}/>
</div>
);
}
}
export default withStyles(s)(BlogContent);
|
local-cli/templates/HelloNavigation/views/welcome/WelcomeScreen.js
|
disparu86/react-native
|
'use strict';
import React, { Component } from 'react';
import {
Image,
Platform,
StyleSheet,
} from 'react-native';
import ListItem from '../../components/ListItem';
import WelcomeText from './WelcomeText';
export default class WelcomeScreen extends Component {
static navigationOptions = {
title: 'Welcome',
header: {
visible: Platform.OS === 'ios',
},
tabBar: {
icon: ({ tintColor }) => (
<Image
// Using react-native-vector-icons works here too
source={require('./welcome-icon.png')}
style={[styles.icon, {tintColor: tintColor}]}
/>
),
},
}
render() {
return (
<WelcomeText />
);
}
}
const styles = StyleSheet.create({
icon: {
width: 30,
height: 26,
},
});
|
src/components/Tabs/Tabs-story.js
|
jzhang300/carbon-components-react
|
import React from 'react';
import { storiesOf } from '@storybook/react';
import { action } from '@storybook/addon-actions';
import Tabs from '../Tabs';
import Tab from '../Tab';
const props = {
tabs: {
className: 'some-class',
triggerHref: '#anotherAnchor',
},
tab: {
className: 'another-class',
onClick: action('onClick'),
onKeyDown: action('onKeyDown'),
},
};
storiesOf('Tabs', module)
.addWithInfo(
'Default',
`
Tabs are used to quickly navigate between views within the same context. Create individual
Tab components for each item in the Tabs list.
`,
() => (
<Tabs {...props.tabs}>
<Tab {...props.tab} label="Tab label 1">
<div className="some-content">Content for first tab goes here.</div>
</Tab>
<Tab {...props.tab} label="Tab label 2">
<div className="some-content">Content for second tab goes here.</div>
</Tab>
<Tab {...props.tab} label="Tab label 3">
<div className="some-content">Content for third tab goes here.</div>
</Tab>
<Tab {...props.tab} label="Tab label 4">
<div className="some-content">Content for fourth tab goes here.</div>
</Tab>
</Tabs>
)
)
.addWithInfo(
'Selected Example',
`
By using the selected prop on the Tabs component, you can switch which Tab gets
rendered by default
`,
() => (
<Tabs {...props.tabs} selected={3}>
<Tab {...props.tab} label="Tab label 1">
<div className="some-content">Content for first tab goes here.</div>
</Tab>
<Tab {...props.tab} label="Tab label 2">
<div className="some-content">Content for second tab goes here.</div>
</Tab>
<Tab {...props.tab} label="Tab label 3">
<div className="some-content">Content for third tab goes here.</div>
</Tab>
<Tab {...props.tab} label="Tab label 4">
<div className="some-content">ontent for fourth tab goes here.</div>
</Tab>
</Tabs>
)
);
|
test/JumbotronSpec.js
|
zanjs/react-bootstrap
|
import React from 'react';
import ReactTestUtils from 'react/lib/ReactTestUtils';
import Jumbotron from '../src/Jumbotron';
describe('Jumbotron', function () {
it('Should output a div with content', function () {
let instance = ReactTestUtils.renderIntoDocument(
<Jumbotron>
<strong>Content</strong>
</Jumbotron>
);
assert.equal(React.findDOMNode(instance).nodeName, 'DIV');
assert.ok(ReactTestUtils.findRenderedDOMComponentWithTag(instance, 'strong'));
});
it('Should have a jumbotron class', function () {
let instance = ReactTestUtils.renderIntoDocument(
<Jumbotron>
Content
</Jumbotron>
);
assert.ok(React.findDOMNode(instance).className.match(/\bjumbotron\b/));
});
it('Should override node class', function () {
let instance = ReactTestUtils.renderIntoDocument(
<Jumbotron componentClass='section'>
<strong>Content</strong>
</Jumbotron>
);
assert.equal(React.findDOMNode(instance).nodeName, 'SECTION');
});
});
|
actor-apps/app-web/src/app/components/modals/CreateGroup.react.js
|
darioajr/actor-platform
|
import React from 'react';
import CreateGroupActionCreators from 'actions/CreateGroupActionCreators';
import CreateGroupStore from 'stores/CreateGroupStore';
import CreateGroupForm from './create-group/Form.react';
import Modal from 'react-modal';
import { KeyCodes } from 'constants/ActorAppConstants';
const appElement = document.getElementById('actor-web-app');
Modal.setAppElement(appElement);
const getStateFromStores = () => {
return {
isShown: CreateGroupStore.isModalOpen()
};
};
class CreateGroup extends React.Component {
constructor(props) {
super(props);
this.state = getStateFromStores();
CreateGroupStore.addChangeListener(this.onChange);
document.addEventListener('keydown', this.onKeyDown, false);
}
componentWillUnmount() {
CreateGroupStore.removeChangeListener(this.onChange);
document.removeEventListener('keydown', this.onKeyDown, false);
}
render() {
const isShown = this.state.isShown;
return (
<Modal className="modal-new modal-new--create-group" closeTimeoutMS={150} isOpen={isShown}>
<header className="modal-new__header">
<a className="modal-new__header__close modal-new__header__icon material-icons" onClick={this.onClose}>clear</a>
<h3 className="modal-new__header__title">Create group</h3>
</header>
<CreateGroupForm/>
</Modal>
);
}
onChange = () => {
this.setState(getStateFromStores());
}
onClose = () => {
CreateGroupActionCreators.closeModal();
}
onKeyDown = (event) => {
if (event.keyCode === KeyCodes.ESC) {
event.preventDefault();
this.onClose();
}
}
}
CreateGroup.displayName = 'CreateGroup';
export default CreateGroup;
|
client/src/components/employer/whyHireGrads.js
|
Siyanda-Mzam/hire-grad
|
import React from 'react';
const WhyHireGrads = () => {
return (
<div className="section">
<div className="container">
<div className="columns">
<div className="column is-7 is-half content">
<h1>Access a curated list of graduates</h1>
<br />
<h4><strong>Only the best</strong></h4>
<p>Our team curates the graduates who apply to GenZ
and youโll only see top candidates.</p>
<br/>
<h4><strong>Ready to move</strong></h4>
<p>Discover talented graduates ready to grow their careers</p>
</div>
<div className="section column is-5 is-half content">
<div className="card">
<div className="card-content">
<div className="media">
<div className="media-left">
<figure id="sample-image" className="image is-100x100">
<img src="https://placehold.it/280"
alt="Placeholder image" />
</figure>
</div>
<div className="media-content">
<p className="title is-4">Brand New</p>
<p className="subtitle is-6">M.A. Political Studies</p>
<span className="media-details">
<table className="table is-narrow">
<tbody>
<tr>
<td>
<i className="fa fa-map-marker" aria-hidden="true">
</i>
</td>
<td>
<span className=" subtitle is-6 card-text-pull">
Johannesburg
</span>
</td>
</tr>
<tr>
<td>
<i className="fa fa-money" aria-hidden="true"></i>
</td>
<td>
<span className=" subtitle is-6 card-text-pull">
R55 000/month
</span>
</td>
</tr>
<tr>
<td>
<i className="fa fa-graduation-cap"
aria-hidden="true"></i>
</td>
<td>
<span className=" subtitle is-6 card-text-pull">
Rhodes University
</span>
</td>
</tr>
</tbody>
</table>
</span>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
);
}
export default WhyHireGrads;
|
src/pages/chocris.js
|
vitorbarbosa19/ziro-online
|
import React from 'react'
import BrandGallery from '../components/BrandGallery'
export default () => (
<BrandGallery brand='Chocris' />
)
|
app/components/DataRangeForm.js
|
seungha-kim/grade-sms
|
// @flow
import React, { Component } from 'react';
import RaisedButton from 'material-ui/RaisedButton';
import type { Map as IMap } from 'immutable';
import { Card, CardTitle, CardText, CardActions } from 'material-ui/Card';
import FlatButton from 'material-ui/FlatButton';
import { basename } from 'path';
import s from './DataRangeForm.css';
import cs from './commonStyles.css';
import DataRangeField from './DataRangeField';
import HelpText from './HelpText';
type Props = {
formData: IMap<string, any>,
filePath: string,
nextStep: () => void,
previousStep: () => void,
updateRangeThunk: (string, string) => void,
addTest: () => void,
removeTest: (string) => void,
addHomework: () => void,
removeHomework: (string) => void
};
const buttonStyle = {
marginLeft: 12
};
const cardStyle = {
marginTop: 30
};
const cardTitleStyle = {
display: 'flex',
alignItems: 'center'
};
const rangeHintText = 'X10:X100';
// const target = e.target;
// if (!(target instanceof HTMLInputElement)) return;
// const dataRange = target.value;
export default class DataRangeForm extends Component {
props: Props;
render() {
const {
formData,
filePath,
// onError,
nextStep,
previousStep,
updateRangeThunk,
addTest,
removeTest,
addHomework,
removeHomework
} = this.props;
// onError('haha');
return (
<div className={s.wrap}>
<div className={s.content}>
<HelpText>
์ฑ์ ํ ์์ฑ์ ์ฌ์ฉ๋ ๋ฐ์ดํฐ ๋ฒ์๋ฅผ ์
๋ ฅํ๋ ๊ณผ์ ์
๋๋ค. <br />
๊ฐ ํญ๋ชฉ์ ํด๋นํ๋ ๋ฐ์ดํฐ ๋ฒ์๋ฅผ ์
๋ ฅํด์ฃผ์ธ์. (์: <code>X15:X1000</code>)
</HelpText>
<Card style={cardStyle}>
<CardTitle title="๊ธฐ๋ณธ ์ฌํญ" subtitle={basename(filePath)} />
<CardText>
<DataRangeField
hintText={rangeHintText}
floatingLabelText="์ด๋ฆ"
fieldData={formData.getIn(['privacyRangeSet', 'name'])}
updateRangeThunk={updateRangeThunk}
/>
<DataRangeField
hintText={rangeHintText}
floatingLabelText="ํ๊ต"
fieldData={formData.getIn(['privacyRangeSet', 'school'])}
updateRangeThunk={updateRangeThunk}
/>
<DataRangeField
hintText={rangeHintText}
floatingLabelText="์๋ฒ"
fieldData={formData.getIn(['privacyRangeSet', 'id'])}
updateRangeThunk={updateRangeThunk}
/>
<DataRangeField
hintText={rangeHintText}
floatingLabelText="๋ถ๋ชจ๋ ์ฐ๋ฝ์ฒ"
fieldData={formData.getIn(['privacyRangeSet', 'phone'])}
updateRangeThunk={updateRangeThunk}
/>
</CardText>
</Card>
<div>
{formData.get('testRangeSets').map((fieldSet, i) => <Card key={fieldSet.get('setKey')} style={cardStyle}>
<CardTitle title={`์ํ ${i + 1}`} style={cardTitleStyle} />
<CardText>
<DataRangeField
hintText={rangeHintText}
floatingLabelText="๋ฐ"
fieldData={fieldSet.getIn(['fields', 'class'])}
updateRangeThunk={updateRangeThunk}
/>
<DataRangeField
hintText={rangeHintText}
floatingLabelText="์ถ๊ฒฐ"
fieldData={fieldSet.getIn(['fields', 'attendance'])}
updateRangeThunk={updateRangeThunk}
/>
<DataRangeField
hintText={rangeHintText}
floatingLabelText="์ ์"
fieldData={fieldSet.getIn(['fields', 'grade'])}
updateRangeThunk={updateRangeThunk}
/>
</CardText>
<CardActions>
<FlatButton
disabled={formData.get('testRangeSets').size <= 1}
secondary
label="์ญ์ "
onClick={() => removeTest(fieldSet.get('setKey'))}
/>
</CardActions>
</Card>)}
</div>
<div>
{formData.get('homeworkRangeSets').map((fieldSet, i) => <Card key={fieldSet.get('setKey')} style={cardStyle}>
<CardTitle title={`์์ ${i + 1}`} style={cardTitleStyle} />
<CardText>
<DataRangeField
hintText={rangeHintText}
floatingLabelText="๋ฐ"
fieldData={fieldSet.getIn(['fields', 'class'])}
updateRangeThunk={updateRangeThunk}
/>
<DataRangeField
hintText={rangeHintText}
floatingLabelText="์ ์"
fieldData={fieldSet.getIn(['fields', 'grade'])}
updateRangeThunk={updateRangeThunk}
/>
</CardText>
<CardActions>
<FlatButton secondary label="์ญ์ " onClick={() => removeHomework(fieldSet.get('setKey'))} />
</CardActions>
</Card>)}
</div>
</div>
<div className={cs.buttonWrap}>
<RaisedButton label="์ํ ์ถ๊ฐ" onClick={addTest} style={buttonStyle} />
<RaisedButton label="์์ ์ถ๊ฐ" onClick={addHomework} style={buttonStyle} />
<RaisedButton label="๋ค๋ก" secondary onClick={previousStep} style={buttonStyle} />
<RaisedButton label="๋ค์" primary disabled={!formData.get('allRangesValid')} onClick={nextStep} style={buttonStyle} />
</div>
</div>
);
}
}
|
react-router-tutorial/lessons/07-more-nesting/index.js
|
zerotung/practices-and-notes
|
import React from 'react'
import { render } from 'react-dom'
import { Router, Route, hashHistory } from 'react-router'
import App from './modules/App'
import About from './modules/About'
import Repos from './modules/Repos'
import Repo from './modules/Repo'
render((
<Router history={hashHistory}>
<Route path="/" component={App}>
<Route path="/repos" component={Repos}/>
<Route path="/repos/:userName/:repoName" component={Repo}/>
<Route path="/about" component={About}/>
</Route>
</Router>
), document.getElementById('app'))
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.