path stringlengths 5 195 | repo_name stringlengths 5 79 | content stringlengths 25 1.01M |
|---|---|---|
src/Input/Textarea.js | AndriusBil/material-ui | // @flow
import React from 'react';
import classnames from 'classnames';
import debounce from 'lodash/debounce';
import EventListener from 'react-event-listener';
import withStyles from '../styles/withStyles';
const rowsHeight = 24;
export const styles = {
root: {
position: 'relative', // because the shadow has position: 'absolute',
},
textarea: {
width: '100%',
height: '100%',
resize: 'none',
font: 'inherit',
padding: 0,
cursor: 'inherit',
boxSizing: 'border-box',
lineHeight: 'inherit',
border: 'none',
outline: 'none',
background: 'transparent',
},
shadow: {
resize: 'none',
// Overflow also needed to here to remove the extra row
// added to textareas in Firefox.
overflow: 'hidden',
// Visibility needed to hide the extra text area on ipads
visibility: 'hidden',
position: 'absolute',
height: 'auto',
whiteSpace: 'pre-wrap',
},
};
type DefaultProps = {
classes: Object,
};
export type Props = {
/**
* Useful to extend the style applied to components.
*/
classes?: Object,
/**
* @ignore
*/
className?: string,
/**
* @ignore
*/
defaultValue?: string,
/**
* @ignore
*/
disabled?: boolean,
/**
* @ignore
*/
onChange?: Function,
/**
* Number of rows to display when multiline option is set to true.
*/
rows?: string | number,
/**
* Maximum number of rows to display when multiline option is set to true.
*/
rowsMax?: string | number,
/**
* Use that property to pass a ref callback to the native textarea element.
*/
textareaRef?: Function,
/**
* @ignore
*/
value?: string,
};
type AllProps = DefaultProps & Props;
type State = {
height: ?number,
};
/**
* @ignore - internal component.
*/
class Textarea extends React.Component<AllProps, State> {
props: AllProps;
shadow: ?HTMLInputElement;
singlelineShadow: ?HTMLInputElement;
input: ?HTMLInputElement;
value: string;
static defaultProps = {
rows: 1,
};
state = {
height: null,
};
componentWillMount() {
// <Input> expects the components it renders to respond to 'value'
// so that it can check whether they are dirty
this.value = this.props.value || this.props.defaultValue || '';
this.setState({
height: Number(this.props.rows) * rowsHeight,
});
}
componentDidMount() {
this.syncHeightWithShadow(null);
}
componentWillReceiveProps(nextProps) {
if (
nextProps.value !== this.props.value ||
Number(nextProps.rowsMax) !== Number(this.props.rowsMax)
) {
this.syncHeightWithShadow(null, nextProps);
}
}
componentWillUnmount() {
this.handleResize.cancel();
}
handleResize = debounce(event => {
this.syncHeightWithShadow(event);
}, 166);
syncHeightWithShadow(event, props = this.props) {
if (this.shadow && this.singlelineShadow) {
// The component is controlled, we need to update the shallow value.
if (typeof this.props.value !== 'undefined') {
this.shadow.value = props.value || '';
}
const lineHeight = this.singlelineShadow.scrollHeight;
let newHeight = this.shadow.scrollHeight;
// Guarding for jsdom, where scrollHeight isn't present.
// See https://github.com/tmpvar/jsdom/issues/1013
if (newHeight === undefined) {
return;
}
if (Number(props.rowsMax) >= Number(props.rows)) {
newHeight = Math.min(Number(props.rowsMax) * lineHeight, newHeight);
}
newHeight = Math.max(newHeight, lineHeight);
if (this.state.height !== newHeight) {
this.setState({
height: newHeight,
});
}
}
}
handleRefInput = node => {
this.input = node;
if (this.props.textareaRef) {
this.props.textareaRef(node);
}
};
handleRefSinglelineShadow = node => {
this.singlelineShadow = node;
};
handleRefShadow = node => {
this.shadow = node;
};
handleChange = (event: SyntheticInputEvent<HTMLInputElement>) => {
this.value = event.target.value;
if (typeof this.props.value === 'undefined' && this.shadow) {
// The component is not controlled, we need to update the shallow value.
this.shadow.value = this.value;
this.syncHeightWithShadow(event);
}
if (this.props.onChange) {
this.props.onChange(event);
}
};
render() {
const {
classes,
className,
defaultValue,
onChange,
rows,
rowsMax,
textareaRef,
value,
...other
} = this.props;
return (
<div className={classes.root} style={{ height: this.state.height }}>
<EventListener target="window" onResize={this.handleResize} />
<textarea
ref={this.handleRefSinglelineShadow}
className={classnames(classes.shadow, classes.textarea)}
tabIndex={-1}
rows="1"
readOnly
aria-hidden="true"
value=""
/>
<textarea
ref={this.handleRefShadow}
className={classnames(classes.shadow, classes.textarea)}
tabIndex={-1}
rows={rows}
aria-hidden="true"
readOnly
defaultValue={defaultValue}
value={value}
/>
<textarea
ref={this.handleRefInput}
rows={rows}
className={classnames(classes.textarea, className)}
defaultValue={defaultValue}
value={value}
onChange={this.handleChange}
{...other}
/>
</div>
);
}
}
export default withStyles(styles, { name: 'MuiTextarea' })(Textarea);
|
src/app/components/feedItem.js | nazar/soapee-ui | import moment from 'moment';
import React from 'react';
import { Link } from 'react-router';
import MarkedDisplay from 'components/markedDisplay';
import ImageableThumbnails from 'components/imageableThumbnails';
import UserAvatar from 'components/userAvatar';
export default React.createClass( {
render() {
let { feedItem } = this.props;
let { user } = feedItem.feedable_meta;
return (
<div className="feed-item media">
<div className="media-left">
<UserAvatar
user={ user }
/>
</div>
<div className="media-body">
<div className="about">
<span className="user">
<Link to="userProfile" params={ { id: user.id } }>{ user.name }</Link>
</span>
{ this.renderActionDescription() }
<span className="time"
title={ moment( feedItem.created_at ).format( 'LLLL' ) }
>
{ moment( feedItem.created_at ).fromNow() }
</span>
</div>
{ this.renderFeedableType() }
</div>
</div>
);
},
renderActionDescription() {
let { feedable_meta } = this.props.feedItem;
let action = {
status_updates: statusUpdate,
comments: comment,
recipes: recipes,
recipe_journals: recipeJournals,
users: () => <span> joined</span>
}[ this.props.feedItem.feedable_type ];
return action();
function statusUpdate() {
return (
<span> posted a <Link to="status-update" params={ { id: feedable_meta.target.id } }><strong>status update</strong></Link></span>
);
}
function comment() {
return (
<span> commented on
<Link to={feedable_meta.target.targetType} params={ { id: feedable_meta.target.id } }>
<strong>{feedable_meta.target.name}</strong>
</Link>
</span>
);
}
function recipes() {
return (
<span> {feedable_meta.target.actionType}
<Link to="recipe" params={ { id: feedable_meta.target.id } }>
<strong>{feedable_meta.target.name}</strong>
</Link>
</span>
);
}
function recipeJournals() {
return (
<span> added a <strong>Recipe Journal</strong> to
<Link to="recipe" params={ { id: feedable_meta.target.id } }>
<strong>{feedable_meta.target.name}</strong>
</Link>
</span>
);
}
},
renderFeedableType() {
let { feedable_meta } = this.props.feedItem;
let renderer = {
status_updates: renderStatusUpdate.bind( this ),
comments: renderCommentUpdate.bind( this ),
recipes: renderRecipe.bind( this ),
recipe_journals: renderRecipeJournals.bind( this ),
users: () => {}
}[ this.props.feedItem.feedable_type ];
return renderer();
function renderStatusUpdate() {
return (
<div className="status-update">
<MarkedDisplay
content={ feedable_meta.target.update }
/>
<ImageableThumbnails
images={ this.props.feedItem.feedable.images }
/>
</div>
);
}
function renderCommentUpdate() {
return (
<div className="status-comment">
<MarkedDisplay
content={ feedable_meta.target.comment || '' }
/>
</div>
);
}
function renderRecipe() {
return (
<div className="status-recipe">
<ImageableThumbnails
images={ this.props.feedItem.feedable.images }
/>
</div>
);
}
function renderRecipeJournals() {
return (
<div className="status-recipe-journals">
<MarkedDisplay
content={ feedable_meta.target.journal }
/>
<ImageableThumbnails
images={ this.props.feedItem.feedable.images }
/>
</div>
);
}
}
} ); |
03-mybooks-lab4/src/Book.js | iproduct/course-node-express-react | import React from 'react';
import './Book.css';
export default function Book({ book, ...rest }) {
return (
<div className="card-wrapper col s12 l6 Book-card">
<div className="card horizontal">
<div className="card-image waves-effect waves-block waves-light">
<img
className="activator Book-front-image"
src={book.frontPage}
alt="front page"
/>
</div>
<div className="card-content">
<span className="card-title activator grey-text text-darken-4">
{book.title}
<i className="material-icons right">more_vert</i>
</span>
<p>{book.subtitle}</p>
<div className="card-action Book-card-action">
<a href="books?remove={{.ID}}">Add to Favs</a>
</div>
</div>
<div className="card-reveal">
<span className="card-title grey-text text-darken-4">
{book.title}
<i className="material-icons right">close</i>
</span>
<p>{book.subtitle}</p>
</div>
</div>
</div>
);
}
|
web/src/presentation/retro-results.js | mgwalker/retros | import React from 'react';
function getResults(resultList) {
const results = [];
for (const result of resultList) {
results.push(
<div key={`retro-results-${result.name}`}>
<div className="usa-width-one-twelfth">{result.votes}</div>
<div>{result.name}</div>
</div>
);
}
return results;
}
function getResultGroup(groupName, results) {
return (
<div key={`retro-result-group-${groupName}`}>
<h2>{groupName}</h2>
<div className="usa-grid">
{getResults(results[groupName])}
</div>
</div>
);
}
function getAllResultGroups(results) {
const groups = [];
if (typeof results !== 'undefined') {
for (const name of Object.keys(results)) {
groups.push(getResultGroup(name, results));
}
}
return groups;
}
function getHappinessHistogram(histogram) {
if (histogram) {
return (
<div>
<h3>Retro Happiness</h3>
<div className="usa-grid">
<div className="usa-width-one-third">
☹️<br />{histogram[1]}
</div>
<div className="usa-width-one-third">
😐<br />{histogram[2]}
</div>
<div className="usa-width-one-third">
😃<br />{histogram[3]}
</div>
</div>
</div>
);
}
return null;
}
function retroResults(props) {
return (
<div className="usa-grid">
<h1>Retro Results</h1>
{getAllResultGroups(props.results.entries)}
{getHappinessHistogram(props.results.happinessHistogram)}
</div>
);
}
retroResults.propTypes = {
results: React.PropTypes.object.isRequired
};
export default retroResults;
|
app/layouts/login.js | jtparrett/countcals | import React from 'react'
import { StyleSheet, View, Text, Button } from 'react-native'
import Header from '../components/header'
import Input from '../components/input'
export default class Login extends React.Component {
constructor(props) {
super(props)
this.state = {
username: '',
password: ''
}
}
submit = () => {
this.props.API.post('auth', {...this.state}).then((response) => {
this.props.onLogin(response.data)
}).catch((error) => {
console.error(error.message)
})
}
render() {
return (
<View style={{ flex: 1 }}>
<Header />
<View style={ styles.container }>
<Input placeholder="Username" onChangeText={value => {
this.setState({
username: value
})
}} value={this.state.username} />
<Input placeholder="Password" onChangeText={value => {
this.setState({
password: value
})
}} value={this.state.password} secureTextEntry />
<Button title="Login" onPress={this.submit} />
</View>
</View>
)
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
margin: 20
}
}) |
app/javascript/mastodon/features/lists/components/new_list_form.js | pixiv/mastodon | import React from 'react';
import { connect } from 'react-redux';
import PropTypes from 'prop-types';
import { changeListEditorTitle, submitListEditor } from '../../../actions/lists';
import IconButton from '../../../components/icon_button';
import { defineMessages, injectIntl } from 'react-intl';
const messages = defineMessages({
label: { id: 'lists.new.title_placeholder', defaultMessage: 'New list title' },
title: { id: 'lists.new.create', defaultMessage: 'Add list' },
});
const mapStateToProps = state => ({
value: state.getIn(['listEditor', 'title']),
disabled: state.getIn(['listEditor', 'isSubmitting']),
});
const mapDispatchToProps = dispatch => ({
onChange: value => dispatch(changeListEditorTitle(value)),
onSubmit: () => dispatch(submitListEditor(true)),
});
@connect(mapStateToProps, mapDispatchToProps)
@injectIntl
export default class NewListForm extends React.PureComponent {
static propTypes = {
value: PropTypes.string.isRequired,
disabled: PropTypes.bool,
intl: PropTypes.object.isRequired,
onChange: PropTypes.func.isRequired,
onSubmit: PropTypes.func.isRequired,
};
handleChange = e => {
this.props.onChange(e.target.value);
}
handleSubmit = e => {
e.preventDefault();
this.props.onSubmit();
}
handleClick = () => {
this.props.onSubmit();
}
render () {
const { value, disabled, intl } = this.props;
const label = intl.formatMessage(messages.label);
const title = intl.formatMessage(messages.title);
return (
<form className='column-inline-form' onSubmit={this.handleSubmit}>
<label>
<span style={{ display: 'none' }}>{label}</span>
<input
className='setting-text'
value={value}
disabled={disabled}
onChange={this.handleChange}
placeholder={label}
/>
</label>
<IconButton
disabled={disabled}
icon='plus'
title={title}
onClick={this.handleClick}
/>
</form>
);
}
}
|
09-react-lab-b/src/app/index.js | iproduct/course-node-express-react | import React from 'react';
import { render } from 'react-dom';
import TodoApp from './todo-app';
import { hot } from 'react-hot-loader';
const root = document.getElementById('root');
render(<TodoApp />, root);
|
src/js/faz.js | INTA-Suelos/faz | // Punto de entrada de React, donde renderiza la aplicación entera y la inserta
// en el DOM.
import React from 'react'
import ReactDOM from 'react-dom'
import Root from './Root'
ReactDOM.render(Root, document.getElementById('faz'))
|
src/app/components/common/simple-tooltip.js | feedm3/unhypem-frontend | /**
* This component can be used to add a tooltip to an existing component.
*
* The existing component must be passed as child of the tooltip and the tooltip text itself must be passed as property.
*
* @author Fabian Dietenberger
*/
'use strict';
import React from 'react';
import PropTypes from 'prop-types';
import TetherComponent from 'react-tether';
export default class SimpleTooltip extends React.Component {
constructor(props) {
super(props);
this.state = {
isOpen: false
};
}
render() {
const { isOpen } = this.state;
// construct props conditionally
const props = {
attachment: this.props.attachment,
constraints: [{
to: 'window',
attachment: 'both'
}]
};
if (this.props.targetAttachment) {
props.targetAttachment = this.props.targetAttachment;
}
// construct styles
// TODO this is a 'quickfix' and could be done better
const triangleStyle = {};
if (this.props.targetAttachment === 'bottom left') {
triangleStyle.right = 'initial';
triangleStyle.left = '10px';
}
return (
<TetherComponent {...props}>
<div onMouseEnter={ () => this.setState({ isOpen: true }) }
onMouseLeave={ () => this.setState({ isOpen: false }) }>{ this.props.children }</div>
{
isOpen &&
<div className='tether-tooltip'>
<div className='tether-tooltip-content'>{ this.props.text }</div>
<div className='tether-tooltip-triangle' style={ triangleStyle }></div>
</div>
}
</TetherComponent>
);
}
}
SimpleTooltip.propTypes = {
children: PropTypes.node.isRequired,
text: PropTypes.string.isRequired,
attachment: PropTypes.oneOf(['top left', 'top center', 'top right', 'bottom left', 'bottom center', 'bottom right']),
targetAttachment: PropTypes.oneOf(['top left', 'top center', 'top right', 'bottom left', 'bottom center', 'bottom right'])
};
SimpleTooltip.defaultProps = {
attachment: 'top center'
};
|
app/containers/PlanSheet/index.js | hukid/shootingstudio | /*
*
* PlanSheet
*
*/
import React from 'react';
import ActorList from 'containers/ActorList';
const PlanSheet = (props) => {
let sheetRows = (<div className="row">empty</div>);
window.scnes = props.planSheet.scenes;
const scenes = props.planSheet.scenes;
if (scenes) {
sheetRows = scenes.map((scene, index) => (
<div key={`scene-${index}`} className="row">
<div className="col-md-3">{scene.seq}</div>
<div className="col-md-3">{props.stageDict[scene.stage_id].name}</div>
<div className="col-md-2">{scene.environment}</div>
<ActorList styleName="col-md-4" actorIds={scene.actors} actorDict={props.actorDict} />
</div>
));
}
return (
<div className="container">
<div className="row">
<div className="col-md-3">场次</div>
<div className="col-md-3">场景</div>
<div className="col-md-2">氛围</div>
<div className="col-md-4">主要演员</div>
</div>
{sheetRows}
</div>
);
};
PlanSheet.propTypes = {
planSheet: React.PropTypes.object.isRequired,
stageDict: React.PropTypes.object.isRequired,
actorDict: React.PropTypes.object.isRequired,
};
export default PlanSheet;
|
react/gameday2/components/embeds/EmbedHtml5.js | fangeugene/the-blue-alliance | /* global videojs */
import React from 'react'
import { webcastPropType } from '../../utils/webcastUtils'
export default class EmbedHtml5 extends React.Component {
static propTypes = {
webcast: webcastPropType.isRequired,
}
componentDidMount() {
videojs(this.props.webcast.id, {
width: '100%',
height: '100%',
autoplay: true,
crossorigin: 'anonymous',
})
}
render() {
return (
<video
controls
id={this.props.webcast.id}
className="video-js vjs-default-skin"
>
<source src={this.props.webcast.channel} type="application/x-mpegurl" />
</video>
)
}
}
|
src/components/availabilityschedule/Slot.js | ChrisWhiten/react-rink | import React from 'react';
import moment from 'moment';
import './Slot.css';
class Slot extends React.Component {
constructor() {
super();
this.state = {
open: false,
};
this.onClick = this.onClick.bind(this);
}
onClick() {
this.props.onClick(this.props.day, this.props.time);
}
render() {
return (
<div className='slot' onClick={this.onClick}>
{
this.props.time &&
<div className='slot-time'>
{ moment(this.props.time).format('LT') }
</div>
}
{
!this.props.time &&
<div className='add-icon-container'>
+
</div>
}
<div className='remove-slot'>
{ this.props.hoverText }
</div>
</div>
)
}
}
export default Slot;
|
src/parser/shared/modules/items/bfa/dungeons/AzerokksResonatingHeart.js | sMteX/WoWAnalyzer | import React from 'react';
import SPELLS from 'common/SPELLS';
import ITEMS from 'common/ITEMS';
import { formatPercentage } from 'common/format';
import { calculatePrimaryStat } from 'common/stats';
import ItemStatistic from 'interface/statistics/ItemStatistic';
import BoringItemValueText from 'interface/statistics/components/BoringItemValueText';
import AgilityIcon from 'interface/icons/Agility';
import Analyzer from 'parser/core/Analyzer';
import Abilities from 'parser/core/modules/Abilities';
const BASE_ITEM_LEVEL = 300;
const BASE_AGILITY_BUFF = 593;
/**
* Azerokk's Resonating Heart
* Equip: Your attacks have a chance to harmonize with the shard, granting you X Agility for 15 sec.
*
* Test log: http://wowanalyzer.com/report/PcaGB6n41NDMrbmA/1-Mythic+Champion+of+the+Light+-+Kill+(1:37)/Baboune/statistics
*/
class AzerokksResonatingHeart extends Analyzer {
static dependencies = {
abilities: Abilities,
};
constructor(...args) {
super(...args);
this.active = this.selectedCombatant.hasTrinket(ITEMS.AZEROKKS_RESONATING_HEART.id);
if(!this.active) {
return;
}
this.procs = 0;
const itemLevel = this.selectedCombatant.getItem(ITEMS.AZEROKKS_RESONATING_HEART.id).itemLevel;
this.agilityBuff = calculatePrimaryStat(BASE_ITEM_LEVEL, BASE_AGILITY_BUFF, itemLevel);
}
on_byPlayer_applybuff(event) {
this.handleBuff(event);
}
on_byPlayer_refreshbuff(event) {
this.handleBuff(event);
}
handleBuff(event) {
if(event.ability.guid !== SPELLS.BENEFICIAL_VIBRATIONS.id) {
return;
}
this.procs++;
}
get uptime() {
return this.selectedCombatant.getBuffUptime(SPELLS.BENEFICIAL_VIBRATIONS.id) / this.owner.fightDuration;
}
get averageAgility() {
return (this.agilityBuff * this.uptime).toFixed(0);
}
statistic() {
return (
<ItemStatistic
size="flexible"
tooltip={<>You procced <strong>{SPELLS.BENEFICIAL_VIBRATIONS.name}</strong> {this.procs} times with an uptime of {formatPercentage(this.uptime)}%.</>}
>
<BoringItemValueText item={ITEMS.AZEROKKS_RESONATING_HEART}>
<AgilityIcon /> {this.averageAgility} <small>average Agility gained</small>
</BoringItemValueText>
</ItemStatistic>
);
}
}
export default AzerokksResonatingHeart;
|
src/layouts/CoreLayout/CoreLayout.js | thanhiro/tuha-ui-tpl | import React from 'react';
import Helmet from 'react-helmet';
import Header from '../../components/Header';
import Footer from '../../components/Footer';
import classes from './CoreLayout.scss';
import '../../styles/core.scss';
export const CoreLayout = ({location, children}) => (
<div>
<Helmet meta={[
{'name': 'description', 'content': 'TUHA'}]} />
<Header location={location} />
<main className={'container ' + classes.mainContainer}>
{children}
</main>
<Footer />
</div>
);
CoreLayout.propTypes = {
location: React.PropTypes.object.isRequired,
children: React.PropTypes.element.isRequired
};
export default CoreLayout;
|
src/svg-icons/image/style.js | lawrence-yu/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let ImageStyle = (props) => (
<SvgIcon {...props}>
<path d="M2.53 19.65l1.34.56v-9.03l-2.43 5.86c-.41 1.02.08 2.19 1.09 2.61zm19.5-3.7L17.07 3.98c-.31-.75-1.04-1.21-1.81-1.23-.26 0-.53.04-.79.15L7.1 5.95c-.75.31-1.21 1.03-1.23 1.8-.01.27.04.54.15.8l4.96 11.97c.31.76 1.05 1.22 1.83 1.23.26 0 .52-.05.77-.15l7.36-3.05c1.02-.42 1.51-1.59 1.09-2.6zM7.88 8.75c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1zm-2 11c0 1.1.9 2 2 2h1.45l-3.45-8.34v6.34z"/>
</SvgIcon>
);
ImageStyle = pure(ImageStyle);
ImageStyle.displayName = 'ImageStyle';
ImageStyle.muiName = 'SvgIcon';
export default ImageStyle;
|
modules/react-documentation/src/components/Code.js | casesandberg/reactcss | 'use strict';
import React from 'react'
import reactCSS from 'reactcss'
import markdown from '../helpers/markdown'
import context from 'react-context'
var { Tile, Raised } = require('../../../react-material-design');
class Code extends React.Component {
render() {
const styles = reactCSS({
'default': {
shortCodeBlock: {
display: 'inline-block',
},
shortCode: {
padding: '14px 16px',
},
head: {
borderRadius: '2px 2px 0 0',
background: '#fafafa',
},
files: {
display: 'inline-block',
},
Files: {
align: 'none',
color: '#666',
},
center: {
fontFamily: 'Monaco',
fontSize: '14px',
lineHeight: '19px',
color: 'rgba(0,0,0,.77)',
},
numbers: {
fontSize: '14px',
lineHeight: '19px',
display: 'inline-block',
textAlign: 'right',
color: 'rgba(0,0,0,.20)',
userSelect: 'none',
paddingLeft: '7px',
},
},
'condensed': {
Tile: {
condensed: true,
},
center: {
paddingTop: '16px',
paddingBottom: '16px',
fontSize: '13px',
lineHeight: '15px',
overflowX: 'scroll',
},
numbers: {
paddingTop: '16px',
fontSize: '13px',
lineHeight: '15px',
},
},
}, {
'condensed': this.context.width < 500,
})
var code = markdown.getBody(this.props.file);
var args = markdown.getArgs(this.props.file);
var colorCoded = markdown.renderCode('```\n' + code + '').trim();
var lineCount = colorCoded.split('\n').length;
var lines;
if (args.lineDecoration) {
lines = args.lineDecoration;
} else {
lines = [];
for (var i = 1; i < lineCount; i++) {
lines.push(<div key={ i }>{ i }</div>);
}
}
return (
<Raised>
<Tile { ...styles.Tile }>
<div style={ styles.numbers }>
{ lines }
</div>
<div style={ styles.center }>
<style>{`
.rendered pre{
margin: 0;
}
.rendered p{
margin: 0;
}
`}</style>
<div className="rendered" dangerouslySetInnerHTML={{ __html: colorCoded }} />
</div>
</Tile>
</Raised>
);
}
}
Code.contextTypes = context.subscribe(['width']);
module.exports = Code;
|
src/docs/components/SectionDoc.js | grommet/grommet-docs | import React, { Component } from 'react';
import DocsArticle from '../../components/DocsArticle';
import Anchor from 'grommet/components/Anchor';
import Section from 'grommet/components/Section';
import Heading from 'grommet/components/Heading';
import Paragraph from 'grommet/components/Paragraph';
import Code from '../../components/Code';
Section.displayName = 'Section';
export const DESC = (
<span>
A standard <Anchor
href='http://www.w3.org/TR/html5/sections.html#the-section-element'>
HTML5 section</Anchor>. It might
contain a <Anchor path='/docs/heading'>Heading</Anchor>, one
or more <Anchor path='/docs/paragraph'>Paragraphs</Anchor>
, <Anchor path='/docs/image'>Images</Anchor>
, and <Anchor path='/docs/video'>Videos</Anchor>.
</span>
);
export default class SectionDoc extends Component {
render () {
return (
<DocsArticle title='Section'>
<section>
<p>{DESC}</p>
<Section colorIndex='light-2' pad='medium'>
<Heading tag='h2'>Sample Heading</Heading>
<Paragraph>Sample content.</Paragraph>
</Section>
</section>
<section>
<h2>Properties</h2>
<p>Properties for <Anchor path='/docs/box'>Box</Anchor> are
available.</p>
</section>
<section>
<h2>Usage</h2>
<Code preamble={`import Section from 'grommet/components/Section';`}>
<Section>
{'{contents}'}
</Section>
</Code>
</section>
</DocsArticle>
);
}
};
|
packages/react-dom/src/shared/checkReact.js | prometheansacrifice/react | /**
* Copyright (c) 2013-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/
import React from 'react';
import invariant from 'fbjs/lib/invariant';
invariant(
React,
'ReactDOM was loaded before React. Make sure you load ' +
'the React package before loading ReactDOM.',
);
|
src/js/components/shared/loading-progress.js | trwalker/marvel-react | import React from 'react';
class LoadingProgress extends React.Component {
constructor(props) {
super(props);
this.title_ = props.title ? props.title : 'Loading...';
this.initialProgressValue_ = props.initialProgressValue ? props.initialProgressValue : 0;
this.getCurrentProgress_ = props.getCurrentProgress ? props.getCurrentProgress : function(progress) { return ++progress; };
}
render() {
var instance = this;
return (
<div>
<div className="col-lg-12 col-md-12 col-sm-12 col-xs-12">
<div className="alert alert-info" role="alert">
{instance.title_}
</div>
</div>
<div className="col-lg-6 col-lg-offset-3 col-md-6 col-md-offset-3 col-sm-8 col-sm-offset-2 col-xs-12">
<div className="progress">
<div ref={ function(progressBar) { advanceProgressBar_(progressBar, 0, instance.initialProgressValue_, instance.getCurrentProgress_); } } className="progress-bar" role="progressbar" style={ { width:'0%' } }></div>
</div>
</div>
</div>
);
}
}
function advanceProgressBar_(progressBar, step, progress, getCurrentProgress) {
if(progressBar) {
var currentProgress = getCurrentProgress(progress);
progressBar.style.width = currentProgress + '%';
if (currentProgress < 99) {
window.requestAnimationFrame(function (step) {
advanceProgressBar_(progressBar, currentProgress, step, getCurrentProgress);
});
}
}
}
export default LoadingProgress;
|
gui/components/MainTab.js | venogram/ExpressiveJS | import React, { Component } from 'react';
import PropTypes from 'prop-types';
function MainTab(props) {
const method = props.routeId.split(' ')[0].slice(0,1) + props.routeId.split(' ')[0].slice(1).toLowerCase();
let classString = 'MainTab'
classString += (props.routeId === props.activeTab ? ' activeMainTab' : ' inactiveMainTab');
function escapeTab(e) {
e.stopPropagation();
props.escapeTab(props.routeId);
}
return (
<div className={classString} onClick={() => {props.onMainTabClick(props.routeId)}}>
<img className="tab-logo" src="./images/whiteTabLogo.png" />
{props.routeId}
<div className="escape-tab-container">
<div className="escape-tab" onClick={escapeTab}>x</div>
</div>
</div>
)
}
MainTab.propTypes = {
routeId: PropTypes.string,
activeTab: PropTypes.string
}
module.exports = MainTab;
|
src/pages/home.js | AlbinOS/book-keeper-ui | import React from 'react';
class Home extends React.Component {
render() {
return (
<div>
<h1>Welcome to Book Keeper !</h1>
<p>Serving live timetracking report of your JIRA project with love.</p>
</div>
);
}
}
export default Home;
|
src/Breadcrumb.js | HPate-Riptide/react-bootstrap | import classNames from 'classnames';
import React from 'react';
import BreadcrumbItem from './BreadcrumbItem';
import { bsClass, getClassSet, splitBsProps } from './utils/bootstrapUtils';
class Breadcrumb extends React.Component {
render() {
const { className, ...props } = this.props;
const [bsProps, elementProps] = splitBsProps(props);
const classes = getClassSet(bsProps);
return (
<ol
{...elementProps}
role="navigation"
aria-label="breadcrumbs"
className={classNames(className, classes)}
/>
);
}
}
Breadcrumb.Item = BreadcrumbItem;
export default bsClass('breadcrumb', Breadcrumb);
|
src/components/Snippets/abilityText.js | chaoticbackup/chaoticbackup.github.io | import React from 'react';
import processString from 'react-process-string';
import { MugicIcon, ElementIcon, DisciplineIcon, TribeIcon } from "./_icons";
export function abilityText(props) {
if (!props.ability || props.ability.length === 0) return "";
const mugic_counters = {
regex: /([0-9x]*){{mc}}/i,
fn: (key, result) => {
if (result.length > 1 && result[1] != "") {
return (<MugicIcon key={key} tribe={props.tribe} amount={result[1].toLowerCase()} size={props.size || "icon14"} />);
}
return (<MugicIcon key={key} tribe={props.tribe} size={props.size || "icon14"} />);
}
};
const elements = {
regex: new RegExp(/(\b((fire)|(air)|(earth)|(water))\b)/i),
fn: (key, result) => {
return (<span key={key}><ElementIcon element={result[0].replace(/\b/, '')} value="true" size={props.size || "icon14"} />{result[0]}</span>);
}
};
const disciplines = {
regex: /(courage)|(power)|(wisdom)|(speed)/i,
fn: (key, result) => {
return (<span key={key}><DisciplineIcon discipline={result[0]} size={props.size || "icon14"} />{result[0]}</span>);
}
};
const tribes = {
regex: /(danian)|(generic)|(mipedian)|(overworld)|(underworld)|(m'arrillian)/i,
fn: (key, result) => {
return (<span key={key}><TribeIcon tribe={result[0]} size={props.size || "icon14"} />{result[0]}</span>);
}
};
const filters = [mugic_counters, elements, disciplines, tribes];
return processString(filters)(props.ability);
}
|
assets/node_modules/react-router/es/IndexRoute.js | janta-devs/nyumbani | import React from 'react';
import warning from './routerWarning';
import invariant from 'invariant';
import { createRouteFromReactElement as _createRouteFromReactElement } from './RouteUtils';
import { component, components, falsy } from './InternalPropTypes';
var func = React.PropTypes.func;
/**
* An <IndexRoute> is used to specify its parent's <Route indexRoute> in
* a JSX route config.
*/
/* eslint-disable react/require-render-return */
var IndexRoute = React.createClass({
displayName: 'IndexRoute',
statics: {
createRouteFromReactElement: function createRouteFromReactElement(element, parentRoute) {
/* istanbul ignore else: sanity check */
if (parentRoute) {
parentRoute.indexRoute = _createRouteFromReactElement(element);
} else {
process.env.NODE_ENV !== 'production' ? warning(false, 'An <IndexRoute> does not make sense at the root of your route config') : void 0;
}
}
},
propTypes: {
path: falsy,
component: component,
components: components,
getComponent: func,
getComponents: func
},
/* istanbul ignore next: sanity check */
render: function render() {
!false ? process.env.NODE_ENV !== 'production' ? invariant(false, '<IndexRoute> elements are for router configuration only and should not be rendered') : invariant(false) : void 0;
}
});
export default IndexRoute; |
client/modules/Poll/components/PollCreateModal/PollNameInput.js | maicongil/fcc_voting_app | import React from 'react';
import { Input } from 'semantic-ui-react';
export default function PollNameInput(props){
return (
<Input {...props}
label={{ basic: true, content: '?' }}
labelPosition='right'
placeholder='Enter question...'
/>
);
} |
src/index.js | TylerFoss/weather-app | import React from 'react';
import ReactDOM from 'react-dom';
import { Provider } from 'react-redux';
import { createStore, applyMiddleware } from 'redux';
import ReduxPromise from "redux-promise";
import App from './components/app';
import reducers from './reducers';
const createStoreWithMiddleware = applyMiddleware(ReduxPromise)(createStore);
ReactDOM.render(
<Provider store={createStoreWithMiddleware(reducers)}>
<App />
</Provider>
, document.querySelector('.container'));
|
packages/react-scripts/fixtures/kitchensink/src/features/webpack/SassInclusion.js | mangomint/create-react-app | /**
* Copyright (c) 2015-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import React from 'react';
import './assets/sass-styles.sass';
export default () => <p id="feature-sass-inclusion">We love useless text.</p>;
|
src/containers/SearchForm.js | houkah26/reddit-clone | import React, { Component } from 'react';
import SearchResults from '../components/SearchResults';
import './SearchForm.css'
const filterResults = (searchResults) => {
let filteredResults = [];
searchResults.forEach(sub => {
if (sub.data.subscribers > 5) {
filteredResults.push(sub.data);
}
});
const maxNumResults = 5;
return filteredResults.slice(0, Math.min(maxNumResults, filteredResults.length));
};
export default class SearchForm extends Component {
state = {
searchTerm: '',
searchResults: []
};
handleChange = (event) => {
this.setState({
searchTerm: event.target.value,
searchResults: []
});
}
handleSubmit = (event) => {
event.preventDefault();
this.searchSub(this.state.searchTerm);
}
searchSub = async (searchTerm) => {
const response = await fetch(`https://www.reddit.com/subreddits/search.json?q=${searchTerm}`);
const jsonResponse = await response.json();
const results = jsonResponse.data.children;
this.setState({searchResults: filterResults(results)});
}
render() {
const {
searchTerm,
searchResults
} = this.state;
return (
<div className="search">
<form onSubmit={this.handleSubmit}>
<span className="fa fa-search"/>
<input
type="text"
placeholder="subreddit"
value={searchTerm}
onChange={this.handleChange}
/>
<SearchResults
searchResults={searchResults}
toggleCollapse={this.props.toggleCollapse}
/>
</form>
</div>
);
}
}
|
src/Home.js | believer/movies | // @flow
import React from 'react'
import { StyleSheet, Text, View } from 'react-native'
import Feed from './Feed'
import Movie from './Movie'
import AddMovie from './AddMovie'
import { StackNavigator, TabNavigator } from 'react-navigation'
import Dimensions from 'Dimensions'
const { width } = Dimensions.get('window')
export class Home extends React.Component {
static navigationOptions = {
title: 'Feed',
headerStyle: {
backgroundColor: '#25292E',
borderBottomWidth: 0
},
headerTitleStyle: {
color: '#25292E'
}
}
render() {
const { navigate } = this.props.navigation
return (
<View
style={{
backgroundColor: '#fff',
flex: 1
}}
>
<View
style={{
width,
backgroundColor: '#25292E',
borderBottomColor: '#efefef',
borderBottomWidth: 1,
position: 'absolute',
top: 0,
height: 300
}}
/>
<Feed navigate={navigate} />
</View>
)
}
}
const HomeNav = StackNavigator({
Feed: {
screen: Home
},
Movie: {
screen: Movie
}
})
export default TabNavigator(
{
Home: { screen: HomeNav },
AddMovie: { screen: AddMovie }
},
{
tabBarPosition: 'bottom',
tabBarOptions: {
lazyLoad: true,
tabStyle: {
paddingBottom: 10
}
}
}
)
|
components/Person.js | pcm-ca/pcm-ca.github.io | import React from 'react';
import {Link} from 'react-router';
const Person = ({ name, email, picture, link }) => (
<Link className='person' to={link}>
<center><img src={picture} alt="foto" className="person--picture" /></center>
<div className="person--info">
<span className="person--name">{name}</span>
<small className="person--email">{email}</small>
</div>
</Link>
);
Person.propTypes = {
name: React.PropTypes.string.isRequired,
email: React.PropTypes.string.isRequired,
picture: React.PropTypes.string.isRequired,
link: React.PropTypes.string.isRequired,
}
export default Person; |
app/components/AppContainer.js | shug0/Awesomidi | import React from 'react';
// MATERIAL
import {blue500, cyan700, pinkA200, cyan500} from 'material-ui/styles/colors';
import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider';
import getMuiTheme from 'material-ui/styles/getMuiTheme';
// COMPONENT
import Navigation from '../components/0_Global/Navigation/NavigationContainer';
// CSS
import './0_Global/CSS/reset.css';
import './0_Global/CSS/base.css';
// ----- COLOR THEME -----
const muiTheme = getMuiTheme({
palette: {
primary1Color: blue500,
primary2Color: cyan700,
accent1Color: pinkA200,
pickerHeaderColor: cyan500,
}
});
const AppContainer = ({ children, location }) => (
<MuiThemeProvider muiTheme={muiTheme}>
<div>
<Navigation title="Awesomidi"/>
{React.cloneElement(children, {
key: location.pathname
})}
</div>
</MuiThemeProvider>
);
export default AppContainer;
|
content/src/scripts/components/app/HighlightsTray.js | CaliAlec/ChromeIGStory | import React, { Component } from 'react';
import {connect} from 'react-redux';
import LinearProgress from '@material-ui/core/LinearProgress';
import MenuItem from '@material-ui/core/MenuItem';
import StoryTrayItem from './StoryTrayItem';
import InstagramApi from '../../../../../utils/InstagramApi';
import {setCurrentStoryObject} from '../../utils/ContentUtils';
class HighlightsTray extends Component {
constructor(props) {
super(props);
this.state = {
highlightItems: this.props.highlightItems
}
}
componentDidMount() {
var unfetchedHighlightItemIds = [];
this.state.highlightItems.forEach(function(highlightItem) {
if(!highlightItem.items) {
unfetchedHighlightItemIds.push(highlightItem.id);
}
});
if(unfetchedHighlightItemIds.length > 0) {
InstagramApi.getReelsMedia(unfetchedHighlightItemIds, (reels) => {
var tempHighlightItems = this.state.highlightItems;
tempHighlightItems.forEach(function(highlightItem, index) {
if(!highlightItem.items) {
tempHighlightItems[index].items = reels.reels[highlightItem.id].items;
}
});
this.setState({highlightItems: tempHighlightItems});
}).catch(function(e) {
// TODO: figure out why reelsMedia API sometimes fails
// remove all highlights that weren't possible to fetch
this.setState({highlightItems: this.state.highlightItems.filter(tempHighlightItem => tempHighlightItem.items)});
}.bind(this));
}
}
onViewUserStory(storyItem) {
setCurrentStoryObject('USER_STORY', storyItem);
}
render() {
const highlightTrayItems = this.state.highlightItems.map((storyTrayItem, key) => {
return (
<StoryTrayItem
key={key}
trayItemIndex={key}
storyItem={storyTrayItem}
onViewUserStory={(storyItem) => this.onViewUserStory(storyItem)}
/>
)
});
return (
<div>
<div className="trayContainer">
{highlightTrayItems}
</div>
<div className="trayContainerEdgeFade"></div>
</div>
)
}
}
export default connect(null)(HighlightsTray); |
admin/client/App/components/Navigation/Secondary/NavItem.js | michaelerobertsjr/keystone | /**
* A navigation item of the secondary navigation
*/
import React from 'react';
import { Link } from 'react-router';
const SecondaryNavItem = React.createClass({
displayName: 'SecondaryNavItem',
propTypes: {
children: React.PropTypes.node.isRequired,
className: React.PropTypes.string,
href: React.PropTypes.string.isRequired,
path: React.PropTypes.string,
title: React.PropTypes.string,
},
render () {
return (
<li className={this.props.className} data-list-path={this.props.path}>
<Link to={this.props.href} title={this.props.title} tabIndex="-1">
{this.props.children}
</Link>
</li>
);
},
});
module.exports = SecondaryNavItem;
|
index.ios.js | fabriziomoscon/pepperoni-app-kit | import {Provider} from 'react-redux';
import store from './src/redux/store';
import AppViewContainer from './src/modules/AppViewContainer';
import React from 'react';
import {AppRegistry} from 'react-native';
const PepperoniAppTemplate = React.createClass({
render() {
return (
<Provider store={store}>
<AppViewContainer />
</Provider>
);
}
});
AppRegistry.registerComponent('PepperoniAppTemplate', () => PepperoniAppTemplate);
|
client/index.js | sethkaufee/TherapyApp | /**
* Client entry point
*/
import React from 'react';
import { render } from 'react-dom';
import { AppContainer } from 'react-hot-loader';
import App from './App';
import { configureStore } from './store';
// Initialize store
const store = configureStore(window.__INITIAL_STATE__);
const mountApp = document.getElementById('root');
render(
<AppContainer>
<App store={store} />
</AppContainer>,
mountApp
);
// For hot reloading of react components
if (module.hot) {
module.hot.accept('./App', () => {
// If you use Webpack 2 in ES modules mode, you can
// use <App /> here rather than require() a <NextApp />.
const NextApp = require('./App').default; // eslint-disable-line global-require
render(
<AppContainer>
<NextApp store={store} />
</AppContainer>,
mountApp
);
});
}
|
client/components/ViewPost.js | JayMc/react-crud-example | import React from 'react';
export default React.createClass({
render() {
let post = this.props.posts.filter((post) => {
if (post.id == this.props.params.id) return post;
})[0];
return (
<div>
<h3>Post details</h3>
<p>{post.title}</p>
</div>
);
},
});
|
views/decoration_toggle.js | alessandrostone/black-screen | import React from 'react';
export default React.createClass({
getInitialState() {
return {enabled: this.props.invocation.state.decorate};
},
handleClick(event) {
stopBubblingUp(event);
var newState = !this.state.enabled;
this.setState({enabled: newState});
this.props.invocation.setState({decorate: newState});
},
render() {
var classes = ['decoration-toggle'];
if (!this.state.enabled) {
classes.push('disabled');
}
return (
<a href="#" className={classes.join(' ')} onClick={this.handleClick}>
<i className="fa fa-magic"></i>
</a>
);
}
});
|
docs/src/PageFooter.js | roadmanfong/react-bootstrap | import React from 'react';
import packageJSON from '../../package.json';
let version = packageJSON.version;
if (/docs/.test(version)) {
version = version.split('-')[0];
}
const PageHeader = React.createClass({
render() {
return (
<footer className='bs-docs-footer' role='contentinfo'>
<div className='container'>
<div className='bs-docs-social'>
<ul className='bs-docs-social-buttons'>
<li>
<iframe className='github-btn'
src='http://ghbtns.com/github-btn.html?user=react-bootstrap&repo=react-bootstrap&type=watch&count=true'
width={95}
height={20}
title='Star on GitHub' />
</li>
<li>
<iframe className='github-btn'
src='http://ghbtns.com/github-btn.html?user=react-bootstrap&repo=react-bootstrap&type=fork&count=true'
width={92}
height={20}
title='Fork on GitHub' />
</li>
<li>
<iframe
src="http://platform.twitter.com/widgets/follow_button.html?screen_name=react_bootstrap&show_screen_name=true"
width={230}
height={20}
allowTransparency="true"
frameBorder='0'
scrolling='no'>
</iframe>
</li>
</ul>
</div>
<p>Code licensed under <a href='https://github.com/react-bootstrap/react-bootstrap/blob/master/LICENSE' target='_blank'>MIT</a>.</p>
<ul className='bs-docs-footer-links muted'>
<li>Currently v{version}</li>
<li>·</li>
<li><a href='https://github.com/react-bootstrap/react-bootstrap/'>GitHub</a></li>
<li>·</li>
<li><a href='https://github.com/react-bootstrap/react-bootstrap/issues?state=open'>Issues</a></li>
<li>·</li>
<li><a href='https://github.com/react-bootstrap/react-bootstrap/releases'>Releases</a></li>
</ul>
</div>
</footer>
);
}
});
export default PageHeader;
|
src/parser/priest/holy/modules/features/HolyPriestHealingEfficiencyDetails.js | sMteX/WoWAnalyzer | import React from 'react';
import Analyzer from 'parser/core/Analyzer';
import Panel from 'interface/others/Panel';
import HealingEfficiencyTracker from './HolyPriestHealingEfficiencyTracker';
import HealingEfficiencyBreakdown from './HolyPriestHealingEfficiencyBreakdown';
class HolyPriestHealingEfficiencyDetails extends Analyzer {
static dependencies = {
healingEfficiencyTracker: HealingEfficiencyTracker,
};
tab() {
return {
title: 'Mana Efficiency',
url: 'mana-efficiency',
render: () => {
return (
<Panel>
<HealingEfficiencyBreakdown
tracker={this.healingEfficiencyTracker}
showSpenders
/>
</Panel>
);
},
};
}
}
export default HolyPriestHealingEfficiencyDetails;
|
docs/components/Homepage/Featured/index.js | enjoylife/storybook | import React from 'react';
import PropTypes from 'prop-types';
import './style.css';
const Item = ({ storybook, owner, source }) =>
<div className="ft-sbooks col-xs-6 col-md-4" key={storybook.link}>
<div className="col-md-4">
<a href={storybook.link} target="_blank" rel="noopener noreferrer">
<center>
<img className="ft-logo" src={owner} alt="" />
</center>
</a>
</div>
<div className="desc col-md-8">
<p>
<a href={storybook.link} className="reponame">
{storybook.name}
</a>
</p>
<a href={source} target="_blank" rel="noopener noreferrer">source</a>
</div>
</div>;
Item.propTypes = {
storybook: PropTypes.object.isRequired, // eslint-disable-line
owner: PropTypes.string.isRequired,
source: PropTypes.string.isRequired,
};
const Featured = ({ featuredStorybooks }) =>
<div id="featured" className="row">
<div className="col-xs-12">
<h2>Featured Storybooks</h2>
<div className="row">
{featuredStorybooks.map(item => <Item {...item} />)}
</div>
<hr />
</div>
</div>;
Featured.propTypes = {
featuredStorybooks: PropTypes.array, // eslint-disable-line
};
export default Featured;
|
examples/real-world/index.js | chicoxyzzy/redux | import 'babel-core/polyfill';
import React from 'react';
import createBrowserHistory from 'history/lib/createBrowserHistory';
import { Provider } from 'react-redux';
import { Router, Route } from 'react-router';
import configureStore from './store/configureStore';
import App from './containers/App';
import UserPage from './containers/UserPage';
import RepoPage from './containers/RepoPage';
const history = createBrowserHistory();
const store = configureStore();
React.render(
<Provider store={store}>
{() =>
<Router history={history}>
<Route path="/" component={App}>
<Route path="/:login/:name"
component={RepoPage} />
<Route path="/:login"
component={UserPage} />
</Route>
</Router>
}
</Provider>,
document.getElementById('root')
);
|
app/javascript/mastodon/features/compose/index.js | pixiv/mastodon | import classNames from 'classnames';
import React from 'react';
import ComposeFormContainer from './containers/compose_form_container';
import NavigationContainer from './containers/navigation_container';
import PropTypes from 'prop-types';
import ImmutablePropTypes from 'react-immutable-proptypes';
import { connect } from 'react-redux';
import { mountCompose, unmountCompose } from '../../actions/compose';
import { Link } from 'react-router-dom';
import { injectIntl, defineMessages } from 'react-intl';
import SearchContainer from './containers/search_container';
import Motion from '../ui/util/optional_motion';
import spring from 'react-motion/lib/spring';
import SearchResultsContainer from './containers/search_results_container';
import { changeComposing } from '../../actions/compose';
import { setPage as pawooSetPage } from '../../../pawoo/actions/page';
import Announcements from '../../../pawoo/components/announcements';
import PawooWebTagLink from '../../../pawoo/components/web_tag_link';
import TrendTagsContainer from '../../../pawoo/containers/trend_tags_container';
import elephantUIPlane from '../../../pawoo/images/pawoo-ui.png';
const messages = defineMessages({
start: { id: 'getting_started.heading', defaultMessage: 'Getting started' },
home_timeline: { id: 'tabs_bar.home', defaultMessage: 'Home' },
notifications: { id: 'tabs_bar.notifications', defaultMessage: 'Notifications' },
suggested_accounts: { id: 'column.suggested_accounts', defaultMessage: 'Active Users' },
community: { id: 'navigation_bar.community_timeline', defaultMessage: 'Local timeline' },
media: { id: 'column.media_timeline', defaultMessage: 'Media timeline' },
help: { id: 'navigation_bar.help', defaultMessage: 'Help' },
});
const mapStateToProps = (state, ownProps) => ({
columns: state.getIn(['settings', 'columns']),
showSearch: ownProps.multiColumn ? state.getIn(['search', 'submitted']) && !state.getIn(['search', 'hidden']) : ownProps.isSearchPage,
pawooHasUnreadNotifications: state.getIn(['notifications', 'unread']) > 0,
pawooMultiColumn: state.getIn(['settings', 'pawoo', 'multiColumn']),
});
@connect(mapStateToProps)
@injectIntl
export default class Compose extends React.PureComponent {
static propTypes = {
dispatch: PropTypes.func.isRequired,
columns: ImmutablePropTypes.list.isRequired,
multiColumn: PropTypes.bool,
showSearch: PropTypes.bool,
isSearchPage: PropTypes.bool,
intl: PropTypes.object.isRequired,
pawooHasUnreadNotifications: PropTypes.bool,
pawooMultiColumn: PropTypes.bool,
};
pawooRef = null;
componentDidMount () {
const { isSearchPage } = this.props;
if (!isSearchPage) {
this.props.dispatch(mountCompose());
}
}
componentWillUnmount () {
const { isSearchPage } = this.props;
if (!isSearchPage) {
this.props.dispatch(unmountCompose());
}
}
onFocus = () => {
this.props.dispatch(changeComposing(true));
}
onBlur = () => {
this.props.dispatch(changeComposing(false));
}
pawooHandleClick = () => {
this.props.dispatch(pawooSetPage('DEFAULT'));
}
pawooHandleSubmit = () => {
if (this.pawooRef) {
this.pawooRef.classList.remove('pawoo-extension-drawer__inner__mastodon--animation');
// Trigger layout
this.pawooRef.offsetWidth; // eslint-disable-line no-unused-expressions
this.pawooRef.classList.add('pawoo-extension-drawer__inner__mastodon--animation');
}
};
pawooSetRef = c => {
this.pawooRef = c;
};
render () {
const { multiColumn, showSearch, isSearchPage, intl } = this.props;
let header = '';
if (multiColumn) {
const { columns, pawooHasUnreadNotifications } = this.props;
header = (
<nav className='drawer__header'>
<Link to='/getting-started' className='drawer__tab' onClick={this.pawooHandleClick} title={intl.formatMessage(messages.start)} aria-label={intl.formatMessage(messages.start)}><i role='img' className='fa fa-fw fa-asterisk' /></Link>
{!columns.some(column => column.get('id') === 'HOME') && (
<Link to='/timelines/home' className='drawer__tab' onClick={this.pawooHandleClick} title={intl.formatMessage(messages.home_timeline)} aria-label={intl.formatMessage(messages.home_timeline)}><i role='img' className='fa fa-fw fa-home' /></Link>
)}
{!columns.some(column => column.get('id') === 'NOTIFICATIONS') && (
<Link to='/notifications' className={classNames('drawer__tab', { 'pawoo-extension-drawer__tab--unread': pawooHasUnreadNotifications })} onClick={this.pawooHandleClick} title={intl.formatMessage(messages.notifications)} aria-label={intl.formatMessage(messages.notifications)}><i role='img' className='fa fa-fw fa-bell' /></Link>
)}
{!columns.some(column => column.get('id') === 'COMMUNITY') && (
<Link to='/timelines/public/local' className='drawer__tab' onClick={this.pawooHandleClick} title={intl.formatMessage(messages.community)} aria-label={intl.formatMessage(messages.community)}><i role='img' className='fa fa-fw fa-users' /></Link>
)}
{!columns.some(column => column.get('id') === 'MEDIA') && columns.some(column => ['HOME', 'NOTIFICATIONS', 'COMMUNITY'].includes(column.get('id'))) && (
<Link to='/timelines/public/media' className='drawer__tab' onClick={this.pawooHandleClick} title={intl.formatMessage(messages.media)} aria-label={intl.formatMessage(messages.media)}><i role='img' className='fa fa-fw fa-image' /></Link>
)}
<Link to='/suggested_accounts' className='drawer__tab' onClick={this.pawooHandleClick} title={intl.formatMessage(messages.suggested_accounts)} aria-label={intl.formatMessage(messages.suggested_accounts)}><i role='img' className='fa fa-fw fa-user-plus' /></Link>
<a href='https://pawoo.pixiv.help' target='_blank' rel='noopener' className='drawer__tab' title={intl.formatMessage(messages.help)} aria-label={intl.formatMessage(messages.help)}><i role='img' className='fa fa-fw fa-question-circle' /></a>
</nav>
);
}
return (
<div className='drawer'>
{header}
{(multiColumn || isSearchPage) && <SearchContainer /> }
<div className='drawer__pager'>
<div className='drawer__inner' onFocus={this.onFocus}>
<NavigationContainer onClose={this.onBlur} />
<ComposeFormContainer pawooOnSubmit={this.pawooHandleSubmit} />
{(!multiColumn || this.props.pawooMultiColumn) && (
<React.Fragment>
<div style={{ marginBottom: '10px' }}><Announcements /></div>
<div className='drawer__block'>
<TrendTagsContainer Tag={PawooWebTagLink} />
</div>
</React.Fragment>
)}
{multiColumn && (
<div className='pawoo-extension-drawer__inner__mastodon drawer__inner__mastodon'>
<img alt='' draggable='false' ref={this.pawooSetRef} src={elephantUIPlane} />
</div>
)}
</div>
<Motion defaultStyle={{ x: isSearchPage ? 0 : -100 }} style={{ x: spring(showSearch || isSearchPage ? 0 : -100, { stiffness: 210, damping: 20 }) }}>
{({ x }) => (
<div className='drawer__inner darker' style={{ transform: `translateX(${x}%)`, visibility: x === -100 ? 'hidden' : 'visible' }}>
<SearchResultsContainer />
</div>
)}
</Motion>
</div>
</div>
);
}
}
|
mobile/mock ups/manager/src/components/common/Button.js | parammehta/TravLendar | import React from 'react';
import { Text, TouchableOpacity } from 'react-native';
const Button = ({ onPress, children }) => {
const { buttonStyle, textStyle } = styles;
return (
<TouchableOpacity onPress={onPress} style={buttonStyle} >
<Text style={textStyle}> {children} </Text>
</TouchableOpacity>
);
};
const styles = {
buttonStyle: {
flex: 1,
alignSelf: 'center',
backgroundColor: '#fff',
borderRadius: 5,
borderWidth: 1,
borderColor: '#007aff',
marginLeft: 5,
marginRight: 5
},
textStyle: {
alignSelf: 'center',
color: '#007aff',
fontSize: 16,
fontWeight: '600',
paddingTop: 10,
paddingBottom: 10
}
};
export { Button };
|
src/svg-icons/image/looks.js | ruifortes/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let ImageLooks = (props) => (
<SvgIcon {...props}>
<path d="M12 10c-3.86 0-7 3.14-7 7h2c0-2.76 2.24-5 5-5s5 2.24 5 5h2c0-3.86-3.14-7-7-7zm0-4C5.93 6 1 10.93 1 17h2c0-4.96 4.04-9 9-9s9 4.04 9 9h2c0-6.07-4.93-11-11-11z"/>
</SvgIcon>
);
ImageLooks = pure(ImageLooks);
ImageLooks.displayName = 'ImageLooks';
ImageLooks.muiName = 'SvgIcon';
export default ImageLooks;
|
src/components/portfolio.js | erik-sn/mslt | if (process.env.BROWSER) {
require('../sass/portfolio.scss');
}
import React, { Component } from 'react';
import { Card, CardHeader } from 'material-ui/Card';
import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider';
export default class Admin extends Component {
constructor(props) {
super(props);
this.state = {
};
this.headerStyle = {
flex: '1 1 auto',
};
}
render() {
return (
<div id="portfolio-container" >
<div className="portfolio-item" >
<MuiThemeProvider>
<Card>
<div className="portfolio-header">
<div className="portfolio-header-name"><a href="https://devreduce.com/formcontrol/"><h2>FormControl</h2></a></div>
<div className="portfolio-code">
<a href="https://github.com/erik-sn/formcontrol/">
<img src="https://simpleicons.org/icons/github.svg" />
</a>
</div>
</div>
<div className="portfolio-body">
<div className="portfolio-img">
<Card><img src="/resources/img/formcontrol.png" /></Card>
</div>
<div className="portfolio-text">
<div className="portfolio-description">
Form Control is an application that lets users design, implement, share, and
implement custom data entry applications. data input, storage, and analysis.
</div>
<div className="portfolio-technology">
<h4>Technologies Used:</h4>
React, Redux, TypeScript, Django
</div>
</div>
</div>
</Card>
</MuiThemeProvider>
</div>
<div className="portfolio-item img-right" >
<MuiThemeProvider>
<Card>
<div className="portfolio-header">
<div className="portfolio-header-name"><a href="https://devreduce.com/repljs/"><h2>repljs</h2></a></div>
<div className="portfolio-code">
<a href="https://github.com/erik-sn/repljs/">
<img src="https://simpleicons.org/icons/github.svg" />
</a>
</div>
</div>
<div className="portfolio-body">
<div className="portfolio-text">
<div className="portfolio-description">
repljs is an in-browser JavaScript REPL (Read Eval Print Loop) application that supports
multiple JavaScript transpilers (Babel, CoffeeScript, TypeScript). It also incrementally
stores code as it is typed - which can be saved, downloaded and shared. This allows not just
code to be stored, but the history of how it was written.
</div>
<div className="portfolio-technology">
<h4>Technologies Used:</h4>
React, Redux, Django
</div>
</div>
<div className="portfolio-img">
<Card><img src="/resources/img/repljs.png" /></Card>
</div>
</div>
</Card>
</MuiThemeProvider>
</div>
<div className="portfolio-item" >
<MuiThemeProvider>
<Card>
<div className="portfolio-header">
<div className="portfolio-header-name"><a href="https://devreduce.com/markdown/"><h2>Markdown</h2></a></div>
<div className="portfolio-code">
<a href="https://github.com/erik-sn/react-markdown/">
<img src="https://simpleicons.org/icons/github.svg" />
</a>
</div>
</div>
<div className="portfolio-body">
<div className="portfolio-img">
<Card><img src="/resources/img/markdown.png" /></Card>
</div>
<div className="portfolio-text">
<div className="portfolio-description">
Type in text and have it be converted to Github styles. If logged in through
Github you can save and retrieve markdowns to continue working on them. Built for FreeCodeCamp.
</div>
<div className="portfolio-technology">
<h4>Technologies Used:</h4>
React, Django
</div>
</div>
</div>
</Card>
</MuiThemeProvider>
</div>
<div className="portfolio-item img-right" >
<MuiThemeProvider>
<Card>
<div className="portfolio-header">
<div className="portfolio-header-name"><a href="https://devreduce.com/simon/"><h2>Simon</h2></a></div>
<div className="portfolio-code">
<a href="https://github.com/erik-sn/react-simon/">
<img src="https://simpleicons.org/icons/github.svg" />
</a>
</div>
</div>
<div className="portfolio-body">
<div className="portfolio-text">
<div className="portfolio-description">
Recreation of the 80's simon says game where the player must match the colors the game
produces. Built for FreeCodeCamp.
</div>
<div className="portfolio-technology">
<h4>Technologies Used:</h4>
React
</div>
</div>
<div className="portfolio-img">
<Card><img src="/resources/img/simon.png" /></Card>
</div>
</div>
</Card>
</MuiThemeProvider>
</div>
<div className="portfolio-item" >
<MuiThemeProvider>
<Card>
<div className="portfolio-header">
<div className="portfolio-header-name"><a href="https://devreduce.com/tictactoe/"><h2>Tic-Tac-Toe</h2></a></div>
<div className="portfolio-code">
<a href="https://github.com/erik-sn/react-tictactoe/">
<img src="https://simpleicons.org/icons/github.svg" />
</a>
</div>
</div>
<div className="portfolio-body">
<div className="portfolio-img">
<Card><img src="/resources/img/tictactoe.png" /></Card>
</div>
<div className="portfolio-text">
<div className="portfolio-description">
Classic Tic-Tac-Toe game. It features an "unbeatable" AI which will draw or win every match, implemented using
the <a href="https://en.wikipedia.org/wiki/Minimax">minimax algorithm</a>.
</div>
<div className="portfolio-technology">
<h4>Technologies Used:</h4>
React
</div>
</div>
</div>
</Card>
</MuiThemeProvider>
</div>
<div className="portfolio-item img-right" >
<MuiThemeProvider>
<Card>
<div className="portfolio-header">
<div className="portfolio-header-name"><a href="https://devreduce.com/pomodoro/"><h2>Pomodoro</h2></a></div>
<div className="portfolio-code">
<a href="https://github.com/erik-sn/react-pomodoro/">
<img src="https://simpleicons.org/icons/github.svg" />
</a>
</div>
</div>
<div className="portfolio-body">
<div className="portfolio-text">
<div className="portfolio-description">
A <a href="https://en.wikipedia.org/wiki/Time_management#Pomodoro">time management</a> application that cycles
between working and breaks. The clock timers and face can be adjusted. Built for FreeCodeCamp.
</div>
<div className="portfolio-technology">
<h4>Technologies Used:</h4>
React
</div>
</div>
<div className="portfolio-img">
<Card><img src="/resources/img/pomodoro.png" /></Card>
</div>
</div>
</Card>
</MuiThemeProvider>
</div>
<div className="portfolio-item" >
<MuiThemeProvider>
<Card>
<div className="portfolio-header">
<div className="portfolio-header-name"><a href="https://devreduce.com/calculator/"><h2>React Calc</h2></a></div>
<div className="portfolio-code">
<a href="https://github.com/erik-sn/react-calc/">
<img src="https://simpleicons.org/icons/github.svg" />
</a>
</div>
</div>
<div className="portfolio-body">
<div className="portfolio-img">
<Card><img src="/resources/img/calc.png" /></Card>
</div>
<div className="portfolio-text">
<div className="portfolio-description">A simple implementation of a calculator
built in JavaScript using React.JS. Use either your mouse or keyboard to run basic evaluations.
</div>
<div className="portfolio-technology">
<h4>Technologies Used:</h4>
React
</div>
</div>
</div>
</Card>
</MuiThemeProvider>
</div>
<div className="portfolio-item img-right" >
<MuiThemeProvider>
<Card>
<div className="portfolio-header">
<div className="portfolio-header-name"><a href="https://codepen.io/erik-sn/full/QNZbJB"><h2>Local Weather</h2></a></div>
<div className="portfolio-code">
<a href="https://codepen.io/erik-sn/pen/QNZbJB">
<img src="https://simpleicons.org/icons/codepen.svg" />
</a>
</div>
</div>
<div className="portfolio-body">
<div className="portfolio-text">
<div className="portfolio-description">
Retrieves your current local weather and hourly forecast and displays it on an environment.
</div>
<div className="portfolio-technology">
<h4>Technologies Used:</h4>
jQuery
</div>
</div>
<div className="portfolio-img">
<Card><img src="/resources/img/weather.png" /></Card>
</div>
</div>
</Card>
</MuiThemeProvider>
</div>
<div className="portfolio-item" >
<MuiThemeProvider>
<Card>
<div className="portfolio-header">
<div className="portfolio-header-name"><a href="https://codepen.io/erik-sn/full/OXmKvw"><h2>Wikipedia Viewer</h2></a></div>
<div className="portfolio-code">
<a href="https://codepen.io/erik-sn/pen/OXmKvw">
<img src="https://simpleicons.org/icons/codepen.svg" />
</a>
</div>
</div>
<div className="portfolio-body">
<div className="portfolio-text">
<div className="portfolio-description">
Allows you to search for wikipedia pages or request a random page, displays some
initial information about the topic, and then keeps track of which pages you have looked.
Built for FreeCodeCamp.
</div>
<div className="portfolio-technology">
<h4>Technologies Used:</h4>
jQuery
</div>
</div>
</div>
</Card>
</MuiThemeProvider>
</div>
<div className="portfolio-item" >
<MuiThemeProvider>
<Card>
<div className="portfolio-header">
<div className="portfolio-header-name"><a href="http://codepen.io/erik-sn/full/oxPqWe"><h2>Random Quote Generator</h2></a></div>
<div className="portfolio-code">
<a href="https://codepen.io/erik-sn/pen/oxPqWe">
<img src="https://simpleicons.org/icons/codepen.svg" />
</a>
</div>
</div>
<div className="portfolio-body">
<div className="portfolio-text">
<div className="portfolio-description">
Retrieves random quotes from designers and searches google for their picture, then displays both
</div>
<div className="portfolio-technology">
<h4>Technologies Used:</h4>
jQuery
</div>
</div>
</div>
</Card>
</MuiThemeProvider>
</div>
</div>
);
}
} |
client/components/Wishlist.js | jimini-js/jimini | import React from 'react';
import Item from './Item.js';
import $ from 'jquery';
import { DropdownButton } from 'react-bootstrap';
import { MenuItem } from 'react-bootstrap';
class Wishlist extends React.Component {
constructor(){
super()
this.removeWish = this.removeWish.bind(this);
this.markAsBought = this.markAsBought.bind(this);
this.showPurchased = this.showPurchased.bind(this);
this.showUnpurchased = this.showUnpurchased.bind(this);
this.showAll = this.showAll.bind(this);
this.state = {
wishlist: [],
show: 'All'
}
}
componentWillReceiveProps(nextProps){
this.setState({
wishlist: nextProps.wishlist
});
}
removeWish(wishId){
let self = this;
$.ajax({
url: '/wish',
type: 'DELETE',
contentType: 'application/json',
data: JSON.stringify({
id: wishId
}),
success: function(data){
self.props.updateWishlist('delete', wishId);
},
error: function(err){
console.log('deletion error', err);
}
});
}
markAsBought(wishId,name,message){
let newWishList = [];
this.state.wishlist.forEach(wish => {
if (wish._id !== wishId) {
newWishList.push(wish);
}
});
this.setState({
wishlist: newWishList
});
$.ajax({
url: '/buy',
type: 'PUT',
contentType: 'application/json',
data: JSON.stringify({
id: wishId,
buyername: name,
message: message
}),
success: function(data){
},
error: function(err){
console.log('buying error', err);
}
});
}
showPurchased(e){
e.preventDefault();
this.setState({show:'Purchased'});
}
showUnpurchased(e){
e.preventDefault();
this.setState({show:'Not Purchased'});
}
showAll(e){
e.preventDefault();
this.setState({show:'All'});
}
render(){
let items = [];
let title;
let dropdown = this.props.isLoggedIn?(
<DropdownButton title={this.state.show} id='purchasedDropdown'>
<MenuItem onClick={this.showAll}>All</MenuItem>
<MenuItem onClick={this.showPurchased}>Purchased</MenuItem>
<MenuItem onClick={this.showUnpurchased}>Not Purchased</MenuItem>
</DropdownButton>
):null;
if (this.props.isLoggedIn) {
if (this.state.show==='All') {
items = this.state.wishlist;
}
else if (this.state.show==='Purchased') {
items = this.state.wishlist.filter(function(item){
return (item.purchased)
});
}
else if (this.state.show==='Not Purchased') {
items = this.state.wishlist.filter(function(item){
return (!item.purchased);
});
}
items = items.map((item, ind) => {
return (
<Item
buyername={item.buyername}
message={item.message}
itemname={item.wishname}
category={item.category}
description={item.description}
url={item.link}
id={item._id}
key={ind}
removeWish={this.removeWish}
markAsBought={this.markAsBought}
isLoggedIn={this.props.isLoggedIn}
isPurchased={item.purchased} />
)
});
this.props.isLoggedIn ? title = (<h3>Wishlist</h3>) : null;
} else {
this.state.wishlist.forEach((item, ind) => {
if(!item.purchased){
items.push(
<Item
itemname={item.wishname}
category={item.category}
description={item.description}
url={item.link}
id={item._id}
key={ind}
removeWish={this.removeWish}
markAsBought={this.markAsBought}
isLoggedIn={this.props.isLoggedIn}
isPurchased={item.purchased}
giftIcon={this.props.giftIcon} />
);
}
});
}
return(
<div className="wishlist">
{title}
<div className="filter">
{dropdown}
</div>
<div className="row">
{items}
</div>
</div>
)
}
}
export default Wishlist;
|
app/shared/feedback-link/FeedbackLink.js | fastmonkeys/respa-ui | import React from 'react';
import PropTypes from 'prop-types';
import constants from '../../constants/AppConstants';
import { getCurrentCustomization } from '../../utils/customizationUtils';
function FeedbackLink({ children }) {
const refUrl = window.location.href;
const href = `${constants.FEEDBACK_URL}&ref=${refUrl}`;
switch (getCurrentCustomization()) {
case 'ESPOO': {
return <a className="feedback-link" href={href}>{children}</a>;
}
default: {
return <a className="feedback-link" href={href}>{children}</a>;
}
}
}
FeedbackLink.propTypes = {
children: PropTypes.node.isRequired,
};
export default FeedbackLink;
|
src/components/ui/FormInput.js | banovotz/WatchBug2 | /**
* Text Input
*
<FormInput></FormInput>
*
* React Native Starter App
* https://github.com/mcnamee/react-native-starter-app
*/
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { FormInput } from 'react-native-elements';
// Consts and Libs
import { AppColors, AppFonts } from '@theme/';
/* Component ==================================================================== */
class CustomFormInput extends Component {
static propTypes = {
containerStyle: PropTypes.oneOfType([
PropTypes.array,
PropTypes.shape({}),
]),
inputStyle: PropTypes.oneOfType([
PropTypes.array,
PropTypes.shape({}),
]),
}
static defaultProps = {
containerStyle: [],
inputStyle: [],
}
inputProps = () => {
// Defaults
const props = {
...this.props,
containerStyle: [{
borderBottomColor: AppColors.border,
borderBottomWidth: 1,
backgroundColor: 'rgba(255,255,255,0.05)',
marginTop: 10,
marginLeft: 0,
marginRight: 0,
}],
inputStyle: [{
color: AppColors.textPrimary,
fontFamily: AppFonts.base.family,
paddingHorizontal: 0,
paddingVertical: 3,
}],
};
if (this.props.containerStyle) {
props.containerStyle.push(this.props.containerStyle);
}
if (this.props.inputStyle) {
props.inputStyle.push(this.props.inputStyle);
}
return props;
}
render = () => <FormInput {...this.inputProps()} />
}
/* Export Component ==================================================================== */
export default CustomFormInput;
|
src/features/feed/feed-list/feed-list.component.js | sunstorymvp/playground | import React from 'react';
import classNames from 'classnames';
import styles from './feed-list.css';
import FeedListItem from '../feed-list-item';
const renderFeedListItems = () => (
[ 1, 2, 3 ].map((feedListItem) => (
<FeedListItem key={ feedListItem } />
))
);
const FeedList = () => {
const classList = classNames(styles.root);
return (
<div className={ classList }>
{ renderFeedListItems() }
</div>
);
};
export default FeedList;
|
src/components/ReportFormPayment/index.js | bruceli1986/contract-react | import React from 'react'
/** 打印报表合同支付对应表单*/
class ReportFormPayment extends React.Component {
static propTypes = {
businessId: React.PropTypes.string,
opinions: React.PropTypes.array,
loaded: React.PropTypes.bool,
onClickCancel: React.PropTypes.func,
onReport: React.PropTypes.func
}
constructor (props, context) {
super(props, context)
this.state = {
step: 0,
reportCode: [],
validStatus: false,
pReportCode: ''
}
}
componentDidUpdate (prevProps, prevState) {
$(this.refs.form).find('.selectpicker').selectpicker({
showContent: true,
width: '100%'
// noneSelectedText:'<span class='opinion-not-insert'>[未填处理意见]<span>'
})
}
componentDidMount () {
this.fetchReportCode()
}
vaildateForm () {
this.setState({validStatus: true})
return (this.state.pReportCode !== '')
}
// 提交打印请求
submitForm = () => {
var component = this
if (this.vaildateForm()) {
this.props.onReport()
$.ajax({
cache: true,
type: this.refs.form.method,
url: this.refs.form.action,
data: $(this.refs.form).serialize(),
async: true,
success: function (result) {
component.props.onClickCancel()
window.open(result)
}
})
}
}
getActivityList () {
var s = []
var result = []
var component = this
this.props.opinions.forEach(function (x) {
if (s.indexOf(x.activityId) < 0) {
s.push(x.activityId)
}
})
s.forEach(function (x) {
result.push(component.props.opinions.filter(function (y) {
return y.activityId === x
}))
})
return result
}
reportCodeErrorMsg () {
if (this.state.validStatus === true) {
if (this.state.pReportCode === '') {
return '报表输出样式必填'
}
}
}
fetchReportCode () {
this.serverRequest = $.post('/qdp/qdp/permisstion/queryMap.do?' +
'strategyId=5&CONTEXT_code=TGPMSREPORTCODE&CONTEXT_notEqualCode=null', function (result) {
this.setState({
reportCode: [{CODE: null, DESCRIPTION: null}].concat(result.rows)
})
}.bind(this), 'json')
}
setReportCode = (e) => {
this.setState({pReportCode: e.target.value})
}
addStep = (e) => {
if (this.state.step < 1) {
this.setState({
step: this.state.step + 1
})
}
}
minusStep = (e) => {
if (this.state.step > 0) {
this.setState({
step: this.state.step - 1
})
}
}
render () {
return (
<form ref='form' action='/qdp/payment/report/payment' method='post'>
<input name='businessId' type='hidden' value={this.props.businessId} />
<div className={this.state.step === 0 ? 'container-fluid' : 'container-fluid hide'}>
<table className='table'>
<thead>
<tr>
<th style={{width: '30%'}}>环节</th>
<th style={{width: '70%'}}>处理意见</th>
</tr>
</thead>
<tbody className={this.props.loaded ? '' : 'hidden'}>
{
this.getActivityList().map(function (x, index) {
return (
<tr key={index}>
<td>{x[0].activityName}</td>
<td>
<select className='selectpicker' name={x[0].reportParameter}
style={{maxWidth: '500px', width: '100%'}}>
{
x.map(function (op, i) {
return (
<option key={i} value={op.opinion + '||' + op.name + '||' + op.processtime}
data-subtext={op.processtime + ' by ' + op.name}>
{op.opinion ? op.opinion : '——'}
</option>
)
})
}
</select>
</td>
</tr>
)
})
}
</tbody>
</table>
<div style={{height: '100px'}} className={this.props.loaded ? 'hidden' : 'payment-mask'} />
<div className='form-group'>
<label className='control-label'>是否打印处理时间:</label>
<label className='radio-inline'>
<input type='radio' name='p_prtTimeFlg' defaultValue='true' defaultChecked />是
</label>
<label className='radio-inline'>
<input type='radio' name='p_prtTimeFlg' defaultValue='false' />否
</label>
</div>
</div>
<div className={this.state.step === 1 ? 'container-fluid' : 'container-fluid hide'}>
<div className='form-group'>
<label className='control-label'>单位:</label>
<select className='form-control' name='precision' defaultValue='1'>
<option value='1'>1</option>
<option value='10'>10</option>
<option value='100'>100</option>
<option value='1000'>1000</option>
<option value='10000'>10,000</option>
</select>
</div>
<div className='form-group'>
<label className='control-label'>币种:</label>
<select className='form-control' name='p_currency' defaultValue='RMB'>
<option value='RMB' >人民币</option>
<option value='USD'>美元</option>
</select>
</div>
<div className='form-group'>
<label className='control-label'>是否多个承包商:</label>
<label className='radio-inline'>
<input type='radio' name='p_multi_vendor' defaultValue='Y' defaultChecked />是
</label>
<label className='radio-inline'>
<input type='radio' name='p_multi_vendor' defaultValue='N' />否
</label>
</div>
<div className='form-group'>
<label className='control-label'>
报表输出样式:<label className='error' style={{marginLeft: '2em'}}>{this.reportCodeErrorMsg()}</label>
</label>
<select className='form-control' name='reportCode' onClick={this.setReportCode}>
{
this.state.reportCode.map(function (x, i) {
return (<option key={i} value={x.CODE} >{x.DESCRIPTION}</option>)
})
}
</select>
</div>
</div>
<div className='row' style={{marginTop: '10px'}}>
<div className={this.state.step === 1 ? 'hide col-md-6' : 'col-md-6'}>
<button type='button' onClick={this.addStep}
className='btn btn-default payment-button btn_payment_next'>下一步</button>
</div>
<div className={this.state.step === 0 ? 'hide col-md-4' : 'col-md-4'}>
<button type='button' onClick={this.minusStep}
className='btn btn-default payment-button btn_payment_prev'>上一步</button>
</div>
<div className={this.state.step === 0 ? 'hide col-md-4' : 'col-md-4'}>
<button type='button' className='btn btn-default payment-button btn_payment_print'
onClick={this.submitForm}>打印</button>
</div>
<div className={this.state.step === 0 ? 'col-md-6' : 'col-md-4'}>
<button type='button' className='btn btn-default payment-button btn_payment_cancel'
onClick={this.props.onClickCancel}>取消</button>
</div>
</div>
</form>
)
}
}
export default ReportFormPayment
|
src/svg-icons/action/perm-media.js | ichiohta/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let ActionPermMedia = (props) => (
<SvgIcon {...props}>
<path d="M2 6H0v5h.01L0 20c0 1.1.9 2 2 2h18v-2H2V6zm20-2h-8l-2-2H6c-1.1 0-1.99.9-1.99 2L4 16c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zM7 15l4.5-6 3.5 4.51 2.5-3.01L21 15H7z"/>
</SvgIcon>
);
ActionPermMedia = pure(ActionPermMedia);
ActionPermMedia.displayName = 'ActionPermMedia';
ActionPermMedia.muiName = 'SvgIcon';
export default ActionPermMedia;
|
src/modules/history/HistoryDetail.js | dominictracey/hangboard | import React from 'react'
import PropTypes from 'prop-types'
import {View, ScrollView, StyleSheet, TouchableOpacity} from 'react-native'
import AppText from '../../components/AppText'
import {Card} from 'react-native-elements'
import {Icon} from 'react-native-vector-icons/MaterialIcons'
import HistoryDetailsGrid from '../../components/HistoryDetailsGrid'
import {K} from '../../utils/constants'
class HistoryDetail extends React.Component {
static navigationOptions =
({navigation}) => ({
tabBarKey: navigation.state,
tabBarlabel: 'History Details',
tabBarIcon: (props) => (<Icon name='history' size={24} color={props.tintColor} />
),
headerTintColor: 'white',
headerStyle: {
backgroundColor: '#39babd'
}
});
static propTypes = {
navigation: PropTypes.object.isRequired,
}
delete = () => {
const {deleteCb, index} = this.props.navigation.state.params
deleteCb(index)
}
// so it seems like using the react-navigation parameter to pass in an
// immutable Map converts it to a POJS object. So use item[key] rather than item.get(key)
render() {
const {params} = this.props.navigation.state
const item = params.item
const deleteButton = params.index !== 0
? (
// <View style={styles.top}>
<TouchableOpacity
style={styles.deleteButton}
accessible={true}
accessibilityLabel={'Delete Workout'}
onPress={this.delete}>
<AppText size='lg' theme='dark' flex='0'>
Delete Workout
</AppText>
</TouchableOpacity>
)
// </View>)
: null
return (
<ScrollView>
<Card title={item[K.HISTORY_LABEL]}>
{/* <View style={styles.top}>
<AppText size='lg'>{item[K.HISTORY_LABEL]}</AppText>
</View> */}
<View style={styles.top}>
<AppText size='lg'>Board:</AppText>
<AppText size='sm'>{item[K.BOARD_LABEL]}</AppText>
</View>
<View style={styles.top}>
<AppText size='lg'>Program:</AppText>
<AppText size='sm'>{item[K.PROGRAM_LABEL]}</AppText>
</View>
</Card>
<Card title='Completed Sets'>
<HistoryDetailsGrid history={item} style={styles.grid}/>
</Card>
<Card>
{deleteButton}
</Card>
</ScrollView>
)
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: 'white',
},
top: {
flex: 1,
flexDirection: 'row',
justifyContent: 'center',
alignItems: 'center',
},
bottom: {
flex: 4,
flexDirection: 'row',
justifyContent: 'center',
alignItems: 'center',
},
grid: {
flex: 5,
flexDirection: 'row',
},
deleteButton: {
flex: 1,
flexDirection: 'row',
justifyContent: 'center',
alignItems: 'center',
backgroundColor: 'red',
borderWidth: 0,
borderRadius: 10,
padding: 10,
shadowOffset: {width: 5, height: 5},
shadowRadius: 5,
shadowOpacity: 50,
elevation: .5,
marginLeft: 50,
marginRight: 50,
marginTop: 20,
shadowColor: '#888888',
margin: 20
}
})
export default HistoryDetail
|
src/svg-icons/social/cake.js | ruifortes/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let SocialCake = (props) => (
<SvgIcon {...props}>
<path d="M12 6c1.11 0 2-.9 2-2 0-.38-.1-.73-.29-1.03L12 0l-1.71 2.97c-.19.3-.29.65-.29 1.03 0 1.1.9 2 2 2zm4.6 9.99l-1.07-1.07-1.08 1.07c-1.3 1.3-3.58 1.31-4.89 0l-1.07-1.07-1.09 1.07C6.75 16.64 5.88 17 4.96 17c-.73 0-1.4-.23-1.96-.61V21c0 .55.45 1 1 1h16c.55 0 1-.45 1-1v-4.61c-.56.38-1.23.61-1.96.61-.92 0-1.79-.36-2.44-1.01zM18 9h-5V7h-2v2H6c-1.66 0-3 1.34-3 3v1.54c0 1.08.88 1.96 1.96 1.96.52 0 1.02-.2 1.38-.57l2.14-2.13 2.13 2.13c.74.74 2.03.74 2.77 0l2.14-2.13 2.13 2.13c.37.37.86.57 1.38.57 1.08 0 1.96-.88 1.96-1.96V12C21 10.34 19.66 9 18 9z"/>
</SvgIcon>
);
SocialCake = pure(SocialCake);
SocialCake.displayName = 'SocialCake';
SocialCake.muiName = 'SvgIcon';
export default SocialCake;
|
src/components/molecules/IconButton/index.stories.js | SIB-Colombia/dataportal_v2_frontend | import React from 'react'
import { storiesOf } from '@kadira/storybook'
import { IconButton } from 'components'
storiesOf('IconButton', module)
.add('default', () => (
<IconButton icon="close">Hello</IconButton>
))
.add('transparent', () => (
<IconButton icon="close" transparent>Hello</IconButton>
))
.add('with icon on right', () => (
<IconButton icon="close" right>Hello</IconButton>
))
.add('responsive', () => (
<IconButton icon="close" responsive>Decrease panel width</IconButton>
))
.add('responsive with breakpoint', () => (
<IconButton icon="close" breakpoint={300} responsive>Decrease panel width to 300</IconButton>
))
.add('without text', () => (
<IconButton icon="close" />
))
.add('collapsed', () => (
<IconButton icon="close" collapsed>Hello</IconButton>
))
.add('height', () => (
<IconButton icon="close" height={100}>Hello</IconButton>
))
|
src/app.js | qmmr/react-movies | import React from 'react'
import App from './components/App.jsx'
import createActionCreators from './actions/createActionCreators'
import getFirebaseService from './services/firebaseService'
import getOMDBService from './services/omdbService'
import AppDispatcher from './dispatcher/AppDispatcher'
import MoviesStore from './stores/MoviesStore'
var appDispatcher = new AppDispatcher()
var actions = createActionCreators(appDispatcher)
var firebaseService = getFirebaseService(actions)
var omdbService = getOMDBService(actions)
var moviesStore = new MoviesStore(appDispatcher, firebaseService, omdbService)
React.render(
React.withContext({ moviesStore, actions }, function() {
return React.createFactory(App)(null)
}),
document.querySelector('#container')
)
|
src/components/App.js | fvalencia/react-vimeo | /**
* React Starter Kit (https://www.reactstarterkit.com/)
*
* Copyright © 2014-present Kriasoft, LLC. All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE.txt file in the root directory of this source tree.
*/
import React from 'react';
import PropTypes from 'prop-types';
import { Provider as ReduxProvider } from 'react-redux';
const ContextType = {
// Enables critical path CSS rendering
// https://github.com/kriasoft/isomorphic-style-loader
insertCss: PropTypes.func.isRequired,
// Universal HTTP client
fetch: PropTypes.func.isRequired,
// Integrate Redux
// http://redux.js.org/docs/basics/UsageWithReact.html
...ReduxProvider.childContextTypes,
};
/**
* The top-level React component setting context (global) variables
* that can be accessed from all the child components.
*
* https://facebook.github.io/react/docs/context.html
*
* Usage example:
*
* const context = {
* history: createBrowserHistory(),
* store: createStore(),
* };
*
* ReactDOM.render(
* <App context={context}>
* <Layout>
* <LandingPage />
* </Layout>
* </App>,
* container,
* );
*/
class App extends React.PureComponent {
static propTypes = {
context: PropTypes.shape(ContextType).isRequired,
//children: PropTypes.element.isRequired,
};
static childContextTypes = ContextType;
getChildContext() {
return this.props.context;
}
render() {
// NOTE: If you need to add or modify header, footer etc. of the app,
// please do that inside the Layout component.
//return React.Children.only(this.props.children);
return React.Children.only(this.props.children);
}
}
export default App;
|
src/interface/VerticalLine.js | yajinni/WoWAnalyzer | import React from 'react';
import PropTypes from 'prop-types';
import Tooltip from 'interface/Tooltip';
import './VerticalLine.css';
const VerticalLine = props => {
const {
value,
style,
className,
children,
// ton of properties get injected from XYPlot
xRange,
xDomain,
marginLeft,
marginTop,
innerHeight,
innerWidth,
} = props;
// xDomain = [minX, maxX] - e.g. [8022559, 8222902]
// xRange = [0, maxXpixels] - e.g. [0, 1160]
// assuming linear scale, these form an equation of a line from [xDomain[0], xRange[0]] to [xDomain[1], xRange[1]]
// equation taken from Line (geometry) on Wikipedia
const pixelOffset = (x) => {
const [x0, x1] = xDomain;
const [y0, y1] = xRange;
return (x - x0) * (y1 - y0) / (x1 - x0) + y0;
};
const left = Math.round(marginLeft + pixelOffset(value));
const top = marginTop;
const orientation = left > innerWidth / 2 ? 'left' : 'right';
return (
<div
className={`rv-vertical-line ${className}`}
style={{
left: `${left}px`,
top: `${top}px`,
...style.wrapper,
}}
>
{!children && (
<div
className="rv-vertical-line__line"
style={{
height: `${innerHeight}px`,
...style.line,
}}
/>
)}
{children && (
<Tooltip
content={children}
direction={orientation}
>
<div
className="rv-vertical-line__line"
style={{
height: `${innerHeight}px`,
...style.line,
}}
/>
</Tooltip>
)}
</div>
);
};
VerticalLine.propTypes = {
value: PropTypes.number.isRequired,
style: PropTypes.shape({
wrapper: PropTypes.object,
line: PropTypes.object,
}),
className: PropTypes.string,
children: PropTypes.node,
xRange: PropTypes.array,
xDomain: PropTypes.array,
marginLeft: PropTypes.number,
marginTop: PropTypes.number,
innerHeight: PropTypes.number,
innerWidth: PropTypes.number,
};
VerticalLine.defaultProps = {
style: {},
className: '',
};
export default VerticalLine;
|
examples/src/components/Multiselect.js | realestate-com-au/react-select | import React from 'react';
import Select from 'react-select';
const FLAVOURS = [
{ label: 'Chocolate', value: 'chocolate' },
{ label: 'Vanilla', value: 'vanilla' },
{ label: 'Strawberry', value: 'strawberry' },
{ label: 'Caramel', value: 'caramel' },
{ label: 'Cookies and Cream', value: 'cookiescream' },
{ label: 'Peppermint', value: 'peppermint' },
];
const WHY_WOULD_YOU = [
{ label: 'Chocolate (are you crazy?)', value: 'chocolate', disabled: true },
].concat(FLAVOURS.slice(1));
var MultiSelectField = React.createClass({
displayName: 'MultiSelectField',
propTypes: {
label: React.PropTypes.string,
},
getInitialState () {
return {
disabled: false,
crazy: false,
options: FLAVOURS,
value: [],
};
},
handleSelectChange (value) {
console.log('You\'ve selected:', value);
this.setState({ value });
},
toggleDisabled (e) {
this.setState({ disabled: e.target.checked });
},
toggleChocolate (e) {
let crazy = e.target.checked;
this.setState({
crazy: crazy,
options: crazy ? WHY_WOULD_YOU : FLAVOURS,
});
},
render () {
return (
<div className="section">
<h3 className="section-heading">{this.props.label}</h3>
<Select multi simpleValue disabled={this.state.disabled} value={this.state.value} placeholder="Select your favourite(s)" options={this.state.options} onChange={this.handleSelectChange} />
<div className="checkbox-list">
<label className="checkbox">
<input type="checkbox" className="checkbox-control" checked={this.state.disabled} onChange={this.toggleDisabled} />
<span className="checkbox-label">Disable the control</span>
</label>
<label className="checkbox">
<input type="checkbox" className="checkbox-control" checked={this.state.crazy} onChange={this.toggleChocolate} />
<span className="checkbox-label">I don't like Chocolate (disabled the option)</span>
</label>
</div>
</div>
);
}
});
module.exports = MultiSelectField;
|
src/svg-icons/hardware/keyboard-capslock.js | mtsandeep/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let HardwareKeyboardCapslock = (props) => (
<SvgIcon {...props}>
<path d="M12 8.41L16.59 13 18 11.59l-6-6-6 6L7.41 13 12 8.41zM6 18h12v-2H6v2z"/>
</SvgIcon>
);
HardwareKeyboardCapslock = pure(HardwareKeyboardCapslock);
HardwareKeyboardCapslock.displayName = 'HardwareKeyboardCapslock';
HardwareKeyboardCapslock.muiName = 'SvgIcon';
export default HardwareKeyboardCapslock;
|
website/src/pages/index.js | giraud/reasonml-idea-plugin | import React from 'react';
import clsx from 'clsx';
import Layout from '@theme/Layout';
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
import useBaseUrl from '@docusaurus/useBaseUrl';
import styles from './styles.module.scss';
import Hero from '@theme/Hero';
const features = [
{
title: 'Language Support',
imageUrl: 'img/syntax-all.png',
placement: 'left',
description: (
<>
The Reason IDEA Plugin adds full language support for <code>OCaml</code>, <code>Reason</code>, and <code>ReScript</code>.
Language support features include <b>code formatting</b>, <b>type annotations</b>, <b>structured code views</b>, and more.
Minimal support for <b>Dune</b> and <b>JSX</b> is included as well.
</>
),
},
{
title: 'Build Tools',
imageUrl: 'img/build-tools.png',
placement: 'right',
description: (
<>
The plugin integrates with common build tools such as <b>Dune</b>, <b>Esy</b>, and <b>BuckleScript</b>.
These are useful for installing dependencies and building your project without leaving your IDE.
</>
),
},
];
function Feature({imageUrl, title, placement, description}) {
const imgUrl = useBaseUrl(imageUrl);
return (
<div className={clsx(styles.feature, {[styles.reverse]: placement === 'right'})}>
{imgUrl && (
<div>
<img className={styles.featureImage} src={imgUrl} alt={title} />
</div>
)}
<div>
<h3>{title}</h3>
<p>{description}</p>
</div>
</div>
);
}
function Home() {
const context = useDocusaurusContext();
const {siteConfig = {}} = context;
return (
<Layout
description="Description will go into a meta tag in <head />">
<Hero />
<main>
{features && features.length > 0 && (
<section className={styles.features}>
<div className="container">
<div className="row">
{features.map((props, idx) => (
<Feature key={idx} {...props} />
))}
</div>
</div>
</section>
)}
</main>
</Layout>
);
}
export default Home;
|
compare/src/components/ecosystems/Header.js | garris/BackstopJS | import React from 'react';
import styled from 'styled-components';
import { Sticky } from 'react-sticky';
import Topbar from '../organisms/Topbar';
import Toolbar from '../organisms/Toolbar';
const HeaderWrapper = styled.section`
width: 100%;
margin: 0 auto;
padding: 15px 0;
z-index: 999;
box-sizing: border-box;
position: relative;
`;
export default class Header extends React.Component {
render () {
return (
<HeaderWrapper className="header">
<Topbar />
<Sticky topOffset={72}>
{({
isSticky,
wasSticky,
style,
distanceFromTop,
distanceFromBottom,
calculatedHeight
}) => {
return <Toolbar style={style} />;
}}
</Sticky>
</HeaderWrapper>
);
}
}
|
app/components/CharacterCreate.js | lotgd/client-react-native | // @flow
'use strict';
import React, { Component } from 'react';
import {
StyleSheet,
Text,
View,
Image,
TextInput,
} from 'react-native';
import { gql, graphql } from 'react-apollo';
import { connect } from 'react-redux';
import { ApolloProvider } from 'react-apollo';
import { NavigationActions } from 'react-navigation';
import {
Cell,
Section,
TableView,
} from 'react-native-tableview-simple';
import RootView from './RootView';
import ActionTypes from '../constants/ActionTypes';
class CharacterCreate extends Component {
state: {
loading: boolean,
characterName: string,
error: ?string,
status: ?string,
}
constructor(props) {
super(props);
this.state = {
loading: false,
characterName: '',
error: null,
status: null,
};
}
onCreate = () => {
this.setState({
loading: true,
error: null,
status: "Creating character...",
});
this.props.mutate({
variables: {
input: {
userId: this.props.realm.session.user.id,
characterName: this.state.characterName,
clientMutationId: 'mutationId'
}
},
refetchQueries:[{
query: gql`
query UserQuery($id: String!) {
user(id: $id) {
characters {
id,
name,
displayName
}
}
}
`,
variables: { id: this.props.realm.session.user.id }
}]
}).then(({ data }) => {
console.log('Create character succeeded:', data);
this.props.navigation.dispatch(NavigationActions.back());
}).catch((error) => {
console.log('Error sending create character query:', error);
this.setState({
loading: false,
error: error.message,
status: null,
})
});
}
render() {
var connectError = this.state.error ? (
<Text style={styles.connectError}>
{ this.state.error }
</Text>
) : null;
return (
<RootView>
<TableView>
<Section
headerComponent={
<Text style={styles.header}>
Create a new character on {this.props.realm.name}.
</Text>
}
footerComponent={connectError}
>
<Cell
contentContainerStyle={{ alignItems: 'flex-start', height: 44 }}
cellContentView={
<TextInput
style={styles.inputBox}
onChangeText={(characterName) => this.setState({characterName: characterName})}
placeholder='Character Name'
autoCorrect={false}
autoCapitalize='none'
/>
}
/>
</Section>
<Section>
<Cell
onPress={this.onCreate}
isDisabled={this.state.loading}
cellStyle="Basic"
titleTextColor="#5291F4"
titleTextStyle={ { textAlign: 'center' } }
titleTextStyleDisabled={ { textAlign: 'center' } }
title={this.state.status ? this.state.status : 'Create Character'}
/>
</Section>
</TableView>
</RootView>
);
}
}
const createCharacterMutation = gql`
mutation createCharacterMutation($input: CreateCharacterInput!) {
createCharacter(input: $input) {
user {
id,
characters {
id,
name,
displayName
}
},
character {
id,
name,
displayName
}
}
}
`;
const WrappedCharacterCreate = connect()(graphql(createCharacterMutation)(CharacterCreate));
class CharacterCreateNavigatorShim extends Component {
static navigationOptions = ({ navigation }) => ({
title: 'Create Character',
});
render() {
return (
<ApolloProvider client={this.props.navigation.state.params.realm.apollo}>
<WrappedCharacterCreate
{...this.props}
realm={this.props.navigation.state.params.realm}
/>
</ApolloProvider>
);
}
}
module.exports = CharacterCreateNavigatorShim;
const styles = StyleSheet.create({
header: {
color: '#787878',
paddingLeft: 15,
paddingRight: 15,
paddingTop: 20,
paddingBottom: 10,
textAlign: 'center',
},
inputBox: {
height: 44,
flex: 1,
},
connectError: {
paddingLeft: 15,
paddingRight: 15,
paddingTop: 10,
textAlign: 'center',
color: 'red',
},
});
|
src/components/Gallery/GalleryItem.js | wundery/wundery-ui-react | import React from 'react';
import classnames from 'classnames';
import { Spinner } from '../Spinner';
import { Progress } from '../Progress';
import { Icon } from '../Icon';
function GalleryItem(props) {
const { addon, onClick, progress, ribbon, small, size, src, highlighted, medium } = props;
const style = { backgroundImage: `url("${src}")` };
const linkClassName = classnames('ui-gallery-item', {
'ui-gallery-item-clickable': typeof onClick === 'function',
});
const className = classnames('ui-gallery-item-wrapper', {
'ui-gallery-item-wrapper-size-small': small,
'ui-gallery-item-highlighted': highlighted,
'ui-gallery-item-wrapper-size-medium': medium
});
return (
<div className={className}>
{ribbon && <div className="ui-gallery-item-ribbon">{ribbon}</div>}
{!src && (
<div className="ui-gallery-item-src-missing">
<Icon name="ban" large />
</div>
)}
{src && (
<div className={linkClassName} onClick={onClick}>
<div className="ui-gallery-item-src-loading">
<Spinner />
</div>
<div className={classnames('ui-gallery-item-src')} style={style} />
{progress && (
<div className="ui-gallery-item-progress">
<Progress progress={progress} small showValue={false} />
</div>
)}
</div>
)}
{src && addon && <div className="ui-gallery-item-addon">{addon}</div>}
</div>
);
}
GalleryItem.propTypes = {
// The image src. Can be either a base64 encoded string or an URL
src: React.PropTypes.string,
// Specifies whether the images should appear small
small: React.PropTypes.bool,
// Specifies whether the images should appear medium
medium: React.PropTypes.bool,
// Specifies the click action on the image
onClick: React.PropTypes.func,
// If a progress is given, a progress bar component will be rendered
// on top of the image (useful for uploader scenarios).
progress: React.PropTypes.number,
// An addon is rendered below the image, could contain actions
addon: React.PropTypes.node,
// A ribbon can be put on top of the item
ribbon: React.PropTypes.oneOfType([
React.PropTypes.string,
React.PropTypes.bool,
]),
// Specifies whether the item is highlighted, e.g. has a special border color
highlighted: React.PropTypes.bool,
};
GalleryItem.defaultProps = {
addon: null,
highlighted: false,
onClick: null,
progress: null,
ribbon: null,
small: false,
medium: false,
src: null,
};
export default GalleryItem;
|
src/public/js/components/Checkout/index.js | Natinux/ironsource-test | import React from 'react';
import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
import Checkout from './presenter';
import {saveUser} from '../../actions';
const mapDispatchToProps = dispatch => ({
saveUser: bindActionCreators(saveUser, dispatch)
});
export default connect(null, mapDispatchToProps)(Checkout); |
src/components/icons/HourGlassIcon.js | InsideSalesOfficial/insidesales-components | import React from 'react';
import { colors, generateFillFromProps } from '../styles/colors.js';
const HourGlassIcon = props => (
<svg {...props.size || { width: '15px', height: '25px' }} {...props} viewBox="0 0 15 25">
{props.title && <title>{props.title}</title>}
<g stroke="none" strokeWidth="1" fill="none" fillRule="evenodd">
<g transform="translate(-74.000000, -559.000000)">
<g transform="translate(40.000000, 199.000000)">
<g transform="translate(28.000000, 358.000000)">
<path {...generateFillFromProps(props, colors.tron)} d="M6,2 L6,8 L6.01,8 L6,8.01 L10,12 L6,16 L6.01,16.01 L6,16.01 L6,22 L18,22 L18,16.01 L17.99,16.01 L18,16 L14,12 L18,8.01 L17.99,8 L18,8 L18,2 L6,2 Z M16,16.5 L16,20 L8,20 L8,16.5 L12,12.5 L16,16.5 Z M12,11.5 L8,7.5 L8,4 L16,4 L16,7.5 L12,11.5 Z" fillRule="nonzero"></path>
<polygon points="0 0 24 0 24 24 0 24"></polygon>
</g>
</g>
</g>
</g>
</svg>
);
export default HourGlassIcon;
|
src/step-24/StoreSetup.js | gufsky/react-native-workshop | import React, { Component } from 'react'
import Highlight from 'react-syntax-highlight'
// import Note from '../Note'
import structurePng from './Structure.png'
const indexJs = `import React from 'react'
import { AppRegistry } from 'react-native'
import { StackNavigator } from 'react-navigation'
import { fetchInitialState } from './store/actions/actions';
import { Provider, connect } from 'react-redux';
import configureStore from './store/configure-store';
import MapScreen from './components/Map'
import HomeScreen from './components/HomeScreen'
const Routes = StackNavigator({
Home: { screen: HomeScreen },
Map: { screen: MapScreen }
}, {
headerMode: 'none'
})
const store = configureStore();
// If we need to fetch some intial data we can do that now! Dispatch an action!
// store.dispatch(fetchInitialState());
// Console out changes to the store for easy debugging.
store.subscribe(() => {
console.log('State Change: ', store.getState());
});
export default class App extends React.Component {
render () {
return (
<Provider store={store} >
<Routes />
</Provider>
)
}
}
AppRegistry.registerComponent('barfinder', () => App)
`
const ConfigureStore = `import {createStore, applyMiddleware} from 'redux';
import thunkMiddleware from 'redux-thunk';
import rootReducer from './reducers/index';
const createStoreWithMiddleware = applyMiddleware(thunkMiddleware)(createStore);
export default function configureStore(initialState) {
return createStoreWithMiddleware(rootReducer, initialState);
}`
const ActionTypes = `export const SEARCH_START = 'SEARCH_START'
export const SEARCH_SUCCESS = 'SEARCH_SUCCESS'
export const SEARCH_ERRROR = 'SEARCH_ERROR'`
const Actions = `import * as ActionTypes from './action-types';
import * as helpers from './helpers';
import config from 'react-native-configs';
export function searchBars(text, lat, long) {
return (dispatch) => {
dispatch(helpers.startAction(ActionTypes.SEARCH_START))
return fetch(\`\${config.barApi}?lat=\${lat}&long=\${long}&name=\${text}\`).then((response) => {
if(response.status !== 200){
throw new Error('error', response.statusText);
}
return response.json();
})
.then((json) => {
return dispatch(helpers.successAction(ActionTypes.SEARCH_SUCCESS, json))
})
.catch((error) => {
console.log(error);
dispatch(helpers.failureAction('ERROR', error))
});
};
}
// Here is how we can structure a call to fetch some initial app data. See the comment in indes.ios.js
// export function fetchInitialState() {
// return (dispatch) => {
// dispatch(fetchsomething());
// };
// }
`
const Helpers = `export function startAction(type) {
console.log('start action ', type);
return { type };
}
export function successAction(type, json) {
console.log('success action ', type);
return { type, payload: json};
}
export function failureAction(type, error) {
console.log('failure action ', type, error);
return { type, payload: error, error: true };
}`
const ReducerIndex = `import {combineReducers} from 'redux';
import search from './search';
const rootReducer = combineReducers({
search
});
export default rootReducer`
const SearchReducer = `import * as ActionTypes from './../actions/action-types';
import _ from 'lodash';
const initialState = {
results: [],
error: null
};
const formatResults = results => _.map(results, result => ({
name: result.name,
coordinate: {
longitude: result.location.coordinates[0],
latitude: result.location.coordinates[1]
},
description: result.description,
rating: result.avgRating,
distance: Math.round(result.distance),
address: result.address,
image: result.image
}))
export default function search(state = initialState, { type, payload }) {
switch(type){
case ActionTypes.SEARCH_START:
return _.assign({}, state, { isLoading: true });
case ActionTypes.SEARCH_SUCCESS:
return _.assign({}, state, { results: formatResults(payload.bars) });
case ActionTypes.SEARCH_ERRROR:
return _.assign({}, state, { error: payload });
default:
return state;
}
}`
const config = `{
"barApi": "https://nm-bar-finder.herokuapp.com/api/v1/bar/search"
}
`
class SearchUiView extends Component {
render() {
return (
<div className="general">
<h1>16. Store Setup!</h1>
<ul className="setup__steps">
<li>
<p>
Now that we have a clean entry file, we can use it to intialize our redux store. Let's update our index files.
</p>
<Highlight lang='javascript' value={indexJs} />
</li>
<li>
<p>Now lets add all the supporting files. I will go over these one by one but for now just copy them over</p>
</li>
<li>
<p>/store/configure-store.js</p>
<Highlight lang='javascript' value={ConfigureStore} />
</li>
<li>
<p>/store/actions/action-types.js</p>
<Highlight lang='javascript' value={ConfigureStore} />
</li>
<li>
<p>/store/actions/actions.js</p>
<Highlight lang='javascript' value={Actions} />
</li>
<li>
<p>/store/actions/helpers.js</p>
<Highlight lang='javascript' value={Helpers} />
</li>
<li>
<p>/store/reducers/index.js</p>
<Highlight lang='javascript' value={ReducerIndex} />
</li>
<li>
<p>/store/reducers/search.js</p>
<Highlight lang='javascript' value={SearchReducer} />
</li>
<li>
<p>
The 'react-nativ-configs' module is handy for configuring API endpoints. It uses the __DEV__ global to select the configs.
This is helpful if you want to setup a mock endpoint for local development and a seperate enpoint for release.
</p>
<p>
You can also use it for other configurations that you might want to only run in development. Let's set up the supporting files.
</p>
<p>/config/debug.json</p>
<Highlight lang='javascript' value={config} />
<p>/config/release.json</p>
<Highlight lang='javascript' value={config} />
</li>
</ul>
</div>
)
}
}
export default SearchUiView
|
src/routes/app/routes/ui/routes/hover/components/Hover.js | ahthamrin/kbri-admin2 | import React from 'react';
import QueueAnim from 'rc-queue-anim';
const MaterialHover = () => (
<article className="article">
<h2 className="article-title">Material Hover</h2>
<div className="row">
<div className="col-xl-4">
<div className="ih-item ih-material">
<a href="javascript:;">
<div className="img">
<img src="assets/images-demo/assets/600_400-1.jpg" alt="" />
</div>
<div className="info">
<div className="info-mask bg-color-primary" />
<div className="info-content">
<div className="info-inner">
<h3>Heading Here</h3>
<p>Description goes here</p>
</div>
</div>
</div>
</a>
</div>
</div>
<div className="col-xl-4">
<div className="ih-item ih-material">
<a href="javascript:;">
<div className="img">
<img src="assets/images-demo/assets/600_400-2.jpg" alt="" />
</div>
<div className="info">
<div className="info-mask bg-color-info" />
<div className="info-content">
<div className="info-inner">
<h3>Heading Here</h3>
<p>Description goes here</p>
</div>
</div>
</div>
</a>
</div>
</div>
<div className="col-xl-4">
<div className="ih-item ih-material">
<a href="javascript:;">
<div className="img">
<img src="assets/images-demo/assets/600_400-3.jpg" alt="" />
</div>
<div className="info">
<div className="info-mask bg-color-dark" />
<div className="info-content">
<div className="info-inner">
<h3>Heading Here</h3>
<p>Description goes here</p>
</div>
</div>
</div>
</a>
</div>
</div>
</div>
</article>
);
const Classic = () => (
<article className="article">
<h2 className="article-title">Classic</h2>
<div className="row">
<div className="col-xl-4">
<div className="ih-item square effect3 bottom_to_top">
<a href="javascript:;">
<div className="img"><img src="assets/images-demo/assets/600_400-1.jpg" alt="img" /></div>
<div className="info">
<h3>Heading here</h3>
<p>Description goes here</p>
</div>
</a>
</div>
</div>
<div className="col-xl-4">
<div className="ih-item square effect3 bottom_to_top">
<a href="javascript:;">
<div className="img"><img src="assets/images-demo/assets/600_400-2.jpg" alt="img" /></div>
<div className="info bg-color-info">
<h3>Heading here</h3>
<p>Description goes here</p>
</div>
</a>
</div>
</div>
<div className="col-xl-4">
<div className="ih-item square effect3 bottom_to_top">
<a href="javascript:;">
<div className="img"><img src="assets/images-demo/assets/600_400-3.jpg" alt="img" /></div>
<div className="info bg-color-primary">
<h3>Heading here</h3>
<p>Description goes here</p>
</div>
</a>
</div>
</div>
</div>
<div className="row">
<div className="col-xl-4">
<div className="ih-item square effect3 top_to_bottom">
<a href="javascript:;">
<div className="img"><img src="assets/images-demo/assets/600_400-4.jpg" alt="img" /></div>
<div className="info">
<h3>Heading here</h3>
<p>Description goes here</p>
</div>
</a>
</div>
</div>
<div className="col-xl-4">
<div className="ih-item square effect3 top_to_bottom">
<a href="javascript:;">
<div className="img"><img src="assets/images-demo/assets/600_400-5.jpg" alt="img" /></div>
<div className="info bg-color-info">
<h3>Heading here</h3>
<p>Description goes here</p>
</div>
</a>
</div>
</div>
<div className="col-xl-4">
<div className="ih-item square effect3 top_to_bottom">
<a href="javascript:;">
<div className="img"><img src="assets/images-demo/assets/600_400-6.jpg" alt="img" /></div>
<div className="info bg-color-primary">
<h3>Heading here</h3>
<p>Description goes here</p>
</div>
</a>
</div>
</div>
</div>
</article>
);
const HoverSection = () => (
<section className="container-fluid with-maxwidth chapter">
<QueueAnim type="bottom" className="ui-animate">
<div key="1"><MaterialHover /></div>
<div key="2"><Classic /></div>
</QueueAnim>
</section>
);
module.exports = HoverSection;
|
src/web/forms/editor/FormAdder.js | asha-nepal/AshaFusionCross | /* @flow */
import React from 'react';
import Modal from '../../components/Modal';
import {
TextInputComponent,
} from '../fields';
type Props = {
onFormAdd: (id: string, label: string) => void,
className?: string,
}
export default class extends React.Component {
constructor(props: Props) {
super(props);
this.state = {
isModalOpen: false,
newFormId: '',
newFormLabel: '',
};
}
state: {
isModalOpen: boolean,
newFormId: string,
newFormLabel: string,
}
props: Props
render() {
const {
onFormAdd,
className,
} = this.props;
return (
<span className={className}>
<a
className="button is-primary"
onClick={e => {
e.preventDefault();
this.setState({ isModalOpen: true });
}}
>Add new form</a>
<Modal
isOpen={this.state.isModalOpen}
onClose={() => this.setState({ isModalOpen: false })}
>
<div className="box">
<TextInputComponent
label="ID"
value={this.state.newFormId}
onChange={newFormId => this.setState({ newFormId })}
/>
<TextInputComponent
label="Label"
value={this.state.newFormLabel}
onChange={newFormLabel => this.setState({ newFormLabel })}
/>
<p className="control">
<label className="label"> </label>
<a
className="button"
onClick={e => {
e.preventDefault();
onFormAdd(this.state.newFormId, this.state.newFormLabel);
this.setState({
isModalOpen: false,
newFormId: '',
newFormLabel: '',
});
}}
>Add new form</a>
</p>
</div>
</Modal>
</span>
);
}
}
|
imports/ui/admin/components/books_new.js | dououFullstack/atomic | import React from 'react';
import { browserHistory } from 'react-router';
import Loading from '/imports/ui/loading';
class _Component extends React.Component {
handelDelete(id) {
if (window.confirm('确认删除?')) {
Meteor.call('bookNew.delete', id);
}
}
render() {
const data = this.props.data;
return (
<div>
<h1>出版申请</h1>
{this.props.ready ?
<table className="ui celled striped table">
<thead>
<tr>
<th>作品名称</th>
<th>版面数字</th>
<th>开本</th>
<th>印数</th>
<th>装帧</th>
<th>姓名</th>
<th>单位</th>
<th>手机号</th>
<th>邮箱</th>
<th></th>
</tr>
</thead>
<tbody>
{data.map( (data, idx) =>
<tr key={idx}>
<td>{data.bookname}</td>
<td>{data.layout}</td>
<td>{data.size}</td>
<td>{data.pages}</td>
<td>{data.binding}</td>
<td>{data.truename}</td>
<td>{data.unit}</td>
<td>{data.mobile}</td>
<td>{data.email}</td>
<td className="control">
<i className="blue remove icon pointer" onClick={()=> this.handelDelete(data._id)} />
</td>
</tr>
)}
</tbody>
</table>
:
<Loading/>
}
</div>
);
}
}
export default _Component;
|
clients/libs/webpage/src/lib/plugins/content/components/draft-editor/index.js | nossas/bonde-client | import React from 'react'
import PropTypes from 'prop-types'
import Editor from './editable-mode'
if (require('exenv').canUseDOM) require('./index.scss')
class EditorNew extends React.Component {
render () {
const { decorator, mobilization, widget: { settings } } = this.props
const { body_font: bodyFont } = mobilization
const theme = (
mobilization && mobilization.color_scheme
? mobilization.color_scheme.replace('-scheme', '')
: null
)
let value
try {
value = JSON.parse(settings.content)
} catch (e) {
value = settings.content
}
return (
<div className='widgets--content-plugin widget editor-new' style={{ fontFamily: bodyFont }}>
<Editor readOnly value={value} theme={theme} />
</div>
)
}
}
EditorNew.propTypes = {
mobilization: PropTypes.object.isRequired,
widget: PropTypes.object.isRequired
}
export default EditorNew
|
modules/Day.js | SomethingSexy/react-planner | import moment from 'moment';
import PropTypes from 'prop-types';
import React from 'react';
const Day = ({ day }) => {
return (React.createElement("div", { style: { textAlign: 'center' } },
React.createElement("strong", null, moment(day, 'MM/DD/YYYY').format('MM/DD'))));
};
Day.propTypes = {
day: PropTypes.string
};
export default Day;
//# sourceMappingURL=Day.js.map |
lib/controllers/github-tab-header-controller.js | atom/github | import React from 'react';
import PropTypes from 'prop-types';
import {AuthorPropType} from '../prop-types';
import GithubTabHeaderView from '../views/github-tab-header-view';
export default class GithubTabHeaderController extends React.Component {
static propTypes = {
user: AuthorPropType.isRequired,
// Workspace
currentWorkDir: PropTypes.string,
contextLocked: PropTypes.bool.isRequired,
changeWorkingDirectory: PropTypes.func.isRequired,
setContextLock: PropTypes.func.isRequired,
getCurrentWorkDirs: PropTypes.func.isRequired,
// Event Handlers
onDidChangeWorkDirs: PropTypes.func.isRequired,
}
constructor(props) {
super(props);
this.state = {
currentWorkDirs: [],
changingLock: null,
changingWorkDir: null,
};
}
static getDerivedStateFromProps(props) {
return {
currentWorkDirs: props.getCurrentWorkDirs(),
};
}
componentDidMount() {
this.disposable = this.props.onDidChangeWorkDirs(this.resetWorkDirs);
}
componentDidUpdate(prevProps) {
if (prevProps.onDidChangeWorkDirs !== this.props.onDidChangeWorkDirs) {
if (this.disposable) {
this.disposable.dispose();
}
this.disposable = this.props.onDidChangeWorkDirs(this.resetWorkDirs);
}
}
render() {
return (
<GithubTabHeaderView
user={this.props.user}
// Workspace
workdir={this.getWorkDir()}
workdirs={this.state.currentWorkDirs}
contextLocked={this.getContextLocked()}
changingWorkDir={this.state.changingWorkDir !== null}
changingLock={this.state.changingLock !== null}
handleWorkDirChange={this.handleWorkDirChange}
handleLockToggle={this.handleLockToggle}
/>
);
}
resetWorkDirs = () => {
this.setState(() => ({
currentWorkDirs: [],
}));
}
handleLockToggle = async () => {
if (this.state.changingLock !== null) {
return;
}
const nextLock = !this.props.contextLocked;
try {
this.setState({changingLock: nextLock});
await this.props.setContextLock(this.state.changingWorkDir || this.props.currentWorkDir, nextLock);
} finally {
await new Promise(resolve => this.setState({changingLock: null}, resolve));
}
}
handleWorkDirChange = async e => {
if (this.state.changingWorkDir !== null) {
return;
}
const nextWorkDir = e.target.value;
try {
this.setState({changingWorkDir: nextWorkDir});
await this.props.changeWorkingDirectory(nextWorkDir);
} finally {
await new Promise(resolve => this.setState({changingWorkDir: null}, resolve));
}
}
getWorkDir() {
return this.state.changingWorkDir !== null ? this.state.changingWorkDir : this.props.currentWorkDir;
}
getContextLocked() {
return this.state.changingLock !== null ? this.state.changingLock : this.props.contextLocked;
}
componentWillUnmount() {
this.disposable.dispose();
}
}
|
src/ducks/BhajanDetail/component/Header.js | saitheexplorer/bhajan-db | import React from 'react'
const Header = ({ title }) => (
<div className="row">
<div className="col-lg-12">
<h3 className="title">{title}</h3>
</div>
</div>
)
export default Header
|
src/index.js | himadriganguly/reactjs-form-practice | import React, { Component } from 'react';
import ReactDOM from 'react-dom';
import BookStore from './BookStore';
ReactDOM.render(<BookStore />, document.getElementById('root'));
|
demo/components/MultiCheckbox.js | technicallyfeasible/dataparser | import React, { Component } from 'react';
import PropTypes from 'prop-types';
import uuid from 'uuid';
export default class MultiCheckbox extends Component {
static propTypes = {
onChange: PropTypes.func,
options: PropTypes.arrayOf(PropTypes.shape({
label: PropTypes.string,
value: PropTypes.any,
})),
/* eslint-disable react/no-unused-prop-types */
defaultValue: PropTypes.arrayOf(PropTypes.any),
value: PropTypes.arrayOf(PropTypes.any),
/* eslint-enable */
};
static defaultProps = {
onChange: function noop() {},
options: [],
defaultValue: null,
value: null,
};
componentWillMount() {
this.updateSelectedState(this.props);
}
componentWillReceiveProps(props) {
this.updateSelectedState(props);
}
onClick(value, checked) {
const { onChange, options } = this.props;
let { selected } = this.state;
selected = (selected || []).filter(val => val !== value);
if (checked) {
selected.push(value);
}
this.setState({ selected });
// create new options array to make sure we keep the right order
const values = options.reduce((r, option) => {
if (selected.indexOf(option.value) !== -1) {
r.push(option.value);
}
return r;
}, []);
onChange(values);
}
updateSelectedState(props) {
const { options, defaultValue, value } = props;
if (options) {
this.setState({ selected: value || defaultValue });
}
}
render() {
const { options } = this.props;
const { selected } = this.state;
const elements = options
.map(option => {
const inputId = uuid();
const isSelected = (selected && selected.indexOf(option.value) !== -1);
return (
<span key={option.label}>
<input type="checkbox" id={inputId} checked={isSelected || false} onChange={e => this.onClick(option.value, e.target.checked)} />
<label htmlFor={inputId}>{ option.label }</label>
</span>
);
});
return elements;
}
}
|
react/reactRedux/redux-master/examples/todos-with-undo/src/components/Link.js | huxinmin/PracticeMakesPerfect | import React from 'react'
import PropTypes from 'prop-types'
const Link = ({ active, children, onClick }) => {
if (active) {
return <span>{children}</span>
}
return (
<a href="#"
onClick={e => {
e.preventDefault()
onClick()
}}
>
{children}
</a>
)
}
Link.propTypes = {
active: PropTypes.bool.isRequired,
children: PropTypes.node.isRequired,
onClick: PropTypes.func.isRequired
}
export default Link
|
js/components/anatomy/index.js | ChiragHindocha/stay_fit |
import React, { Component } from 'react';
import { StatusBar } from 'react-native';
import { connect } from 'react-redux';
import { Container, Header, Title, Content, Text, H3, Button, Icon, Footer, FooterTab, Left, Right, Body } from 'native-base';
import { openDrawer } from '../../actions/drawer';
import styles from './styles';
class Anatomy extends Component {
static propTypes = {
openDrawer: React.PropTypes.func,
}
render() {
return (
<Container style={styles.container}>
<Header>
<Left>
<Button transparent onPress={this.props.openDrawer}>
<Icon name="ios-menu" />
</Button>
</Left>
<Body>
<Title>Header</Title>
</Body>
<Right />
</Header>
<Content padder>
<Text>
Content Goes Here
</Text>
</Content>
<Footer>
<FooterTab>
<Button active full>
<Text>Footer</Text>
</Button>
</FooterTab>
</Footer>
</Container>
);
}
}
function bindAction(dispatch) {
return {
openDrawer: () => dispatch(openDrawer()),
};
}
const mapStateToProps = state => ({
navigation: state.cardNavigation,
themeState: state.drawer.themeState,
});
export default connect(mapStateToProps, bindAction)(Anatomy);
|
src/svg-icons/image/style.js | pradel/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let ImageStyle = (props) => (
<SvgIcon {...props}>
<path d="M2.53 19.65l1.34.56v-9.03l-2.43 5.86c-.41 1.02.08 2.19 1.09 2.61zm19.5-3.7L17.07 3.98c-.31-.75-1.04-1.21-1.81-1.23-.26 0-.53.04-.79.15L7.1 5.95c-.75.31-1.21 1.03-1.23 1.8-.01.27.04.54.15.8l4.96 11.97c.31.76 1.05 1.22 1.83 1.23.26 0 .52-.05.77-.15l7.36-3.05c1.02-.42 1.51-1.59 1.09-2.6zM7.88 8.75c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1zm-2 11c0 1.1.9 2 2 2h1.45l-3.45-8.34v6.34z"/>
</SvgIcon>
);
ImageStyle = pure(ImageStyle);
ImageStyle.displayName = 'ImageStyle';
export default ImageStyle;
|
packages/veritone-react-common/src/components/FolderTree/Component/ExpandIcon.js | veritone/veritone-sdk | import React from 'react';
import _ from 'lodash';
import cx from 'classnames';
import {
arrayOf,
shape,
func,
oneOfType,
number,
string
} from 'prop-types';
import { makeStyles } from '@material-ui/core/styles';
import styles from '../styles';
const useStyles = makeStyles(theme => ({
...styles
}));
export default function ExpandIcon({ folder, opening, onExpand }) {
const classes = useStyles();
const folderId = _.get(folder, 'id');
const expanded = _.includes(opening, folderId);
const expandStyle = expanded ? 'icon-sort-desc' : 'icon-caret-right';
if (folder.contentType !== 'folder' || !folder.hasContent) {
return (
<div style={{
width: 20,
minWidth: 20
}}
/>
)
}
return (
<div
onClick={onExpand(folderId)}
className={cx([
expandStyle,
classes.expandIcon
])}
/>
)
}
ExpandIcon.propTypes = {
folder: shape(Object),
onExpand: func,
opening: arrayOf(oneOfType([number, string]))
}
|
addons/themes/future-imperfect/layouts/Home.js | rendact/rendact | import $ from 'jquery'
import React from 'react';
import gql from 'graphql-tag';
import {graphql} from 'react-apollo';
import moment from 'moment';
import {Link} from 'react-router';
let Home = React.createClass({
componentDidMount(){
require('../assets/css/main.css')
},
render(){
let {
theConfig,
data,
thePagination,
loadDone
} = this.props
// debugger
return (
<div id="wrapper">
<header id="header">
<h1>
<strong><Link to="/">{theConfig?theConfig.name:"Rendact"}</Link></strong>
</h1>
<nav className="links">
{this.props.theMenu()}
</nav>
<nav className="main">
<ul>
<li className="search">
<a className="fa-search" href="#search">Search</a>
<form id="search" className="visible" method="get" action="#">
<input type="text" name="query" placeholder="Search" />
</form>
</li>
</ul>
</nav>
</header>
<div id="main">
{data && data.map((post, index) => (
<article className="post">
<header>
<div className="title">
<h2><Link to={"/post/" + post.id}>{post.title && post.title}</Link></h2>
</div>
<div className="meta">
<time className="published">{moment(post.createdAt).format("MMMM Do YY")}</time>
<small><time className="published">{moment(post.createdAt).format("h:mm:ss a")}</time></small>
</div>
</header>
<div className="image featured">
<Link to={"/post/" + post.id}>
<img src={post.imageFeatured ? post.imageFeatured.blobUrl: require('images/logo-128.png') } alt="" />
</Link>
</div>
<p dangerouslySetInnerHTML={{__html: post.content ? post.content.slice(0, 200):""}} />
<footer>
<ul className="actions">
<li><Link className="button big" to={"/post/" + post.id}>Continue Reading</Link></li>
</ul>
<ul className="stats">
<li><a href="#">{post.status}</a></li>
<li><a href="#" className="icon fa-heart">{post.comments.length}</a></li>
<li><a href="#" className="icon fa-comment">{post.comments.length?post.comments.length:0}</a></li>
</ul>
</footer>
</article>
))}
<section className="wrapper style1 align-center">
<div style={{textAlign: "center"}}>
{this.props.thePagination}
</div>
</section>
</div>
<section id="sidebar">
<section id="intro">
<a href="#" className="logo"><img src={require('images/logo-128.png')} alt="" /></a>
<header>
<h2><strong>{theConfig?theConfig.name:"RENDACT"}</strong></h2>
<h3><strong>{theConfig ? theConfig.tagline: "a simple blog"}</strong></h3>
</header>
</section>
<section className="blurb">
<div id="side" >
<div className="inner">
{this.props.footerWidgets.map((fw, i) => (
<section key={i}>{fw}</section>
))}
</div>
</div>
</section>
<section id="footer">
<p className="copyright">© FUTURE-IMPERFECT <a href="http://html5up.net">HTML5 UP</a> OF RENDACT .</p>
</section>
</section>
</div>
)
}
});
export default Home;
|
templates/react/routes/foo.js | api-platform/generate-crud | import React from 'react';
import { Route } from 'react-router-dom';
import { List, Create, Update, Show } from '../components/{{{lc}}}/';
export default [
<Route path="/{{{name}}}/create" component={Create} exact key="create" />,
<Route path="/{{{name}}}/edit/:id" component={Update} exact key="update" />,
<Route path="/{{{name}}}/show/:id" component={Show} exact key="show" />,
<Route path="/{{{name}}}/" component={List} exact strict key="list" />,
<Route path="/{{{name}}}/:page" component={List} exact strict key="page" />
];
|
demo/src/index.js | bem-sdk/bemjson-to-jsx | import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
import './index.css';
ReactDOM.render(
<App />,
document.getElementById('root')
);
|
client/canx-client/src/views/Categories.js | uros-stegic/canx | import React from 'react'
import {Link} from 'react-router'
function Categories(props) {
return (
<div className='category-container'>
<h1 className='profile-title'>CATEGORIES</h1>
{props.args.categories.map((cat, ind) => <Link key={ind} to={'/categories/'+cat.name.toLowerCase() }>
<div className='category-row'> {cat.name} </div>
</Link>)}
</div>
)
}
export default Categories
|
examples/huge-apps/components/App.js | mjw56/react-router | import React from 'react';
import Dashboard from './Dashboard';
import GlobalNav from './GlobalNav';
class App extends React.Component {
render() {
var courses = COURSES;
return (
<div>
<GlobalNav />
<div style={{ padding: 20 }}>
{this.props.children || <Dashboard courses={courses} />}
</div>
</div>
);
}
}
export default App;
|
03a-todo-list-from-scratch/src/index.js | dtanzer/react-basic-examples | import React from 'react';
import ReactDOM from 'react-dom';
import TodoList from './TodoList';
import './index.css';
ReactDOM.render(
<TodoList />,
document.getElementById('root')
);
|
frontend/src/app/containers/SharePage.js | mathjazz/testpilot | import React from 'react';
import Copter from '../components/Copter';
import LayoutWrapper from '../components/LayoutWrapper';
import View from '../components/View';
export default class SharePage extends React.Component {
render() {
return (
<View spaceBetween={true} showNewsletterFooter={false} {...this.props}>
<LayoutWrapper flexModifier="column-center">
<div id="share" className="modal">
<div className="modal-content centered">
<p data-l10n-id="sharePrimary">Love Test Pilot? Help us find some new recruits.</p>
<ul className="share-list">
<li className="share-facebook"><a href={'https://www.facebook.com/sharer/sharer.php?u=' + this.shareUrl('facebook', true)} onClick={this.handleClick('facebook')} target="_blank">Facebook</a></li>
<li className="share-twitter"><a href={'https://twitter.com/home?status=' + this.shareUrl('twitter', true)} onClick={this.handleClick('twitter')} target="_blank">Twitter</a></li>
<li className="share-email"><a href={'mailto:?body=' + this.shareUrl('email', true)} data-l10n-id="shareEmail" onClick={this.handleClick('email')}>E-mail</a></li>
</ul>
<p data-l10n-id="shareSecondary">or just copy and paste this link...</p>
<fieldset className="share-url-wrapper">
<div className="share-url">
<input type="text" readOnly value={this.shareUrl('copy', false)} />
<button data-l10n-id="shareCopy" onClick={this.handleClick('copy')} data-clipboard-target=".share-url input">Copy</button>
</div>
</fieldset>
</div>
</div>
<Copter animation="fade-in-fly-up" />
</LayoutWrapper>
</View>
);
}
shareUrl(medium, urlencode) {
const url = `https://testpilot.firefox.com/?utm_source=${medium}&utm_medium=social&utm_campaign=share-page`;
return urlencode ? encodeURIComponent(url) : url;
}
handleClick(label) {
return () => this.props.sendToGA('event', {
eventCategory: 'ShareView Interactions',
eventAction: 'button click',
eventLabel: label
});
}
}
SharePage.propTypes = {
hasAddon: React.PropTypes.bool,
uninstallAddon: React.PropTypes.func,
sendToGA: React.PropTypes.func,
openWindow: React.PropTypes.func
};
|
node_modules/react-bootstrap/es/BreadcrumbItem.js | lucketta/got-quote-generator | import _extends from 'babel-runtime/helpers/extends';
import _objectWithoutProperties from 'babel-runtime/helpers/objectWithoutProperties';
import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn';
import _inherits from 'babel-runtime/helpers/inherits';
import classNames from 'classnames';
import React from 'react';
import PropTypes from 'prop-types';
import SafeAnchor from './SafeAnchor';
var propTypes = {
/**
* If set to true, renders `span` instead of `a`
*/
active: PropTypes.bool,
/**
* `href` attribute for the inner `a` element
*/
href: PropTypes.string,
/**
* `title` attribute for the inner `a` element
*/
title: PropTypes.node,
/**
* `target` attribute for the inner `a` element
*/
target: PropTypes.string
};
var defaultProps = {
active: false
};
var BreadcrumbItem = function (_React$Component) {
_inherits(BreadcrumbItem, _React$Component);
function BreadcrumbItem() {
_classCallCheck(this, BreadcrumbItem);
return _possibleConstructorReturn(this, _React$Component.apply(this, arguments));
}
BreadcrumbItem.prototype.render = function render() {
var _props = this.props,
active = _props.active,
href = _props.href,
title = _props.title,
target = _props.target,
className = _props.className,
props = _objectWithoutProperties(_props, ['active', 'href', 'title', 'target', 'className']);
// Don't try to render these props on non-active <span>.
var linkProps = { href: href, title: title, target: target };
return React.createElement(
'li',
{ className: classNames(className, { active: active }) },
active ? React.createElement('span', props) : React.createElement(SafeAnchor, _extends({}, props, linkProps))
);
};
return BreadcrumbItem;
}(React.Component);
BreadcrumbItem.propTypes = propTypes;
BreadcrumbItem.defaultProps = defaultProps;
export default BreadcrumbItem; |
initial_test/src/app/components/projectItem.js | niketpathak/npk-website | import React, { Component } from 'react';
class ProjectItem extends Component {
deleteProject(id) {
console.log('delete clicked', id);
this.props.onDelete(id);
}
render() {
// console.log(this.props);
return (
<li className="projectItem">
<strong>{this.props.project.title} </strong> - {this.props.project.category} <a href="#" onClick={this.deleteProject.bind(this, this.props.project.id)} >Remove</a>
</li>
);
}
}
export default ProjectItem;
|
src/pages/404.js | lottebijlsma/lottebijlsma.github.io | import React from 'react';
const NotFoundPage = () => (
<div>
<h1>NOT FOUND</h1>
<p>You just hit a route that doesn't exist... the sadness.</p>
</div>
);
export default NotFoundPage;
|
app/components/AnalyticsOverview/index.js | eddiewang/tinderapp | /**
*
* AnalyticsOverview
*
*/
import React from 'react';
import Card from 'components/Card';
import Avatar from 'components/Avatar';
import avatar from 'assets/img/avatar.jpg';
import styles from './styles.scss';
function AnalyticsOverview() {
return (
<div className={styles.analyticsOverview}>
<Card width={'100%'} height={'100%'} margin={'10px auto'} styles={{display: 'block !important'}}>
<div className={styles.avatarblock}>
<Avatar className={styles.avatar} avatar={avatar} width={150} height={150} />
</div>
<div className={styles.selector}>
<span>Day</span>
<span>Week</span>
</div>
<div className={styles.statistics}>
<div className={styles.statblock}>
<h1 className={styles.statheading}>145</h1>
<span className={styles.label}>Likes</span>
</div>
<div className={styles.statblock}>
<h1 className={styles.statheading}>23</h1>
<span className={styles.label}>Matches</span>
</div>
<div className={styles.statblock}>
<h1 className={styles.statheading}>35</h1>
<span className={styles.label}>Messages</span>
</div>
</div>
</Card>
</div>
);
}
export default AnalyticsOverview;
|
src/components/TextArea/Textarea-story.js | jzhang300/carbon-components-react | import React from 'react';
import { storiesOf } from '@storybook/react';
import { action } from '@storybook/addon-actions';
import TextArea from '../TextArea';
const TextAreaProps = {
labelText: 'Text Area label',
className: 'some-class',
onChange: action('onChange'),
onClick: action('onClick'),
placeholder: 'Placeholder text.',
id: 'test2',
cols: 50,
rows: 4,
};
storiesOf('TextArea', module)
.addWithInfo(
'enabled',
`
Text areas enable the user to interact with and input data. A text area is used when you
anticipate the user to input more than 1 sentence. The example belows shows an enabled
Text Area component.
`,
() => <TextArea {...TextAreaProps} />
)
.addWithInfo(
'disabled',
`
Text areas enable the user to interact with and input data. A text area is used when you
anticipate the user to input more than 1 sentence. The example belows shows an disabled
Text Area component.
`,
() => <TextArea disabled {...TextAreaProps} placeholder={'Disabled'} />
);
|
app/components/IssueIcon/index.js | mclxly/react-study | import React from 'react';
function IssueIcon(props) {
return (
<svg
height="1em"
width="0.875em"
className={props.className}
>
<path d="M7 2.3c3.14 0 5.7 2.56 5.7 5.7S10.14 13.7 7 13.7 1.3 11.14 1.3 8s2.56-5.7 5.7-5.7m0-1.3C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7S10.86 1 7 1z m1 3H6v5h2V4z m0 6H6v2h2V10z" />
</svg>
);
}
IssueIcon.propTypes = {
className: React.PropTypes.string,
};
export default IssueIcon;
|
packages/icons/src/md/av/Replay5.js | suitejs/suitejs | import React from 'react';
import IconBase from '@suitejs/icon-base';
function MdReplay5(props) {
return (
<IconBase viewBox="0 0 48 48" {...props}>
<path d="M24 12V4L14 14l10 10v-8c6.6 0 12 5.4 12 12s-5.4 12-12 12-12-5.4-12-12H8c0 8.8 7.2 16 16 16s16-7.2 16-16-7.2-16-16-16zm-2.6 17.8l.5-4.3h4.8v1.4h-3.4l-.2 1.8c.1 0 .1-.1.2-.1s.2-.1.3-.1c.1 0 .2-.1.4-.1h.4c.4 0 .8.1 1.1.2.3.1.6.3.8.6.2.3.4.5.5.9.1.4.2.8.2 1.2 0 .4-.1.7-.2 1.1-.1.4-.3.6-.5.9-.2.3-.5.5-.9.6-.4.1-.8.2-1.3.2-.4 0-.7-.1-1.1-.2-.4-.1-.6-.3-.9-.5-.3-.2-.5-.5-.6-.8-.1-.3-.3-.7-.3-1.1h1.7c0 .4.2.6.4.8.2.2.5.3.8.3.2 0 .4 0 .5-.1.1-.1.3-.2.4-.3.1-.1.2-.3.2-.5s.1-.4.1-.6c0-.2 0-.4-.1-.6-.1-.2-.1-.3-.3-.5-.2-.2-.3-.2-.4-.3-.1-.1-.4-.1-.6-.1h-.4s-.2.1-.3.1c-.1 0-.2.2-.3.3l-.2.2-1.3-.4z" />
</IconBase>
);
}
export default MdReplay5;
|
src/client/search/search-message.react.js | lassecapel/este-isomorphic-app | import React from 'react';
import PureComponent from '../components/purecomponent.react';
export default class SearchMessage extends PureComponent {
render() {
return (
<div className='row' style={{textAlign: 'center', height: '4em'}}>
{this.props.query && <p>You search "{this.props.query}" resulted in {this.props.total} search results</p>}
</div>
);
}
}
SearchMessage.propTypes = {
query: React.PropTypes.string.isRequired,
total: React.PropTypes.number.isRequired
};
|
client/components/Main.js | wilywallabies/wilyVideo | import React from 'react';
import { Link } from 'react-router';
const Main = React.createClass({
render(){
return (
<div>
<h1>
<Link to="/">WilyVideo</Link>
</h1>
{React.cloneElement(this.props.children, this.props)}
</div>
)
}
});
export default Main;
|
app/javascript/mastodon/features/compose/components/upload_button.js | Chronister/mastodon | import React from 'react';
import IconButton from '../../../components/icon_button';
import PropTypes from 'prop-types';
import { defineMessages, injectIntl } from 'react-intl';
import { connect } from 'react-redux';
import ImmutablePureComponent from 'react-immutable-pure-component';
import ImmutablePropTypes from 'react-immutable-proptypes';
const messages = defineMessages({
upload: { id: 'upload_button.label', defaultMessage: 'Add media (JPEG, PNG, GIF, WebM, MP4, MOV)' },
});
const makeMapStateToProps = () => {
const mapStateToProps = state => ({
acceptContentTypes: state.getIn(['media_attachments', 'accept_content_types']),
});
return mapStateToProps;
};
const iconStyle = {
height: null,
lineHeight: '27px',
};
export default @connect(makeMapStateToProps)
@injectIntl
class UploadButton extends ImmutablePureComponent {
static propTypes = {
disabled: PropTypes.bool,
onSelectFile: PropTypes.func.isRequired,
style: PropTypes.object,
resetFileKey: PropTypes.number,
acceptContentTypes: ImmutablePropTypes.listOf(PropTypes.string).isRequired,
intl: PropTypes.object.isRequired,
};
handleChange = (e) => {
if (e.target.files.length > 0) {
this.props.onSelectFile(e.target.files);
}
}
handleClick = () => {
this.fileElement.click();
}
setRef = (c) => {
this.fileElement = c;
}
render () {
const { intl, resetFileKey, disabled, acceptContentTypes } = this.props;
return (
<div className='compose-form__upload-button'>
<IconButton icon='camera' title={intl.formatMessage(messages.upload)} disabled={disabled} onClick={this.handleClick} className='compose-form__upload-button-icon' size={18} inverted style={iconStyle} />
<label>
<span style={{ display: 'none' }}>{intl.formatMessage(messages.upload)}</span>
<input
key={resetFileKey}
ref={this.setRef}
type='file'
multiple={false}
accept={acceptContentTypes.toArray().join(',')}
onChange={this.handleChange}
disabled={disabled}
style={{ display: 'none' }}
/>
</label>
</div>
);
}
}
|
src/components/search-result.js | marcusdarmstrong/mockdraftable-web | // @flow
import React from 'react';
import SparkGraph from './graphs/spark-graph';
import type { Position } from '../types/domain';
import type { MeasurablePercentile } from '../types/graphing';
import Link from './link';
type Props = {
name: string,
playerPosition: Position,
selectedPosition: Position,
id: string,
percentiles: Array<MeasurablePercentile>,
measurable?: string,
school?: string,
draft: number,
};
const SearchResult =
({ name, playerPosition, selectedPosition, id, percentiles, measurable, school, draft }: Props) =>
(
<Link
href={`/player/${id}?position=${selectedPosition.id}`}
className="list-group-item list-group-item-action justify-content-between d-flex"
>
<div className="list-group-item-text mt-1">
<h5 className="list-group-item-heading mb-0 text-dark">{name}</h5>
<span
className="badge"
title={playerPosition.name}
style={{ backgroundColor: playerPosition.color, color: '#fff' }}
>
{playerPosition.abbreviation}
</span>
<span className="align-middle ml-2">{school && `${school}, `}{draft}</span>
</div>
<SparkGraph percentiles={percentiles} overlay={measurable} color={selectedPosition.color} />
</Link>
);
SearchResult.defaultProps = {
measurable: undefined,
school: undefined,
};
export default SearchResult;
|
src/components/CollapseTreeZoom.js | ysaaron/react-collapse-tree | import React from 'react';
import d3 from 'd3';
import { DragDropContext } from 'react-dnd';
import MouseEventBackend from 'react-dnd-mouse-backend';
import { walkThroughTree } from '../utils/walkThroughTree';
import SvgChart from './SvgChart';
import Links from './Links';
import Nodes from './Nodes';
class CollapseTree extends React.Component {
constructor(props) {
super(props);
var tree = d3.layout.tree().size([this.props.height, this.props.width]),
nodes = tree.nodes(this.props.source),
links = tree.links(nodes);
nodes.forEach((d, index) => {
d._children = undefined;
d.id = index;
d.y = d.depth * 180;
d.x0 = d.x;
d.y0 = d.y;
d.isDisplay = true;
});
this.state = {
isDragging: false,
tree: tree,
nodes: nodes,
links: links,
eventNode: nodes[0]
};
}
render() {
return (
<SvgChart
height={this.props.height}
width={this.props.width}
blockZooming={this.state.isDragging}
>
<Links
linksData={this.state.links}
eventNode={this.state.eventNode}
isDragging={this.state.isDragging}
/>
<Nodes
nodesData={this.state.nodes}
eventNode={this.state.eventNode}
onNodeClick={this.handleNodeClick.bind(this)}
onNodeBeginDrag={this.handleNodeBeginDrag.bind(this)}
onNodeEndDrag={this.handleNodeEndDrag.bind(this)}
onNodeDidDrop={this.handleNodeDidDrop.bind(this)}
/>
</SvgChart>
);
}
handleNodeBeginDrag(node) {
walkThroughTree(node, (item) => { return item.children; }, (item) => { item.isDisplay = false; });
let {
x: endingX,
y: endingY
} = node;
this.setState({
isDragging: true,
nodes: this.state.nodes,
eventNode: {
id: node.id,
x: node.x,
y: node.y,
x0: endingX,
y0: endingY
}
});
}
handleNodeEndDrag(node) {
walkThroughTree(node, (item) => { return item.children; }, (item) => { item.isDisplay = true; });
this.setState({
isDragging: false
});
}
handleNodeDidDrop(droppedNode, draggedNode) {
let tmpNodes = this.state.nodes.slice();
let droppedIndex = tmpNodes.indexOf(droppedNode);
let draggedIndex = tmpNodes.indexOf(draggedNode);
if(droppedIndex == -1 || draggedIndex == -1)
return;
//move node to another node
if(!!tmpNodes[droppedIndex].children) {
droppedNode.children.push(draggedNode);
} else if(!!tmpNodes[droppedIndex]._children) {
droppedNode._children.push(draggedNode);
} else {
droppedNode.children = [];
droppedNode.children.push(draggedNode);
}
//remove draggedNode from parant
let indexInParant = draggedNode.parent.children.indexOf(draggedNode);
draggedNode.parent = draggedNode.parent.children.splice(indexInParant, 1);
let {
x: endingX,
y: endingY
} = droppedNode;
var newNodes = this.state.tree.nodes(this.props.source).map((d) => {
d.y = d.depth * 180;
return d;
});
let newLinks = this.state.tree.links(newNodes);
this.setState({
nodes: newNodes,
links: newLinks,
eventNode: {
id: droppedNode.id,
x: droppedNode.x,
y: droppedNode.y,
x0: endingX,
y0: endingY
}
});
}
handleNodeClick(node) {
let tmpNodes = this.state.nodes.slice();
let index = tmpNodes.indexOf(node);
let isUpdated = true;
if(index == -1)
return;
if(!!tmpNodes[index].children) {
tmpNodes[index]._children = tmpNodes[index].children;
tmpNodes[index].children = undefined;
} else if(!!tmpNodes[index]._children) {
tmpNodes[index].children = tmpNodes[index]._children;
tmpNodes[index]._children = undefined;
} else {
isUpdated = false;
}
if(isUpdated) {
let {
x: endingX,
y: endingY
} = node;
tmpNodes.forEach((item) => {
item.x0 = item.x;
item.y0 = item.y;
})
var newNodes = this.state.tree.nodes(this.props.source).map((d) => {
d.y = d.depth * 180;
return d;
});
let newLinks = this.state.tree.links(newNodes);
this.setState({
nodes: newNodes,
links: newLinks,
eventNode: {
id: node.id,
x: node.x,
y: node.y,
x0: endingX,
y0: endingY
}
});
}
}
};
CollapseTree.propTypes = {
source: React.PropTypes.object.isRequired,
height: React.PropTypes.number,
width: React.PropTypes.number,
depth: React.PropTypes.number
};
CollapseTree.defaultProps = {
height: 1000,
width: 1000,
depth: 1
}
export default DragDropContext(MouseEventBackend)(CollapseTree);
|
src/components/LandingPages/Email/FilterOptions/index.js | ndlib/usurper | import React from 'react'
import { useLocation } from 'react-router-dom'
import PropTypes from 'prop-types'
import { connect } from 'react-redux'
import { bindActionCreators } from 'redux'
import typy from 'typy'
import PresenterFactory from 'components/APIPresenterFactory'
import Presenter from './presenter'
import { fetchGrouping } from 'actions/contentful/grouping'
import { mapFacet } from 'constants/facets'
import * as statuses from 'constants/APIStatuses'
const FACETS_GROUPING = 'event-facets'
export const FilterOptionsContainer = (props) => {
const { facetStatus, fetchGrouping } = props
const location = useLocation()
React.useEffect(() => {
const preview = (new URLSearchParams(location.search)).get('preview') === 'true'
if (facetStatus === statuses.NOT_FETCHED) {
fetchGrouping(FACETS_GROUPING, preview, 2)
}
}, [location, facetStatus, fetchGrouping])
return (
<PresenterFactory
status={props.facetStatus}
presenter={Presenter}
props={{
facets: props.facets,
onOptionChange: props.onOptionChange,
selectedOptions: props.selectedOptions,
}}
/>
)
}
export const mapStateToProps = (state) => {
const { grouping } = state
const facetStatus = typy(grouping, `${FACETS_GROUPING}.status`).safeString || statuses.NOT_FETCHED
const facets = (facetStatus === statuses.SUCCESS)
? typy(grouping, `${FACETS_GROUPING}.data.fields.items`).safeArray.map(mapFacet)
: []
return {
facetStatus,
facets,
}
}
export const mapDispatchToProps = (dispatch) => {
return bindActionCreators({ fetchGrouping }, dispatch)
}
FilterOptionsContainer.propTypes = {
facetStatus: PropTypes.string.isRequired,
facets: PropTypes.array,
fetchGrouping: PropTypes.func.isRequired,
onOptionChange: PropTypes.func.isRequired,
selectedOptions: PropTypes.object.isRequired,
}
const FilterOptions = connect(mapStateToProps, mapDispatchToProps)(FilterOptionsContainer)
export default FilterOptions
|
node_modules/react-bootstrap/es/MediaHeading.js | firdiansyah/crud-req | import _extends from 'babel-runtime/helpers/extends';
import _objectWithoutProperties from 'babel-runtime/helpers/objectWithoutProperties';
import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn';
import _inherits from 'babel-runtime/helpers/inherits';
import classNames from 'classnames';
import React from 'react';
import elementType from 'react-prop-types/lib/elementType';
import { bsClass, getClassSet, splitBsProps } from './utils/bootstrapUtils';
var propTypes = {
componentClass: elementType
};
var defaultProps = {
componentClass: 'h4'
};
var MediaHeading = function (_React$Component) {
_inherits(MediaHeading, _React$Component);
function MediaHeading() {
_classCallCheck(this, MediaHeading);
return _possibleConstructorReturn(this, _React$Component.apply(this, arguments));
}
MediaHeading.prototype.render = function render() {
var _props = this.props,
Component = _props.componentClass,
className = _props.className,
props = _objectWithoutProperties(_props, ['componentClass', 'className']);
var _splitBsProps = splitBsProps(props),
bsProps = _splitBsProps[0],
elementProps = _splitBsProps[1];
var classes = getClassSet(bsProps);
return React.createElement(Component, _extends({}, elementProps, {
className: classNames(className, classes)
}));
};
return MediaHeading;
}(React.Component);
MediaHeading.propTypes = propTypes;
MediaHeading.defaultProps = defaultProps;
export default bsClass('media-heading', MediaHeading); |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.