path
stringlengths 5
195
| repo_name
stringlengths 5
79
| content
stringlengths 25
1.01M
|
---|---|---|
src/svg-icons/device/airplanemode-inactive.js | hai-cea/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let DeviceAirplanemodeInactive = (props) => (
<SvgIcon {...props}>
<path d="M13 9V3.5c0-.83-.67-1.5-1.5-1.5S10 2.67 10 3.5v3.68l7.83 7.83L21 16v-2l-8-5zM3 5.27l4.99 4.99L2 14v2l8-2.5V19l-2 1.5V22l3.5-1 3.5 1v-1.5L13 19v-3.73L18.73 21 20 19.73 4.27 4 3 5.27z"/>
</SvgIcon>
);
DeviceAirplanemodeInactive = pure(DeviceAirplanemodeInactive);
DeviceAirplanemodeInactive.displayName = 'DeviceAirplanemodeInactive';
DeviceAirplanemodeInactive.muiName = 'SvgIcon';
export default DeviceAirplanemodeInactive;
|
src/admin/src/components/controls/renderers/render_number.js | jgretz/zen-express | import React from 'react';
export const renderNumber = (data) =>
(
<span>{data ? data.toLocaleString() : ''}</span>
);
|
docs-ui/components/tableChart.stories.js | ifduyue/sentry | import React from 'react';
import {storiesOf} from '@storybook/react';
import {withInfo} from '@storybook/addon-info';
import {number, text, boolean, array} from '@storybook/addon-knobs';
import TableChart from 'app/components/charts/tableChart';
storiesOf('Charts/TableChart', module).add(
'default',
withInfo(
'A simple table that can calculate totals and relative share as a bar inside of a row'
)(() => {
const ERROR_TYPE_DATA = [
['TypeError', 50, 40, 30],
['SyntaxError', 40, 30, 20],
['NameError', 15, 15, 15],
['ZeroDivisionError', 20, 10, 0],
];
return (
<TableChart
data={ERROR_TYPE_DATA}
dataStartIndex={number('Data Start Index', 1)}
showRowTotal={boolean('Show Row Total', true)}
showColumnTotal={boolean('Show Column Total', true)}
shadeRowPercentage={boolean('Shade Row %', true)}
headers={array('Headers', [
text('Column 1', 'Exception Type'),
text('Column 2', 'Project 1'),
text('Column 3', 'Project 2'),
text('Column 4', 'Project 3'),
])}
widths={array('Widths', [
number('Column 1', null),
number('Column 2', 100),
number('Column 3', 100),
number('Column 4', 100),
])}
rowTotalLabel={text('Row Total Label', 'Row Total')}
rowTotalWidth={number('Row Total Column Width', 120)}
/>
);
})
);
|
text-dream/webapp/src/components/heads/DreamHeadComponent.js | PAIR-code/interpretability | /**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
import React from 'react';
import PropTypes from 'prop-types';
import {Grid, Typography, Tooltip, Paper} from '@material-ui/core';
import ReconstructSentence from '../reconstruct/ReconstructSentence';
/**
* Providing a Heading Component for Dreaming Cards.
*/
class DreamHead extends React.Component {
/**
* Renders the heading component.
*
* @return {jsx} the heading component to be rendered.
*/
render() {
return (
<Grid item>
<Paper className='subHeadingPaper' style={{backgroundColor: '#DDDDDD'}}
square>
<Grid container direction='row' spacing={1} alignItems="center">
<Tooltip title="Input Sentence" placement="top">
<Grid item style={{width: this.props.sentenceParams.headWidth}}>
<Typography variant="body1" color="inherit">
I
</Typography>
</Grid>
</Tooltip>
<Grid item>
<ReconstructSentence
sentence={this.props.params.tokens}
target={this.props.sentenceParams.target}
original={this.props.sentenceParams.target}
colors={this.props.sentenceParams.colors}/>
</Grid>
</Grid>
</Paper>
</Grid>
);
}
}
DreamHead.propTypes = {
params: PropTypes.object.isRequired,
sentenceParams: PropTypes.object.isRequired,
};
export default DreamHead;
|
assets/javascripts/sso/components/AdminIndexCard.js | laincloud/sso | import StyleSheet from 'react-style';
import React from 'react';
import {History} from 'react-router';
let AdminIndexCard = React.createClass({
mixins: [History],
render() {
const buttons = [
{ title: "我的应用管理", target: "apps" },
{ title: "我的群组管理", target: "groups" },
{ title: "用户管理-管理员特供", target: "users" },
];
return (
<div className="mdl-card mdl-shadow--2dp" styles={[this.styles.card, this.props.style]}>
<div className="mdl-card__title">
<h2 className="mdl-card__title-text">自助服务</h2>
</div>
<div className="mdl-card__supporting-text" style={this.styles.supporting}>
这里提供了一些应用和群组的管理功能,用户管理属于管理员特供功能,非管理员同学请勿操作,如果有需要,请联系 LAIN 集群管理员。
</div>
<div style={{ padding: 8 }}>
{
_.map(buttons, (btn) => {
return (
<button className="mdl-button mdl-js-button mdl-button--accent mdl-js-ripple-effect"
onClick={(evt) => this.adminAuthorize(btn.target)}
key={btn.target}
style={this.styles.buttons}>
{btn.title}
</button>
);
})
}
</div>
</div>
);
},
adminAuthorize(target) {
this.history.pushState(null, `/spa/admin/${target}`);
},
styles: StyleSheet.create({
card: {
width: '100%',
marginBottom: 16,
minHeight: 50,
},
buttons: {
display: 'block',
},
supporting: {
borderTop: '1px solid rgba(0, 0, 0, .12)',
borderBottom: '1px solid rgba(0, 0, 0, .12)',
},
}),
});
export default AdminIndexCard;
|
src/__mocks__/react-intl.js | shayc/cboard | import React from 'react';
const Intl = jest.genMockFromModule('react-intl');
// Here goes intl context injected into component, feel free to extend
const intl = {
formatMessage: ({ defaultMessage }) => defaultMessage
};
Intl.injectIntl = Node => {
const renderWrapped = props => <Node {...props} intl={intl} />;
renderWrapped.displayName = Node.displayName || Node.name || 'Component';
return renderWrapped;
};
module.exports = Intl;
|
examples/js/custom/csv-button/fully-custom-csv-button.js | prajapati-parth/react-bootstrap-table | /* eslint max-len: 0 */
/* eslint no-unused-vars: 0 */
/* eslint no-alert: 0 */
import React from 'react';
import { BootstrapTable, TableHeaderColumn, InsertButton } from 'react-bootstrap-table';
const products = [];
function addProducts(quantity) {
const startId = products.length;
for (let i = 0; i < quantity; i++) {
const id = startId + i;
products.push({
id: id,
name: 'Item name ' + id,
price: 2100 + i
});
}
}
addProducts(5);
export default class FullyCustomInsertButtonTable extends React.Component {
createCustomExportCSVButton = (onClick) => {
return (
<button style={ { color: 'red' } } onClick={ onClick }>Custom Export CSV Btn</button>
);
}
render() {
const options = {
exportCSVBtn: this.createCustomExportCSVButton
};
return (
<BootstrapTable data={ products } options={ options } exportCSV>
<TableHeaderColumn dataField='id' isKey={ true }>Product ID</TableHeaderColumn>
<TableHeaderColumn dataField='name'>Product Name</TableHeaderColumn>
<TableHeaderColumn dataField='price'>Product Price</TableHeaderColumn>
</BootstrapTable>
);
}
}
|
js/components/Header/6.js | LetsBuildSomething/vmag_mobile |
import React, { Component } from 'react';
import { connect } from 'react-redux';
import { Container, Header, Title, Content, Button, Icon, Left, Right, Body, Text } from 'native-base';
import { Actions } from 'react-native-router-flux';
import { actions } from 'react-native-navigation-redux-helpers';
import { openDrawer } from '../../actions/drawer';
import styles from './styles';
const {
popRoute,
} = actions;
class Header6 extends Component { // eslint-disable-line
static propTypes = {
openDrawer: React.PropTypes.func,
popRoute: React.PropTypes.func,
navigation: React.PropTypes.shape({
key: React.PropTypes.string,
}),
}
popRoute() {
this.props.popRoute(this.props.navigation.key);
}
render() {
return (
<Container style={styles.container}>
<Header>
<Left>
<Button transparent onPress={() => Actions.pop()}>
<Icon name="arrow-back" />
</Button>
</Left>
<Body>
<Title>Header</Title>
</Body>
<Right>
<Button transparent><Icon name="search" /></Button>
<Button transparent><Icon name="heart" /></Button>
<Button transparent><Icon name="more" /></Button>
</Right>
</Header>
<Content padder>
<Text>
Header With multiple Icon Buttons
</Text>
</Content>
</Container>
);
}
}
function bindAction(dispatch) {
return {
openDrawer: () => dispatch(openDrawer()),
popRoute: key => dispatch(popRoute(key)),
};
}
const mapStateToProps = state => ({
navigation: state.cardNavigation,
themeState: state.drawer.themeState,
});
export default connect(mapStateToProps, bindAction)(Header6);
|
app/components/material/Material_5.js | tw00089923/kcr_bom | import React from 'react';
import style from './Material.css';
import cx from 'classname';
import _ from 'lodash';
export default class Material_5 extends React.Component {
constructor(props) {
super(props);
this.state ={
show_first:false,
show_3_2_1:true,
show_3_2_2:false,
show_3_1:false,
index_3_1_1:"00",
index_3_1_2:"0",
index_3_1_3:"00",
index_3_1_4:"000"
};
this.onChange = this.onChange.bind(this);
this.upload = this.upload.bind(this);
}
show(){
this.setState({show_first:!this.state.show_first});
}
upload(e){
let files = e.target.files;
console.log(XLSX.read(files,{type: 'base64'}));
console.log(f);
}
onChange(e){
if(e.target.name == "glup"){
this.setState({show_3_2_1:!this.state.show_3_2_1});
}
if(e.target.name == "index_2_2"){
this.setState({index_2_1_2:e.target.value});
}
if(e.target.name =="index_3_1"){
this.setState({index_3_1_1:e.target.value});
}
if(e.target.name =="index_2_3"){
this.setState({index_2_1_3:e.target.value});
}
if(e.target.name =="index_2_4"){
this.setState({index_2_1_4:e.target.value});
}
}
render() {
const material_a_1 = ['塑膠粒、色母','普通式BB(COMMON)','分隔式BB(APART)','普通式BB-PCB','分隔式BB-PCB','普通式BB-KSP','分隔式BB-KSP','盒子式BOBBIN','盒子式COVER','抽式BOBBIN','抽式COVER','尼龍套、絕緣墊片','蓋子(網蓋、PT保護蓋)','支架、CHASSIS、CASE、底座、DOOR) 、間隔柱、銘板、腳墊','搖桿、滾子、插梢、輪','電源開關箱、輸入座','夾線槽、束線帶','護線環、固定扣(座)、櫬套、線材標示牌','端子板、補償片','把手、按鈕、開關','內外層式BB-內層P','內外層式BB-外層S','裝飾板、條、框、帶','KEYBOARD OVERLAY','LENS 透鏡','防水塞、滑槽,RING','其他(三通、由任)','雜項BOBBIN','SHEET PVC','MIRROR 鏡子','FORMER 玻璃纖維線軸','DAMPER 緩衝器','毛氈','球網、織布扣合','乒乓球','圍布','水槽'
];
const material_a_2 = ['固定用','稀釋用','硬化促進用','清潔用','塗裝用','散熱用','助焊用','COATING用','乾燥劑、防潮用','捺印用','防水/散熱','填充','營養液','其他'];
const material_b_1 = [
'ZYTEL NYLON RESIN 101L(N66)',
'ZYTEL 70G33L, 6410G5, 6210G6',
'FR-PET',
'VALOX THERMOPLASTIC',
'POPLYESTER (DR-48)',
'LEXAN POLYCARBONATE RESIN',
'(P.C)',
'NORYL RESIN (N190J-7002)',
' (CFN3J-8007)',
'POLYCARBONATE MAKROLON',
'NO.6870',
'PHENLOIC MOLDING POWDER',
'(電木)',
'P.V.C',
'POLYPHENYLENE SULFIDE',
'(HW搖桿)',
'ABS',
'ACRYLICX, STYRENE-METHYL',
'METHACRYLATE',
'POLYDROPYLENE(聚丙稀)',
'RUBBER, EVA',
'DURACON(塑膠鋼)、POM',
'其他,P.B.T',
'FLAME RETARDANT',
'POLYPROPYLENE SHEET',
'FRPP 301-18(FORMEX-18)',
'NORYL PPHOX SE-100 (F), AS',
'SPONGE(泡棉)',
'PP2654',
'MG-0033N',
'CM3001G-30',
'GFRP/CFRP',
'TEFLON',
'HPS',
'PC/ABS',
'VALOX M7002'
];
const material_b_2 =[
'凡立水、腊、樹脂',
'固定劑、熱溶膠、膠粉',
'稀釋劑',
'硬化促進劑',
'甲苯、汽油、香蕉水',
'剝離劑',
'凡士林、離形劑',
'隔離膠、靜電劑',
'潤滑油、防銹油',
'油漆、噴漆、烤漆',
'矽油膏',
'助焊劑',
'氣體 ',
'防焊劑、',
'MTL CONATHANE',
'REDUCER (催化劑)',
'SILICA GEL (乾燥劑)',
'墨水',
'碳',
'牛油',
'其他',
'營養液/肥料',
'其他'
];
return (
<div> material_5
<div>
<input type="file" onChange={this.upload}/>
</div>
</div>
);
}
}
|
node_modules/native-base/Components/Widgets/ProgressBar.android.js | tedsf/tiptap | /* @flow */
'use strict';
import React from 'react';
import ProgressBar from "ProgressBarAndroid";
import NativeBaseComponent from '../Base/NativeBaseComponent';
import computeProps from '../../Utils/computeProps';
export default class SpinnerNB extends NativeBaseComponent {
prepareRootProps() {
var type = {
height: 40
}
var defaultProps = {
style: type
}
return computeProps(this.props, defaultProps);
}
render() {
return(
<ProgressBar {...this.prepareRootProps()} styleAttr = "Horizontal"
indeterminate = {false} progress={this.props.progress ? this.props.progress/100 : 0.5}
color={this.props.color ? this.props.color : this.props.inverse ? this.getTheme().inverseProgressColor :
this.getTheme().defaultProgressColor} />
);
}
}
|
src/lib/plot/hint.js | jameskraus/react-vis | // Copyright (c) 2016 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
import React from 'react';
import PureRenderComponent from '../pure-render-component';
import {getAttributeFunctor} from '../utils/scales-utils';
const ORIENTATION_AUTO = 'auto';
const ORIENTATION_TOPLEFT = 'topleft';
const ORIENTATION_BOTTOMLEFT = 'bottomleft';
const ORIENTATION_TOPRIGHT = 'topright';
const ORIENTATION_BOTTOMRIGHT = 'bottomright';
/**
* Default format function for the value.
* @param {Object} value Value.
* @returns {Array} title-value pairs.
*/
function defaultFormat(value) {
return Object.keys(value).map(function getProp(key) {
return {title: key, value: value[key]};
});
}
class Hint extends PureRenderComponent {
static get propTypes() {
return {
marginTop: React.PropTypes.number,
marginLeft: React.PropTypes.number,
innerWidth: React.PropTypes.number,
innerHeight: React.PropTypes.number,
scales: React.PropTypes.object,
value: React.PropTypes.object,
format: React.PropTypes.func,
orientation: React.PropTypes.oneOf([
ORIENTATION_AUTO,
ORIENTATION_BOTTOMLEFT,
ORIENTATION_BOTTOMRIGHT,
ORIENTATION_TOPLEFT,
ORIENTATION_TOPRIGHT
])
};
}
static get defaultProps() {
return {
format: defaultFormat,
orientation: ORIENTATION_AUTO
};
}
/**
* Get the right coordinate of the hint.
* @param {number} x X.
* @returns {{right: *}} Mixin.
* @private
*/
_getCSSRight(x) {
const {
innerWidth,
marginRight} = this.props;
return {
right: `${marginRight + innerWidth - x}px`
};
}
/**
* Get the left coordinate of the hint.
* @param {number} x X.
* @returns {{left: *}} Mixin.
* @private
*/
_getCSSLeft(x) {
const {marginLeft} = this.props;
return {
left: `${marginLeft + x}px`
};
}
/**
* Get the bottom coordinate of the hint.
* @param {number} y Y.
* @returns {{bottom: *}} Mixin.
* @private
*/
_getCSSBottom(y) {
const {
innerHeight,
marginBottom} = this.props;
return {
bottom: `${marginBottom + innerHeight - y}px`
};
}
/**
* Get the top coordinate of the hint.
* @param {number} y Y.
* @returns {{top: *}} Mixin.
* @private
*/
_getCSSTop(y) {
const {marginTop} = this.props;
return {
top: `${marginTop + y}px`
};
}
/**
* Convert the "automatic" orientation to the real one depending on the values
* of x and y.
* @param {number} x X value.
* @param {number} y Y value.
* @returns {string} Orientation.
* @private
*/
_getOrientationFromAuto(x, y) {
const {
innerWidth,
innerHeight} = this.props;
if (x > innerWidth / 2) {
if (y > innerHeight / 2) {
return ORIENTATION_TOPLEFT;
}
return ORIENTATION_BOTTOMLEFT;
}
if (y > innerHeight / 2) {
return ORIENTATION_TOPRIGHT;
}
return ORIENTATION_BOTTOMRIGHT;
}
/**
* Get a CSS mixin for a proper positioning of the element.
* @param {string} orientation Orientation.
* @param {number} x X position.
* @param {number} y Y position.
* @returns {Object} Object, that may contain `left` or `right, `top` or
* `bottom` properties.
* @private
*/
_getOrientationStyle(orientation, x, y) {
let xCSS;
let yCSS;
if (orientation === ORIENTATION_BOTTOMLEFT ||
orientation === ORIENTATION_BOTTOMRIGHT) {
yCSS = this._getCSSTop(y);
} else {
yCSS = this._getCSSBottom(y);
}
if (orientation === ORIENTATION_TOPLEFT ||
orientation === ORIENTATION_BOTTOMLEFT) {
xCSS = this._getCSSRight(x);
} else {
xCSS = this._getCSSLeft(x);
}
return {
...xCSS,
...yCSS
};
}
/**
* Get the class name from orientation value.
* @param {string} orientation Orientation.
* @returns {string} Class name.
* @private
*/
_getOrientationClassName(orientation) {
return `rv-hint--orientation-${orientation}`;
}
/**
* Get the position for the hint and the appropriate class name.
* @returns {{style: Object, className: string}} Style and className for the
* hint.
* @private
*/
_getPositionInfo() {
const {
value,
orientation: initialOrientation} = this.props;
const x = getAttributeFunctor(this.props, 'x')(value);
const y = getAttributeFunctor(this.props, 'y')(value);
const orientation = initialOrientation === ORIENTATION_AUTO ?
this._getOrientationFromAuto(x, y) : initialOrientation;
return {
style: this._getOrientationStyle(orientation, x, y),
className: this._getOrientationClassName(orientation)
};
}
render() {
const {
value,
format,
children} = this.props;
const {style, className} = this._getPositionInfo();
return (
<div
className={`rv-hint ${className}`}
style={{
... style,
position: 'absolute'
}}>
{children ?
children :
<div className="rv-hint__content">
{format(value).map((formattedProp, i) =>
<div key={`rv-hint${i}`}>
<span className="rv-hint__title">{formattedProp.title}</span>
{': '}
<span className="rv-hint__value">{formattedProp.value}</span>
</div>
)}
</div>
}
</div>
);
}
}
Hint.displayName = 'Hint';
export default Hint;
|
src/components/UserList/UserList.js | Pamplemaus/raincloud | import React from 'react';
import UserItem from '../UserItem/UserItem';
import styles from './UserList.scss';
const UserList = ({ users, removeUser, togglePlaylist }) => {
return(
<div className={styles.userlist}>
{ users.map((user) => (
<UserItem key={user.id} selected={user.selected} image={user.avatar_url}
username={user.username} removeUser={removeUser} togglePlaylist={togglePlaylist}/>
)) }
</div>
);
};
export default UserList;
|
frontend/src/components/common/pagination.js | unicef/un-partner-portal |
import React, { Component } from 'react';
import withStyles from 'material-ui/styles/withStyles';
import IconButton from 'material-ui/IconButton';
import Input from 'material-ui/Input';
import { MenuItem } from 'material-ui/Menu';
import Select from 'material-ui/Select';
import Toolbar from 'material-ui/Toolbar';
import Typography from 'material-ui/Typography';
import KeyboardArrowLeft from 'material-ui-icons/KeyboardArrowLeft';
import KeyboardArrowRight from 'material-ui-icons/KeyboardArrowRight';
export const styles = theme => ({
root: {
// Increase the specificity to override TableCell.
'&:last-child': {
padding: 0,
},
},
toolbar: {
height: 56,
minHeight: 56,
paddingRight: 2,
},
spacer: {
flex: '1 1 100%',
},
caption: {
flexShrink: 0,
},
selectRoot: {
marginRight: theme.spacing.unit * 4,
},
select: {
marginLeft: theme.spacing.unit,
width: 34,
textAlign: 'right',
paddingRight: 22,
color: theme.palette.text.secondary,
height: 32,
lineHeight: '32px',
},
actions: {
flexShrink: 0,
color: theme.palette.text.secondary,
marginLeft: theme.spacing.unit * 2.5,
},
});
class Pagination extends Component {
constructor() {
super();
this.handleBackButtonClick = this.handleBackButtonClick.bind(this);
this.handleNextButtonClick = this.handleNextButtonClick.bind(this);
}
componentWillReceiveProps({ count, onChangePage, rowsPerPage }) {
const newLastPage = Math.max(0, Math.ceil(count / rowsPerPage) - 1);
}
handleBackButtonClick(event) {
this.props.onChangePage(event, this.props.page - 1);
}
handleNextButtonClick(event) {
this.props.onChangePage(event, this.props.page + 1);
}
render() {
const {
classes,
colSpan: colSpanProp,
count,
labelDisplayedRows,
labelRowsPerPage,
onChangePage,
onChangeRowsPerPage,
page,
rowsPerPage,
rowsPerPageOptions,
...other
} = this.props;
let colSpan;
return (
<div className={classes.root} colSpan={colSpan} {...other}>
<Toolbar className={classes.toolbar}>
<div className={classes.spacer} />
<Typography type="caption" className={classes.caption}>
{labelRowsPerPage}
</Typography>
<Select
classes={{ root: classes.selectRoot, select: classes.select }}
input={<Input disableUnderline />}
value={rowsPerPage}
onChange={(event) => { onChangeRowsPerPage(event); }}
>
{rowsPerPageOptions.map(rowsPerPageOption => (
<MenuItem key={rowsPerPageOption} value={rowsPerPageOption}>
{rowsPerPageOption}
</MenuItem>
))}
</Select>
<Typography type="caption" className={classes.caption}>
{labelDisplayedRows({
from: count === 0 ? 0 : (page - 1) * rowsPerPage + 1,
to: Math.min(count, (page) * rowsPerPage),
count,
page,
})}
</Typography>
<div className={classes.actions}>
<IconButton onClick={this.handleBackButtonClick} disabled={page === 1}>
<KeyboardArrowLeft />
</IconButton>
<IconButton
onClick={this.handleNextButtonClick}
disabled={page >= Math.ceil(count / rowsPerPage)}
>
<KeyboardArrowRight />
</IconButton>
</div>
</Toolbar>
</div>
);
}
}
Pagination.defaultProps = {
labelRowsPerPage: 'Items per page:',
labelDisplayedRows: ({ from, to, count }) => `${from}-${to} of ${count}`,
rowsPerPageOptions: [5, 10, 15],
};
export default withStyles(styles, { name: 'Pagination' })(Pagination);
|
src/App.js | MichaelKohler/where | import React from 'react';
import Overview from './Overview';
import Footer from './Footer';
import './scss/app.scss';
const App = () => {
return (
<div>
<Overview />
<Footer />
</div>
);
};
export default App;
|
src/Parser/DeathKnight/Shared/RuneDetails.js | hasseboulen/WoWAnalyzer | import React from 'react';
import { Scatter } from 'react-chartjs-2';
import Analyzer from 'Parser/Core/Analyzer';
import Tab from 'Main/Tab';
import { formatDuration } from 'common/format';
import RuneBreakdown from './RuneBreakdown';
import RuneTracker from './RuneTracker';
class RuneDetails extends Analyzer {
static dependencies = {
runeTracker: RuneTracker,
};
formatLabel(number){
return formatDuration(number, 0);
}
render() {
const labels = Array.from({length: Math.ceil(this.owner.fightDuration / 1000)}, (x, i) => i);
const runeData = {
labels: labels,
datasets: [{
label: 'Runes',
data: this.runeTracker.runesReady,
backgroundColor: 'rgba(196, 31, 59, 0)',
borderColor: 'rgb(196, 31, 59)',
borderWidth: 2,
pointStyle: 'line',
}],
};
const chartOptions = {
showLines: true,
elements: {
point: { radius: 0 },
line: {
tension: 0,
skipNull: true,
},
},
scales: {
xAxes: [{
labelString: 'Time',
ticks: {
fontColor: '#ccc',
callback: this.formatLabel,
beginAtZero: true,
stepSize: 10,
max: this.owner.fightDuration / 1000,
},
}],
yAxes: [{
labelString: 'Runes',
ticks: {
fontColor: '#ccc',
beginAtZero: true,
},
}],
},
};
return (
<div>
<Scatter
data={runeData}
options={chartOptions}
height={100}
width={300}
/>
<RuneBreakdown
tracker={this.runeTracker}
showSpenders={true}
/>
</div>
);
}
tab() {
return {
title: 'Rune usage',
url: 'rune-usage',
render: () => (
<Tab title="Rune usage breakdown">
{this.render()}
</Tab>
),
};
}
}
export default RuneDetails;
|
src/svg-icons/device/usb.js | andrejunges/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let DeviceUsb = (props) => (
<SvgIcon {...props}>
<path d="M15 7v4h1v2h-3V5h2l-3-4-3 4h2v8H8v-2.07c.7-.37 1.2-1.08 1.2-1.93 0-1.21-.99-2.2-2.2-2.2-1.21 0-2.2.99-2.2 2.2 0 .85.5 1.56 1.2 1.93V13c0 1.11.89 2 2 2h3v3.05c-.71.37-1.2 1.1-1.2 1.95 0 1.22.99 2.2 2.2 2.2 1.21 0 2.2-.98 2.2-2.2 0-.85-.49-1.58-1.2-1.95V15h3c1.11 0 2-.89 2-2v-2h1V7h-4z"/>
</SvgIcon>
);
DeviceUsb = pure(DeviceUsb);
DeviceUsb.displayName = 'DeviceUsb';
DeviceUsb.muiName = 'SvgIcon';
export default DeviceUsb;
|
actor-apps/app-web/src/app/components/dialog/ComposeSection.react.js | yangchenghu/actor-platform | /*
* Copyright (C) 2015 Actor LLC. <https://actor.im>
*/
import _ from 'lodash';
import React from 'react';
import classnames from 'classnames';
import ReactMixin from 'react-mixin';
import addons from 'react/addons';
const {addons: { PureRenderMixin }} = addons;
import ActorClient from 'utils/ActorClient';
import Inputs from 'utils/Inputs';
import { KeyCodes } from 'constants/ActorAppConstants';
import MessageActionCreators from 'actions/MessageActionCreators';
import ComposeActionCreators from 'actions/ComposeActionCreators';
import GroupStore from 'stores/GroupStore';
import PreferencesStore from 'stores/PreferencesStore';
import ComposeStore from 'stores/ComposeStore';
import AvatarItem from 'components/common/AvatarItem.react';
import MentionDropdown from 'components/common/MentionDropdown.react';
import EmojiDropdown from 'components/common/EmojiDropdown.react';
let getStateFromStores = () => {
return {
text: ComposeStore.getText(),
profile: ActorClient.getUser(ActorClient.getUid()),
sendByEnter: PreferencesStore.isSendByEnterEnabled(),
mentions: ComposeStore.getMentions()
};
};
@ReactMixin.decorate(PureRenderMixin)
class ComposeSection extends React.Component {
static propTypes = {
peer: React.PropTypes.object.isRequired
};
constructor(props) {
super(props);
this.state = _.assign({
isEmojiDropdownShow: false
}, getStateFromStores());
GroupStore.addChangeListener(this.onChange);
ComposeStore.addChangeListener(this.onChange);
PreferencesStore.addListener(this.onChange);
}
componentWillUnmount() {
GroupStore.removeChangeListener(this.onChange);
ComposeStore.removeChangeListener(this.onChange);
}
onChange = () => {
this.setState(getStateFromStores());
};
onMessageChange = event => {
const text = event.target.value;
const { peer } = this.props;
ComposeActionCreators.onTyping(peer, text, this.getCaretPosition());
};
onKeyDown = event => {
const { mentions, sendByEnter } = this.state;
if (mentions === null) {
if (sendByEnter === true) {
if (event.keyCode === KeyCodes.ENTER && !event.shiftKey) {
event.preventDefault();
this.sendTextMessage();
}
} else {
if (event.keyCode === KeyCodes.ENTER && event.metaKey) {
event.preventDefault();
this.sendTextMessage();
}
}
}
};
sendTextMessage = () => {
const { text } = this.state;
const { peer } = this.props;
if (text.trim().length !== 0) {
MessageActionCreators.sendTextMessage(peer, text);
}
ComposeActionCreators.cleanText();
};
onSendFileClick = () => {
const fileInput = React.findDOMNode(this.refs.composeFileInput);
fileInput.click();
};
onSendPhotoClick = () => {
const photoInput = React.findDOMNode(this.refs.composePhotoInput);
photoInput.accept = 'image/*';
photoInput.click();
};
onFileInputChange = () => {
const fileInput = React.findDOMNode(this.refs.composeFileInput);
MessageActionCreators.sendFileMessage(this.props.peer, fileInput.files[0]);
this.resetSendFileForm();
};
onPhotoInputChange = () => {
console.debug('onPhotoInputChange');
const photoInput = React.findDOMNode(this.refs.composePhotoInput);
MessageActionCreators.sendPhotoMessage(this.props.peer, photoInput.files[0]);
this.resetSendFileForm();
};
resetSendFileForm = () => {
const form = React.findDOMNode(this.refs.sendFileForm);
form.reset();
};
onPaste = event => {
let preventDefault = false;
_.forEach(event.clipboardData.items, (item) => {
if (item.type.indexOf('image') !== -1) {
preventDefault = true;
MessageActionCreators.sendClipboardPhotoMessage(this.props.peer, item.getAsFile());
}
}, this);
if (preventDefault) {
event.preventDefault();
}
};
onMentionSelect = (mention) => {
const { peer } = this.props;
const { text } = this.state;
ComposeActionCreators.insertMention(peer, text, this.getCaretPosition(), mention);
React.findDOMNode(this.refs.area).focus();
};
onMentionClose = () => {
ComposeActionCreators.closeMention();
};
getCaretPosition = () => {
const composeArea = React.findDOMNode(this.refs.area);
const selection = Inputs.getInputSelection(composeArea);
return selection.start;
};
onEmojiDropdownSelect = (emoji) => {
ComposeActionCreators.insertEmoji(this.state.text, this.getCaretPosition(), emoji);
React.findDOMNode(this.refs.area).focus();
};
onEmojiDropdownClose = () => this.setState({isEmojiDropdownShow: false});
onEmojiShowClick = () => this.setState({isEmojiDropdownShow: true});
render() {
const { text, profile, mentions, isEmojiDropdownShow } = this.state;
const emojiOpenerClassName = classnames('emoji-opener material-icons hide', {
'emoji-opener--active': isEmojiDropdownShow
});
return (
<section className="compose" onPaste={this.onPaste}>
<MentionDropdown mentions={mentions}
onSelect={this.onMentionSelect}
onClose={this.onMentionClose}/>
<EmojiDropdown isOpen={isEmojiDropdownShow}
onSelect={this.onEmojiDropdownSelect}
onClose={this.onEmojiDropdownClose}/>
<i className={emojiOpenerClassName}
onClick={this.onEmojiShowClick}>insert_emoticon</i>
<AvatarItem className="my-avatar"
image={profile.avatar}
placeholder={profile.placeholder}
title={profile.name}/>
<textarea className="compose__message"
onChange={this.onMessageChange}
onKeyDown={this.onKeyDown}
value={text}
ref="area"/>
<footer className="compose__footer row">
<button className="button attachment" onClick={this.onSendFileClick}>
<i className="material-icons">attachment</i> Send file
</button>
<button className="button attachment" onClick={this.onSendPhotoClick}>
<i className="material-icons">photo_camera</i> Send photo
</button>
<span className="col-xs"></span>
<button className="button button--lightblue" onClick={this.sendTextMessage}>Send</button>
</footer>
<form className="compose__hidden" ref="sendFileForm">
<input ref="composeFileInput" onChange={this.onFileInputChange} type="file"/>
<input ref="composePhotoInput" onChange={this.onPhotoInputChange} type="file"/>
</form>
</section>
);
}
}
export default ComposeSection;
|
src/components/SocialIcon/SocialIcon.js | denichodev/personal-web | import React from 'react';
import PropTypes from 'prop-types';
import './SocialIcon.css';
const SocialIcon = ({ to, className }) => {
return (
<div>
<a href={to} target="_blank" rel="noreferrer noopener">
<i className={`social-icon centered ${className}`} />
</a>
</div>
);
};
SocialIcon.propTypes = {
to: PropTypes.string.isRequired,
className: PropTypes.string.isRequired
};
export default SocialIcon;
|
src/svg-icons/image/camera-front.js | ngbrown/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let ImageCameraFront = (props) => (
<SvgIcon {...props}>
<path d="M10 20H5v2h5v2l3-3-3-3v2zm4 0v2h5v-2h-5zM12 8c1.1 0 2-.9 2-2s-.9-2-2-2-1.99.9-1.99 2S10.9 8 12 8zm5-8H7C5.9 0 5 .9 5 2v14c0 1.1.9 2 2 2h10c1.1 0 2-.9 2-2V2c0-1.1-.9-2-2-2zM7 2h10v10.5c0-1.67-3.33-2.5-5-2.5s-5 .83-5 2.5V2z"/>
</SvgIcon>
);
ImageCameraFront = pure(ImageCameraFront);
ImageCameraFront.displayName = 'ImageCameraFront';
ImageCameraFront.muiName = 'SvgIcon';
export default ImageCameraFront;
|
PeerAI/index.ios.js | peerism/peer.ai | import React, { Component } from 'react';
import { AppRegistry } from 'react-native';
import MainApp from './src/MainApp';
AppRegistry.registerComponent('PeerAI', () => MainApp);
|
src/svg-icons/action/card-travel.js | ichiohta/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let ActionCardTravel = (props) => (
<SvgIcon {...props}>
<path d="M20 6h-3V4c0-1.11-.89-2-2-2H9c-1.11 0-2 .89-2 2v2H4c-1.11 0-2 .89-2 2v11c0 1.11.89 2 2 2h16c1.11 0 2-.89 2-2V8c0-1.11-.89-2-2-2zM9 4h6v2H9V4zm11 15H4v-2h16v2zm0-5H4V8h3v2h2V8h6v2h2V8h3v6z"/>
</SvgIcon>
);
ActionCardTravel = pure(ActionCardTravel);
ActionCardTravel.displayName = 'ActionCardTravel';
ActionCardTravel.muiName = 'SvgIcon';
export default ActionCardTravel;
|
src/components/bottomBar.item.js | pcyan/dva-example-rn | import React, { Component } from 'react';
import {
StyleSheet,
Text,
View,
Image,
} from 'react-native';
import { IconToggle } from 'react-native-material-design';
const NORMAL_COLOR = '#2b2b2b';
const SELECTED_COLOR = '#006eff';
class Item extends Component {
constructor(props) {
super(props);
let { onPress, selectedColor, normalColor, tabImage, tabText, isSelected } = props;
if (!selectedColor) {
selectedColor = SELECTED_COLOR;
}
if (!normalColor) {
normalColor = NORMAL_COLOR;
}
if (!tabText) {
tabText = '';
}
if (!isSelected) {
isSelected = false;
}
this.state = {
onPress,
selectedColor,
normalColor,
tabImage,
tabText,
isSelected,
};
}
render() {
const { onPress, selectedColor, normalColor, tabImage, tabText } = this.state;
return (
<IconToggle color="paperGrey900" style={{ padding: 4 }} onPress={onPress}>
<View style={styles.item}>
<Image
style={styles.itemImage}
tintColor={this.props.isSelected ? selectedColor : normalColor}
source={tabImage}
/>
<Text style={styles.itemText}>{tabText}</Text>
</View>
</IconToggle>
);
}
}
const styles = StyleSheet.create({
item: {
minWidth: 60,
flexDirection: 'column',
justifyContent: 'center',
alignItems: 'center',
},
itemText: {
fontSize: 14,
color: NORMAL_COLOR,
},
itemImage: {
height: 24,
width: 24,
},
});
export default Item;
|
examples/with-firebase-functions/src/server.js | jaredpalmer/react-production-starter | import App from './App';
import React from 'react';
import express from 'express';
import { renderToString } from 'react-dom/server';
const assets = require(process.env.RAZZLE_ASSETS_MANIFEST);
const server = express();
server
.disable('x-powered-by')
.use(express.static(process.env.RAZZLE_PUBLIC_DIR))
.get('/*', (req, res) => {
const markup = renderToString(<App />);
res.send(
`<!doctype html>
<html lang="">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta charSet='utf-8' />
<title>Welcome to Razzle</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
${assets.client.css
? `<link rel="stylesheet" href="${assets.client.css}">`
: ''}
${process.env.NODE_ENV === 'production'
? `<script src="${assets.client.js}" defer></script>`
: `<script src="${assets.client.js}" defer crossorigin></script>`}
</head>
<body>
<div id="root">${markup}</div>
</body>
</html>`
);
});
export default server;
|
docs/app/Examples/collections/Table/Variations/TableExampleTextAlign.js | clemensw/stardust | import React from 'react'
import { Table } from 'semantic-ui-react'
const TableExampleTextAlign = () => {
return (
<Table striped>
<Table.Header>
<Table.Row>
<Table.HeaderCell>Name</Table.HeaderCell>
<Table.HeaderCell>Status</Table.HeaderCell>
<Table.HeaderCell textAlign='right'>Notes</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
<Table.Row textAlign='center'>
<Table.Cell>John</Table.Cell>
<Table.Cell>Approved</Table.Cell>
<Table.Cell textAlign='right'>None</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>Jamie</Table.Cell>
<Table.Cell>Approved</Table.Cell>
<Table.Cell textAlign='right'>Requires call</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>Jill</Table.Cell>
<Table.Cell>Denied</Table.Cell>
<Table.Cell textAlign='right'>None</Table.Cell>
</Table.Row>
</Table.Body>
</Table>
)
}
export default TableExampleTextAlign
|
src/components/Header/Header.js | rickyduck/pp-frontend | import React from 'react'
import { IndexLink, Link } from 'react-router'
import './Header.scss'
export const Header = () => (
<div>
</div>
)
export default Header
|
app/components/App.js | erlswtshrt/react-es6-boilerplate | import React from 'react';
class App extends React.Component {
render() {
return (
<div>
{this.props.children}
</div>
);
}
}
export default App; |
src/index.js | hartzis/react-redux | import React from 'react';
import createAll from './components/createAll';
export const { Provider, connect } = createAll(React);
|
frontend/src/Calendar/Legend/LegendItem.js | lidarr/Lidarr | import classNames from 'classnames';
import PropTypes from 'prop-types';
import React from 'react';
import titleCase from 'Utilities/String/titleCase';
import styles from './LegendItem.css';
function LegendItem(props) {
const {
name,
status,
tooltip,
colorImpairedMode
} = props;
return (
<div
className={classNames(
styles.legendItem,
styles[status],
colorImpairedMode && 'colorImpaired'
)}
title={tooltip}
>
{name ? name : titleCase(status)}
</div>
);
}
LegendItem.propTypes = {
name: PropTypes.string,
status: PropTypes.string.isRequired,
tooltip: PropTypes.string.isRequired,
colorImpairedMode: PropTypes.bool.isRequired
};
export default LegendItem;
|
src/svg-icons/action/offline-pin.js | tan-jerene/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let ActionOfflinePin = (props) => (
<SvgIcon {...props}>
<path d="M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10 10-4.5 10-10S17.5 2 12 2zm5 16H7v-2h10v2zm-6.7-4L7 10.7l1.4-1.4 1.9 1.9 5.3-5.3L17 7.3 10.3 14z"/>
</SvgIcon>
);
ActionOfflinePin = pure(ActionOfflinePin);
ActionOfflinePin.displayName = 'ActionOfflinePin';
ActionOfflinePin.muiName = 'SvgIcon';
export default ActionOfflinePin;
|
admin/client/components/ListFilters.js | efernandesng/keystone | import React from 'react';
import filterComponents from '../filters';
import CurrentListStore from '../stores/CurrentListStore';
import Popout from './Popout';
import { Pill } from 'elemental';
const Filter = React.createClass({
propTypes: {
filter: React.PropTypes.object.isRequired
},
getInitialState () {
return {
isOpen: false
};
},
open () {
this.setState({
isOpen: true,
filterValue: this.props.filter.value
});
},
close () {
this.setState({
isOpen: false
});
},
updateValue (filterValue) {
this.setState({
filterValue: filterValue
});
},
updateFilter (e) {
CurrentListStore.setFilter(this.props.filter.field.path, this.state.filterValue);
this.close();
e.preventDefault();
},
removeFilter () {
CurrentListStore.clearFilter(this.props.filter.field.path);
},
render () {
let { filter } = this.props;
let filterId = `activeFilter__${filter.field.path}`;
let FilterComponent = filterComponents[filter.field.type];
return (
<span>
<Pill label={filter.field.label} onClick={this.open} onClear={this.removeFilter} type="primary" id={filterId} showClearButton />
<Popout isOpen={this.state.isOpen} onCancel={this.close} relativeToID={filterId}>
<form onSubmit={this.updateFilter}>
<Popout.Header title="Edit Filter" />
<Popout.Body>
<FilterComponent field={filter.field} filter={this.state.filterValue} onChange={this.updateValue} />
</Popout.Body>
<Popout.Footer
ref="footer"
primaryButtonIsSubmit
primaryButtonLabel="Apply"
secondaryButtonAction={this.close}
secondaryButtonLabel="Cancel" />
</form>
</Popout>
</span>
);
}
});
const ListFilters = React.createClass({
getInitialState () {
return this.getStateFromStore();
},
componentDidMount () {
CurrentListStore.addChangeListener(this.updateStateFromStore);
},
componentWillUnmount () {
CurrentListStore.removeChangeListener(this.updateStateFromStore);
},
updateStateFromStore () {
this.setState(this.getStateFromStore());
},
getStateFromStore () {
return {
filters: CurrentListStore.getActiveFilters()
};
},
clearAllFilters () {
CurrentListStore.clearAllFilters();
},
render () {
if (!this.state.filters.length) return <div />;
let currentFilters = this.state.filters.map((filter, i) => {
return (
<Filter key={'f' + i} filter={filter} />
);
});
// append the clear button
if (currentFilters.length > 1) {
currentFilters.push(<Pill key="listFilters__clear" label="Clear All" onClick={this.clearAllFilters} />);
}
return (
<div className="ListFilters mb-2">
{currentFilters}
</div>
);
}
});
module.exports = ListFilters;
|
src/routes/Home/components/Home/Home-Devs.js | Ryana513/ccproject | import React from 'react'
import Paper from 'material-ui/Paper'
import ryanj from '../../assets/ryanj.jpg'
import drew from '../../assets/drew.jpg'
import sdg from '../../assets/sdg.jpg'
import ryanW from '../../assets/ryanW.jpg'
import bghero from '../../assets/bg-hero-online.jpg'
// import { BrowserRouter as NavLink } from "react-router-dom";
const style = {
height: 212,
width: 212,
margin: 22,
textAlign: 'center',
display: 'inline-block',
border: '15px solid teal',
offset: 1,
div: {
margin: 'auto',
width: '98%',
padding: 10,
backgroundImage: "url('../../assets/bg-hero-online.jpg')"
}
}
const pic = { borderRadius: 85 }
const devPic = img => {
return <img style={pic} width={200} height={200} src={img} />
}
export const HomeDevs = props => {
return (
<div style={style.div}>
<div className="col s5 pull-s7">
<Paper style={style} zDepth={5} circle children={devPic(ryanW)} />
<Paper style={style} zDepth={5} circle children={devPic(ryanj)} />
<Paper style={style} zDepth={5} circle children={devPic(sdg)} />
<Paper style={style} zDepth={5} circle children={devPic(drew)} />
</div>
</div>
)
}
export default HomeDevs
|
src/lists.js | Zyj163/React_learning | /**
* Created by ddn on 16/11/7.
*/
import React from 'react';
import ReactDOM from 'react-dom';
//A "key" is a special string attribute you need to include when creating lists of elements.
//并且key必须是唯一的,在一个数组中
function NumberList(props) {
const numbers = props.numbers;
const listItems = numbers.map((number, index) =>
<li key={index}>{number * 2}</li>
);
return (
<ul>{listItems}</ul>
);
}
const numbers = [1, 2, 3, 4, 5];
ReactDOM.render(
<NumberList numbers={numbers} />,
document.getElementById('root')
);
|
src/js/ui/pages/welcome/loadDiary.js | hiddentao/heartnotes | import _ from 'lodash';
import React from 'react';
import Icon from '../../components/icon';
import Button from '../../components/button';
import Loading from '../../components/loading';
import Layout from './layout';
import { connectRedux, routing } from '../../helpers/decorators';
var Component = React.createClass({
render: function() {
let activity = this.props.data.diary.loadingEntries;
let progressMsg = (
<Loading text="Loading diary" />
);
let progressMsg2 = _.get(this.props, 'data.diary.decryptEntries.progressMsg');
let loadingError = null;
if (activity.error) {
progressMsg = 'Loading diary failed!';
let msg = (
<span>{activity.error.toString()}</span>
);
loadingError = (
<div>
<div className="error">
<Icon name="exclamation-triangle" />
{msg}
</div>
<Button size="xs" color="dark" onClick={this._goBack}>Back</Button>
</div>
);
}
return (
<Layout>
<div className="load-diary">
<p>{progressMsg}</p>
<p className="progress-message">{progressMsg2}</p>
{loadingError}
</div>
</Layout>
);
},
componentDidMount: function(oldProps) {
if (!_.get(this.props, 'data.diary.diaryMgr')) {
return this.props.router.push('/welcome');
}
this.props.actions.loadEntries()
.then(() => {
this.props.router.push('/newEntry');
if (this.props.data.diary.diaryMgr.auth.isLocalType) {
this.props.actions.alertUser(
'You are using the app in local-only mode, meaning your diary ' +
'entries are stored locally within your browser. To enable cloud ' +
'sync and backup goto the settings page.',
'dialog'
);
}
});
},
_goBack: function() {
this.props.actions.closeDiary();
this.props.router.push('/welcome');
},
});
module.exports = connectRedux([
'closeDiary',
'loadEntries',
'alertUser',
])(routing()(Component));
|
src/frontend/components/survey-renderers/BSDPhonebankRSVPSurvey.js | al3x/ground-control | import React from 'react';
import Relay from 'react-relay'
import BSDSurvey from './BSDSurvey'
import {BernieColors, BernieText} from '../styles/bernie-css'
import {GoogleMapLoader, GoogleMap, Marker} from 'react-google-maps';
import {FlatButton, Paper} from 'material-ui';
import moment from 'moment';
import FontIcon from 'material-ui/lib/font-icon';
import SideBarLayout from '../SideBarLayout'
class BSDPhonebankRSVPSurvey extends React.Component {
static propTypes = {
onSubmitted : React.PropTypes.func,
initialValues: React.PropTypes.object,
survey: React.PropTypes.object
}
submit() {
this.refs.survey.refs.component.submit()
}
state = {
clickedMarker: null,
selectedEventId: null
}
handleMarkerClick(marker) {
this.setState({clickedMarker: marker})
}
selectButton(marker) {
return (
<FlatButton label='Select' style={{
...BernieText.inputLabel,
backgroundColor: BernieColors.green,
marginTop: 10,
}}
onTouchTap={(event) => {
this.setState({
clickedMarker: null,
selectedEventId: marker.eventId
})
this.refs.survey.refs.component.setFieldValue('event_id', marker.eventId)
}}
/>
)
}
deselectButton() {
return (
<FlatButton
label="Deselect"
style={{
...BernieText.inputLabel,
backgroundColor: BernieColors.red,
}}
onTouchTap={() => {
this.setState({
selectedEventId: null
})
this.refs.survey.refs.component.setFieldValue('event_id', '')
}}
/>
)
}
renderSelectedEvent() {
if (!this.state.selectedEventId)
return <div></div>
let event = this.props.interviewee.nearbyEvents.find((event) => event.eventIdObfuscated === this.state.selectedEventId)
let content = (
<div>
<p>Selected <strong>{event.name}</strong></p>
<p>on <strong>{moment(event.startDate).utcOffset(event.localUTCOffset).format('MMM D')}</strong>.</p>
</div>
)
let sideBar = (
<div>
{this.deselectButton()}
</div>
)
return (
<Paper zDepth={0} style={{
padding: '10px 10px 10px 10px',
marginTop: 10,
border: 'solid 1px ' + BernieColors.green,
minHeight: 25
}}>
<SideBarLayout
containerStyle={{
'border': 'none'
}}
sideBar={sideBar}
content={content}
contentViewStyle={{
border: 'none',
paddingRight: 10
}}
sideBarStyle={{
border: 'none',
textAlign: 'right',
marginTop: 'auto',
marginBottom: 'auto'
}}
sideBarPosition='right'
/>
</Paper>
)
}
renderMarkerDescription(marker) {
let description = <div></div>
if (!marker)
return <div></div>;
if (marker.key === 'home')
description = (
<div>
<div style={{
...BernieText.default,
fontWeight: 600,
fontSize: '1.0em'
}}>
{`${this.props.interviewee.firstName}'s home`}
</div>
</div>
)
let button = <div></div>;
if (marker.key !== 'home')
description = (
<div>
<div style={{
...BernieText.secondaryTitle,
color: BernieColors.gray,
fontSize: '1.0em'
}}>
{moment(marker.startDate).utcOffset(marker.localUTCOffset).format('h:mm A - dddd, MMM D')}
</div>
<div style={{
...BernieText.default,
fontWeight: 600,
fontSize: '1.0em'
}}>
{marker.name}
</div>
<div style={{
...BernieText.default,
fontSize: '1.0em'
}}>
<div>{marker.venueName}</div>
<div>{marker.addr1}</div>
<div>{marker.addr2}</div>
<div>Capacity: {marker.capacity}</div>
<div>Attendees: {marker.attendeesCount}</div>
{this.state.selectedEventId === marker.eventId ? this.deselectButton() : this.selectButton(marker)}
</div>
</div>
)
return (
<Paper zDepth={0} style={{
marginTop: 10,
padding: '10px 10px 10px 10px',
border: 'solid 1px ' + BernieColors.lightGray
}}>
{description}
</Paper>
)
}
getEventAddr2(event) {
let desc = ''
if (event.venueAddr2)
desc = desc + ' ' + event.venueAddr2;
if (event.venueCity)
desc = desc + ' ' + event.venueCity;
if (event.venueState)
desc = desc + ', ' + event.venueState
return desc.trim();
}
renderMap() {
let center = {
lat: this.props.interviewee.address.latitude,
lng: this.props.interviewee.address.longitude
}
let homeIcon = {
path: 'M10 20v-6h4v6h5v-8h3L12 3 2 12h3v8z',
fillColor: BernieColors.blue,
fillOpacity: 1.0,
scale: 1,
strokeColor: BernieColors.blue,
strokeWeight: 2
};
let markers = [
{
position: center,
key: 'home',
title: 'home',
name: 'Interviewee home',
icon: homeIcon
}
];
this.props.interviewee.nearbyEvents.forEach((event) => {
markers.push({
position: {
lat: event.latitude,
lng: event.longitude
},
localUTCOffset: event.localUTCOffset,
key: event.id,
title: event.name,
name: event.name,
startDate: event.startDate,
venueName: event.venueName,
addr1: event.venueAddr1,
addr2: this.getEventAddr2(event),
eventId: event.eventIdObfuscated,
capacity: event.capacity,
attendeesCount: event.attendeesCount
})
})
return (
<div style={{height: '100%', width: '100%'}}>
<GoogleMapLoader
containerElement={
<div
style={{
height: '100%',
width: '100%'
}}
/>
}
googleMapElement={
<GoogleMap
ref='map'
options={{
scrollwheel: false
}}
defaultZoom={9}
defaultCenter={center}>
{markers.map((marker, index) => {
return (
<Marker
{...marker}
onClick={this.handleMarkerClick.bind(this, marker)}
/>
);
})}
</GoogleMap>
}
/>
</div>
)
}
render() {
return (
<div>
<div style={{width: '100%', height: 200}}>
{this.renderMap()}
</div>
{this.renderSelectedEvent()}
{this.renderMarkerDescription(this.state.clickedMarker)}
<BSDSurvey
ref='survey'
survey={this.props.survey}
interviewee={this.props.interviewee}
onSubmitted={this.props.onSubmitted}
/>
</div>
)
}
}
export default Relay.createContainer(BSDPhonebankRSVPSurvey, {
initialVariables: {
type: 'phonebank'
},
fragments: {
survey: () => Relay.QL`
fragment on Survey {
${BSDSurvey.getFragment('survey')}
}
`,
interviewee: () => Relay.QL`
fragment on Person {
${BSDSurvey.getFragment('interviewee')}
firstName
email
address {
latitude
longitude
}
nearbyEvents(within:20, type:$type) {
id
eventIdObfuscated
name
startDate
localTimezone
localUTCOffset
venueName
venueAddr1
venueAddr2
venueCity
venueState
description
latitude
longitude
capacity
attendeesCount
}
}
`
}
})
|
packages/react/src/components/ContentSwitcher/next/index.js | carbon-design-system/carbon-components | /**
* Copyright IBM Corp. 2016, 2018
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/
import { settings } from 'carbon-components';
import PropTypes from 'prop-types';
import React from 'react';
import cx from 'classnames';
import { match, matches, keys } from '../../../internal/keyboard';
import { useId } from '../../../internal/useId';
import { useControllableState } from './useControllableState';
const { prefix } = settings;
// Used to manage the overall state of the ContentSwitcher
const ContentSwitcherContext = React.createContext();
// Used to keep track of position in a tablist
const ContentTabContext = React.createContext();
// Used to keep track of position in a list of tab panels
const ContentPanelContext = React.createContext();
function ContentSwitcher({
children,
defaultSelectedIndex = 0,
onChange,
selectedIndex: controlledSelectedIndex,
}) {
const baseId = useId('ccs');
// The active index is used to track the element which has focus in our tablist
const [activeIndex, setActiveIndex] = React.useState(defaultSelectedIndex);
// The selected index is used for the tab/panel pairing which is "visible"
const [selectedIndex, setSelectedIndex] = useControllableState({
value: controlledSelectedIndex,
defaultValue: defaultSelectedIndex,
onChange: (value) => {
if (onChange) {
onChange({ selectedIndex: value });
}
},
});
const value = {
baseId,
activeIndex,
setActiveIndex,
selectedIndex,
setSelectedIndex,
};
return (
<ContentSwitcherContext.Provider value={value}>
{children}
</ContentSwitcherContext.Provider>
);
}
ContentSwitcher.propTypes = {
/**
* Provide child elements to be rendered inside of the `ContentSwitcher`.
* These elements should render either `ContentTabs` or `ContentPanels`
*/
children: PropTypes.node,
/**
* Specify which content tab should be initially selected when the component
* is first rendered
*/
defaultSelectedIndex: PropTypes.number,
/**
* Provide an optional function which is called whenever the state of the
* `ContentSwitcher` changes
*/
onChange: PropTypes.func,
/**
* Control which content panel is currently selected. This puts the component
* in a controlled mode and should be used along with `onChange`
*/
selectedIndex: PropTypes.number,
};
/**
* A `ContentPanel` corresponds to a tablist in the Tabs pattern as written in
* WAI-ARIA Authoring Practices.
*
* @see https://w3c.github.io/aria-practices/#tabpanel
*/
function ContentTabs({
activation = 'automatic',
'aria-label': label,
children,
className: customClassName,
size = 'md',
...rest
}) {
const {
activeIndex,
selectedIndex,
setSelectedIndex,
setActiveIndex,
} = React.useContext(ContentSwitcherContext);
const ref = React.useRef(null);
const className = cx(customClassName, `${prefix}--content-switcher`, {
[`${prefix}--content-switcher--${size}`]: size,
});
const count = React.Children.count(children);
const tabs = [];
function onKeyDown(event) {
if (
matches(event, [keys.ArrowRight, keys.ArrowLeft, keys.Home, keys.End])
) {
const nextIndex = getNextIndex(
event,
count,
activation === 'automatic' ? selectedIndex : activeIndex
);
if (activation === 'automatic') {
setSelectedIndex(nextIndex);
} else if (activation === 'manual') {
setActiveIndex(nextIndex);
}
tabs[nextIndex].current.focus();
}
}
return (
// eslint-disable-next-line jsx-a11y/interactive-supports-focus
<div
{...rest}
aria-label={label}
ref={ref}
role="tablist"
className={className}
onKeyDown={onKeyDown}>
{React.Children.map(children, (child, index) => {
const ref = React.createRef();
tabs.push(ref);
return (
<ContentTabContext.Provider value={index}>
{React.cloneElement(child, {
ref,
})}
</ContentTabContext.Provider>
);
})}
</div>
);
}
ContentTabs.propTypes = {
/**
* Specify whether the content tab should be activated automatically or
* manually
*/
activation: PropTypes.oneOf(['automatic', 'manual']),
/**
* Provide an accessible label to be read when a user interacts with this
* component
*/
'aria-label': PropTypes.string.isRequired,
/**
* Provide child elements to be rendered inside of `ContentTabs`.
* These elements should render a `ContentTab`
*/
children: PropTypes.node,
/**
* Specify an optional className to be added to the container node
*/
className: PropTypes.string,
/**
* Specify the size of the Content Switcher. Currently supports either `sm`, 'md' (default) or 'lg` as an option.
*/
size: PropTypes.oneOf(['sm', 'md', 'lg']),
};
/**
* Get the next index for a givne keyboard event given a count of the total
* items and the current index
* @param {Event} event
* @param {number} total
* @param {number} index
* @returns {number}
*/
function getNextIndex(event, total, index) {
if (match(event, keys.ArrowRight)) {
return (index + 1) % total;
} else if (match(event, keys.ArrowLeft)) {
return (total + index - 1) % total;
} else if (match(event, keys.Home)) {
return 0;
} else if (match(event, keys.End)) {
return total - 1;
}
}
const ContentTab = React.forwardRef(function ContentTab(
{ children, ...rest },
ref
) {
const { selectedIndex, setSelectedIndex, baseId } = React.useContext(
ContentSwitcherContext
);
const index = React.useContext(ContentTabContext);
const id = `${baseId}-tab-${index}`;
const panelId = `${baseId}-tabpanel-${index}`;
const className = cx(`${prefix}--content-switcher-btn`, {
[`${prefix}--content-switcher--selected`]: selectedIndex === index,
});
return (
<button
{...rest}
aria-controls={panelId}
aria-selected={selectedIndex === index}
ref={ref}
id={id}
role="tab"
className={className}
onClick={() => {
setSelectedIndex(index);
}}
tabIndex={selectedIndex === index ? '0' : '-1'}
type="button">
{children}
</button>
);
});
ContentTab.propTypes = {
/**
* Provide child elements to be rendered inside of `ContentTab`.
* These elements must be noninteractive
*/
children: PropTypes.node,
};
/**
* Used to display all of the tab panels inside of a Content Switcher. This
* components keeps track of position in for each ContentPanel.
*
* Note: children should either be a `ContentPanel` or should render a
* `ContentPanel`. Fragments are not currently supported.
*/
function ContentPanels({ children }) {
return React.Children.map(children, (child, index) => {
return (
<ContentPanelContext.Provider value={index}>
{child}
</ContentPanelContext.Provider>
);
});
}
ContentPanels.propTypes = {
/**
* Provide child elements to be rendered inside of `ContentPanels`.
* These elements should render a `ContentPanel`
*/
children: PropTypes.node,
};
/**
* A `ContentPanel` corresponds to a tabpanel in the Tabs pattern as written in
* WAI-ARIA Authoring Practices. This component reads the selected
* index and base id from context in order to determine the correct `id` and
* display status of the component.
*
* @see https://w3c.github.io/aria-practices/#tabpanel
*/
const ContentPanel = React.forwardRef(function ContentPanel(props, ref) {
const { children, ...rest } = props;
const { selectedIndex, baseId } = React.useContext(ContentSwitcherContext);
const index = React.useContext(ContentPanelContext);
const id = `${baseId}-tabpanel-${index}`;
const tabId = `${baseId}-tab-${index}`;
// TODO: tabindex should only be 0 if no interactive content in children
return (
<div
{...rest}
aria-labelledby={tabId}
id={id}
ref={ref}
role="tabpanel"
tabIndex="0"
hidden={selectedIndex !== index}>
{children}
</div>
);
});
ContentPanel.propTypes = {
/**
* Provide child elements to be rendered inside of `ContentPanel`.
*/
children: PropTypes.node,
};
export {
ContentSwitcher,
ContentTabs,
ContentTab,
ContentPanels,
ContentPanel,
};
|
stories/typography.stories.js | buildkite/frontend | /* global module */
import React from 'react';
import PropTypes from 'prop-types';
import { storiesOf } from '@storybook/react';
const Example = function(props) {
return <div className={`my3 border-left border-${props.border || "gray"} pl4 py2`}>{props.children}</div>;
};
Example.propTypes = { children: PropTypes.node, border: PropTypes.string };
const Section = function(props) {
return (
<div className="max-width-2">
{props.children}
</div>
);
};
Section.propTypes = { children: PropTypes.node };
const combinations = () => (
<Section>
<Example>
<p className="h1 m0" data-sketch-symbol="Text/h1" data-sketch-text="Heading - h1">Pipeline Settings — h1</p>
<p className="h3 m0" data-sketch-symbol="Text/h3" data-sketch-text="Heading - h3">Manage your how your pipeline works — h3</p>
</Example>
<Example>
<p className="h2 m0" data-sketch-symbol="Text/h2" data-sketch-text="Heading - h2">Pipeline Settings — h2</p>
<p className="h4 m0" data-sketch-symbol="Text/h4" data-sketch-text="Text - h4">Manage your how your pipeline works — h4</p>
</Example>
<Example>
<p className="h3 m0" data-sketch-symbol="Text/h3" data-sketch-text="Text - h4">Pipeline Settings — h3</p>
<p className="h5 m0" data-sketch-symbol="Text/h5" data-sketch-text="Text - h5">Manage your how your pipeline works — h5</p>
</Example>
<Example>
<p className="h4 m0" data-sketch-symbol="Text/h4" data-sketch-text="Text - h4">Pipeline Settings — h4</p>
<p className="h5 m0 dark-gray" data-sketch-symbol="Text/h5 (Subdued)" data-sketch-text="Text - h5 Subdued">Manage your how your pipeline works — h5</p>
</Example>
<Example>
<p className="h5 m0" data-sketch-symbol="Text/h5" data-sketch-text="Text - h4">Pipeline Settings — h5</p>
<p className="h6 m0 dark-gray" data-sketch-symbol="Text/h6 (Subdued)" data-sketch-text="Text - h6 Subdued">Manage your how your pipeline works — h6</p>
</Example>
</Section>
);
storiesOf('Typography', module)
.add('Combinations', combinations);
storiesOf('Typography', module)
.add('Choosing Sizes', () => (
<Section>
<p className="my3">You want enough contrast between type so that the hierarchy is clear. With our type scale, a good rule of thumb is to ensure text is at least two sizes different.</p>
<p className="mt4 mb3">For example, the following lacks typographic contrast:</p>
<Example border="red">
<p className="h1 m0" title="h1">Pipeline Settings — h1</p>
<p className="h2 m0" title="h2">Manage your how your pipeline works — h2</p>
</Example>
<p className="mt4 mb3">The ideal solution is to make sure there’s two sizes between them, i.e. switch the second paragraph to a .h3:</p>
<Example border="green">
<p className="h1 m0" title="h1">Pipeline Settings — h1</p>
<p className="h3 m0" title="h2">Manage your how your pipeline works — h3</p>
</Example>
<p className="mt4 mb3">If you can’t adjust the size to have enough contrast, you can introduce colour to achieve some contrast:</p>
<Example border="green">
<p className="h1 m0">Pipeline Settings — h1</p>
<p className="h2 m0 dark-gray">Manage your how your pipeline works — h2</p>
</Example>
<p className="mt4 mb3">And finally, if size and colour can’t be adjusted, you can use weight:</p>
<Example border="green">
<p className="h1 m0 bold">Pipeline Settings — h1</p>
<p className="h2 m0">Manage your how your pipeline works — h2</p>
</Example>
<p className="my4">The general rule is to try to adjust font-size first, and then colour, and then weight.</p>
</Section>
));
export const Sketch = combinations; |
react/redux-start/react-redux-todos-review/src/components/TodoList.js | kobeCan/practices | import React from 'react';
import Todo from './Todo'
const TodoList = ({ todos, onClick }) => (
todos.map(todo => (
<Todo key={todo.id} {...todo} onClick={() => onClick(todo.id)} />
))
);
export default TodoList |
examples/basic/app.js | revolunet/cmp1 | import React, { Component } from 'react';
import ReactDOM from 'react-dom';
import Cmp1 from '../../lib/index';
class App extends Component {
click() {
alert('Roger that !');
}
render() {
return (
<div className='example'>
<h1>cmp1</h1>
<Cmp1 click={ this.click } name='Click me'/>
</div>
);
}
}
ReactDOM.render(<App/>, document.getElementById('container'));
|
ReactNativeExampleApp/node_modules/react-native/Libraries/Text/Text.js | weien/Auth0Exercise | /**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule Text
* @flow
*/
'use strict';
const NativeMethodsMixin = require('NativeMethodsMixin');
const Platform = require('Platform');
const React = require('React');
const ReactNativeViewAttributes = require('ReactNativeViewAttributes');
const StyleSheetPropType = require('StyleSheetPropType');
const TextStylePropTypes = require('TextStylePropTypes');
const Touchable = require('Touchable');
const createReactNativeComponentClass =
require('createReactNativeComponentClass');
const merge = require('merge');
const stylePropType = StyleSheetPropType(TextStylePropTypes);
const viewConfig = {
validAttributes: merge(ReactNativeViewAttributes.UIView, {
isHighlighted: true,
numberOfLines: true,
lineBreakMode: true,
allowFontScaling: true,
}),
uiViewClassName: 'RCTText',
};
/**
* A React component for displaying text.
*
* `Text` supports nesting, styling, and touch handling.
*
* In the following example, the nested title and body text will inherit the `fontFamily` from
*`styles.baseText`, but the title provides its own additional styles. The title and body will
* stack on top of each other on account of the literal newlines:
*
* ```ReactNativeWebPlayer
* import React, { Component } from 'react';
* import { AppRegistry, Text, StyleSheet } from 'react-native';
*
* class TextInANest extends Component {
* constructor(props) {
* super(props);
* this.state = {
* titleText: "Bird's Nest",
* bodyText: 'This is not really a bird nest.'
* };
* }
*
* render() {
* return (
* <Text style={styles.baseText}>
* <Text style={styles.titleText} onPress={this.onPressTitle}>
* {this.state.titleText}<br /><br />
* </Text>
* <Text numberOfLines={5}>
* {this.state.bodyText}
* </Text>
* </Text>
* );
* }
* }
*
* const styles = StyleSheet.create({
* baseText: {
* fontFamily: 'Cochin',
* },
* titleText: {
* fontSize: 20,
* fontWeight: 'bold',
* },
* });
*
* // App registration and rendering
* AppRegistry.registerComponent('TextInANest', () => TextInANest);
* ```
*/
const Text = React.createClass({
propTypes: {
/**
* Line Break mode. This can be one of the following values:
*
* - `head` - The line is displayed so that the end fits in the container and the missing text
* at the beginning of the line is indicated by an ellipsis glyph. e.g., "...wxyz"
* - `middle` - The line is displayed so that the beginning and end fit in the container and the
* missing text in the middle is indicated by an ellipsis glyph. "ab...yz"
* - `tail` - The line is displayed so that the beginning fits in the container and the
* missing text at the end of the line is indicated by an ellipsis glyph. e.g., "abcd..."
* - `clip` - Lines are not drawn past the edge of the text container.
*
* The default is `tail`.
*
* `numberOfLines` must be set in conjunction with this prop.
*
* > `clip` is working only for iOS
*/
lineBreakMode: React.PropTypes.oneOf(['head', 'middle', 'tail', 'clip']),
/**
* Used to truncate the text with an ellipsis after computing the text
* layout, including line wrapping, such that the total number of lines
* does not exceed this number.
*
* This prop is commonly used with `lineBreakMode`.
*/
numberOfLines: React.PropTypes.number,
/**
* Invoked on mount and layout changes with
*
* `{nativeEvent: {layout: {x, y, width, height}}}`
*/
onLayout: React.PropTypes.func,
/**
* This function is called on press.
*
* e.g., `onPress={() => console.log('1st')}``
*/
onPress: React.PropTypes.func,
/**
* This function is called on long press.
*
* e.g., `onLongPress={this.increaseSize}>``
*/
onLongPress: React.PropTypes.func,
/**
* Lets the user select text, to use the native copy and paste functionality.
*
* @platform android
*/
selectable: React.PropTypes.bool,
/**
* When `true`, no visual change is made when text is pressed down. By
* default, a gray oval highlights the text on press down.
*
* @platform ios
*/
suppressHighlighting: React.PropTypes.bool,
style: stylePropType,
/**
* Used to locate this view in end-to-end tests.
*/
testID: React.PropTypes.string,
/**
* Specifies whether fonts should scale to respect Text Size accessibility setting on iOS. The
* default is `true`.
*
* @platform ios
*/
allowFontScaling: React.PropTypes.bool,
/**
* When set to `true`, indicates that the view is an accessibility element. The default value
* for a `Text` element is `true`.
*
* See the
* [Accessibility guide](/react-native/docs/accessibility.html#accessible-ios-android)
* for more information.
*/
accessible: React.PropTypes.bool,
},
getDefaultProps(): Object {
return {
accessible: true,
allowFontScaling: true,
lineBreakMode: 'tail',
};
},
getInitialState: function(): Object {
return merge(Touchable.Mixin.touchableGetInitialState(), {
isHighlighted: false,
});
},
mixins: [NativeMethodsMixin],
viewConfig: viewConfig,
getChildContext(): Object {
return {isInAParentText: true};
},
childContextTypes: {
isInAParentText: React.PropTypes.bool
},
contextTypes: {
isInAParentText: React.PropTypes.bool
},
/**
* Only assigned if touch is needed.
*/
_handlers: (null: ?Object),
_hasPressHandler(): boolean {
return !!this.props.onPress || !!this.props.onLongPress;
},
/**
* These are assigned lazily the first time the responder is set to make plain
* text nodes as cheap as possible.
*/
touchableHandleActivePressIn: (null: ?Function),
touchableHandleActivePressOut: (null: ?Function),
touchableHandlePress: (null: ?Function),
touchableHandleLongPress: (null: ?Function),
touchableGetPressRectOffset: (null: ?Function),
render(): ReactElement<any> {
let newProps = this.props;
if (this.props.onStartShouldSetResponder || this._hasPressHandler()) {
if (!this._handlers) {
this._handlers = {
onStartShouldSetResponder: (): bool => {
const shouldSetFromProps = this.props.onStartShouldSetResponder &&
this.props.onStartShouldSetResponder();
const setResponder = shouldSetFromProps || this._hasPressHandler();
if (setResponder && !this.touchableHandleActivePressIn) {
// Attach and bind all the other handlers only the first time a touch
// actually happens.
for (const key in Touchable.Mixin) {
if (typeof Touchable.Mixin[key] === 'function') {
(this: any)[key] = Touchable.Mixin[key].bind(this);
}
}
this.touchableHandleActivePressIn = () => {
if (this.props.suppressHighlighting || !this._hasPressHandler()) {
return;
}
this.setState({
isHighlighted: true,
});
};
this.touchableHandleActivePressOut = () => {
if (this.props.suppressHighlighting || !this._hasPressHandler()) {
return;
}
this.setState({
isHighlighted: false,
});
};
this.touchableHandlePress = () => {
this.props.onPress && this.props.onPress();
};
this.touchableHandleLongPress = () => {
this.props.onLongPress && this.props.onLongPress();
};
this.touchableGetPressRectOffset = function(): RectOffset {
return PRESS_RECT_OFFSET;
};
}
return setResponder;
},
onResponderGrant: function(e: SyntheticEvent, dispatchID: string) {
this.touchableHandleResponderGrant(e, dispatchID);
this.props.onResponderGrant &&
this.props.onResponderGrant.apply(this, arguments);
}.bind(this),
onResponderMove: function(e: SyntheticEvent) {
this.touchableHandleResponderMove(e);
this.props.onResponderMove &&
this.props.onResponderMove.apply(this, arguments);
}.bind(this),
onResponderRelease: function(e: SyntheticEvent) {
this.touchableHandleResponderRelease(e);
this.props.onResponderRelease &&
this.props.onResponderRelease.apply(this, arguments);
}.bind(this),
onResponderTerminate: function(e: SyntheticEvent) {
this.touchableHandleResponderTerminate(e);
this.props.onResponderTerminate &&
this.props.onResponderTerminate.apply(this, arguments);
}.bind(this),
onResponderTerminationRequest: function(): bool {
// Allow touchable or props.onResponderTerminationRequest to deny
// the request
var allowTermination = this.touchableHandleResponderTerminationRequest();
if (allowTermination && this.props.onResponderTerminationRequest) {
allowTermination = this.props.onResponderTerminationRequest.apply(this, arguments);
}
return allowTermination;
}.bind(this),
};
}
newProps = {
...this.props,
...this._handlers,
isHighlighted: this.state.isHighlighted,
};
}
if (Touchable.TOUCH_TARGET_DEBUG && newProps.onPress) {
newProps = {
...newProps,
style: [this.props.style, {color: 'magenta'}],
};
}
if (this.context.isInAParentText) {
return <RCTVirtualText {...newProps} />;
} else {
return <RCTText {...newProps} />;
}
},
});
type RectOffset = {
top: number;
left: number;
right: number;
bottom: number;
}
var PRESS_RECT_OFFSET = {top: 20, left: 20, right: 20, bottom: 30};
var RCTText = createReactNativeComponentClass(viewConfig);
var RCTVirtualText = RCTText;
if (Platform.OS === 'android') {
RCTVirtualText = createReactNativeComponentClass({
validAttributes: merge(ReactNativeViewAttributes.UIView, {
isHighlighted: true,
}),
uiViewClassName: 'RCTVirtualText',
});
}
module.exports = Text;
|
examples/huge-apps/routes/Course/routes/Announcements/components/Announcements.js | mjw56/react-router | import React from 'react';
class Announcements extends React.Component {
render () {
return (
<div>
<h3>Announcements</h3>
{this.props.children || <p>Choose an announcement from the sidebar.</p>}
</div>
);
}
}
export default Announcements;
|
docs/app/Examples/collections/Grid/ResponsiveVariations/GridExampleResponsiveWidth.js | mohammed88/Semantic-UI-React | import React from 'react'
import { Grid, Image } from 'semantic-ui-react'
const GridExampleResponsiveWidth = () => (
<div>
<Grid>
<Grid.Column mobile={16} tablet={8} computer={4}>
<Image src='http://semantic-ui.com/images/wireframe/paragraph.png' />
</Grid.Column>
<Grid.Column mobile={16} tablet={8} computer={4}>
<Image src='http://semantic-ui.com/images/wireframe/paragraph.png' />
</Grid.Column>
<Grid.Column mobile={16} tablet={8} computer={4}>
<Image src='http://semantic-ui.com/images/wireframe/paragraph.png' />
</Grid.Column>
<Grid.Column mobile={16} tablet={8} computer={4}>
<Image src='http://semantic-ui.com/images/wireframe/paragraph.png' />
</Grid.Column>
<Grid.Column mobile={16} tablet={8} computer={4}>
<Image src='http://semantic-ui.com/images/wireframe/paragraph.png' />
</Grid.Column>
</Grid>
<Grid>
<Grid.Column largeScreen={2} widescreen={1}>
<Image src='http://semantic-ui.com/images/wireframe/paragraph.png' />
</Grid.Column>
<Grid.Column largeScreen={2} widescreen={1}>
<Image src='http://semantic-ui.com/images/wireframe/paragraph.png' />
</Grid.Column>
<Grid.Column largeScreen={2} widescreen={1}>
<Image src='http://semantic-ui.com/images/wireframe/paragraph.png' />
</Grid.Column>
<Grid.Column largeScreen={2} widescreen={1}>
<Image src='http://semantic-ui.com/images/wireframe/paragraph.png' />
</Grid.Column>
</Grid>
</div>
)
export default GridExampleResponsiveWidth
|
app/components/Message.js | alexbooker/pusher-realtime-chat | import React from 'react'
import Time from './Time'
const Message = React.createClass({
render () {
return (
<div className='message'>
<div className='message__top'>
<img className='message__author-avatar' src={this.props.message.user.avatarUrl} alt={this.props.message.user.username} />
<p className='message__text'>{this.props.message.text}</p>
</div>
<p className='message__time'>
<Time value={this.props.message.createdAt} />
</p>
</div>
)
}
})
export default Message
|
docs/app/Examples/elements/Icon/Groups/IconExampleCornerGroup.js | Rohanhacker/Semantic-UI-React | import React from 'react'
import { Icon } from 'semantic-ui-react'
const IconExampleCornerGroup = () => (
<Icon.Group size='huge'>
<Icon name='puzzle' />
<Icon corner name='add' />
</Icon.Group>
)
export default IconExampleCornerGroup
|
src/js/components/icons/base/BackTen.js | kylebyerly-hp/grommet | // (C) Copyright 2014-2015 Hewlett Packard Enterprise Development LP
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import classnames from 'classnames';
import CSSClassnames from '../../../utils/CSSClassnames';
import Intl from '../../../utils/Intl';
import Props from '../../../utils/Props';
const CLASS_ROOT = CSSClassnames.CONTROL_ICON;
const COLOR_INDEX = CSSClassnames.COLOR_INDEX;
export default class Icon extends Component {
render () {
const { className, colorIndex } = this.props;
let { a11yTitle, size, responsive } = this.props;
let { intl } = this.context;
const classes = classnames(
CLASS_ROOT,
`${CLASS_ROOT}-back-ten`,
className,
{
[`${CLASS_ROOT}--${size}`]: size,
[`${CLASS_ROOT}--responsive`]: responsive,
[`${COLOR_INDEX}-${colorIndex}`]: colorIndex
}
);
a11yTitle = a11yTitle || Intl.getMessage(intl, 'back-ten');
const restProps = Props.omit(this.props, Object.keys(Icon.propTypes));
return <svg {...restProps} version="1.1" viewBox="0 0 24 24" width="24px" height="24px" role="img" className={classes} aria-label={a11yTitle}><path fill="none" stroke="#000" strokeWidth="2" d="M3.11111111,7.55555556 C4.66955145,4.26701301 8.0700311,2 12,2 C17.5228475,2 22,6.4771525 22,12 C22,17.5228475 17.5228475,22 12,22 L12,22 C6.4771525,22 2,17.5228475 2,12 M2,4 L2,8 L6,8 M9,16 L9,9 L7,9.53333333 M17,12 C17,10 15.9999999,8.5 14.5,8.5 C13.0000001,8.5 12,10 12,12 C12,14 13,15.5000001 14.5,15.5 C16,15.4999999 17,14 17,12 Z M14.5,8.5 C16.9253741,8.5 17,11 17,12 C17,13 17,15.5 14.5,15.5 C12,15.5 12,13 12,12 C12,11 12.059,8.5 14.5,8.5 Z"/></svg>;
}
};
Icon.contextTypes = {
intl: PropTypes.object
};
Icon.defaultProps = {
responsive: true
};
Icon.displayName = 'BackTen';
Icon.icon = true;
Icon.propTypes = {
a11yTitle: PropTypes.string,
colorIndex: PropTypes.string,
size: PropTypes.oneOf(['xsmall', 'small', 'medium', 'large', 'xlarge', 'huge']),
responsive: PropTypes.bool
};
|
resources/apps/frontend/src/pages/attendance/index.js | johndavedecano/PHPLaravelGymManagementSystem | import React from 'react';
import Loadable from 'components/Loadable';
import {PrivateLayout} from 'components/Layouts';
import renderRoutes from './../routes';
export default {
exact: false,
auth: true,
path: '/attendance',
component: ({routes}) => {
return <PrivateLayout>{renderRoutes(routes)}</PrivateLayout>;
},
routes: [
{
exact: true,
auth: true,
path: '/attendance',
component: Loadable({
loader: () => import('./lists'),
}),
},
],
};
|
src/parser/priest/discipline/modules/features/Checklist/Module.js | FaideWW/WoWAnalyzer | import React from 'react';
import BaseChecklist from 'parser/shared/modules/features/Checklist2/Module';
import CastEfficiency from 'parser/shared/modules/CastEfficiency';
import Combatants from 'parser/shared/modules/Combatants';
import ManaValues from 'parser/shared/modules/ManaValues';
import PreparationRuleAnalyzer from 'parser/shared/modules/features/Checklist2/PreparationRuleAnalyzer';
import AlwaysBeCasting from '../AlwaysBeCasting';
import Component from './Component';
class Checklist extends BaseChecklist {
static dependencies = {
combatants: Combatants,
castEfficiency: CastEfficiency,
alwaysBeCasting: AlwaysBeCasting,
manaValues: ManaValues,
preparationRuleAnalyzer: PreparationRuleAnalyzer,
};
render() {
return (
<Component
combatant={this.combatants.selected}
castEfficiency={this.castEfficiency}
thresholds={{
...this.preparationRuleAnalyzer.thresholds,
nonHealingTimeSuggestionThresholds: this.alwaysBeCasting.nonHealingTimeSuggestionThresholds,
downtimeSuggestionThresholds: this.alwaysBeCasting.downtimeSuggestionThresholds,
manaLeft: this.manaValues.suggestionThresholds,
}}
/>
);
}
}
export default Checklist;
|
src/components/MainLayout/Header.js | waltcow/newsApp | import React from 'react';
import { Menu, Icon } from 'antd';
import { Link } from 'dva/router';
function Header({ location }) {
return (
<Menu
selectedKeys={[location.pathname]}
mode="horizontal"
theme="dark"
>
<Menu.Item key="/users">
<Link to="/users"><Icon type="bars" />Users</Link>
</Menu.Item>
<Menu.Item key="/">
<Link to="/"><Icon type="home" />Home</Link>
</Menu.Item>
<Menu.Item key="/404">
<Link to="/page-you-dont-know"><Icon type="frown-circle" />404</Link>
</Menu.Item>
<Menu.Item key="/antd">
<a href="https://github.com/dvajs/dva">dva</a>
</Menu.Item>
</Menu>
);
}
export default Header;
|
react/features/room-lock/components/RoomLockPrompt.native.js | KalinduDN/kalindudn.github.io | import React, { Component } from 'react';
import { connect } from 'react-redux';
import { Dialog } from '../../base/dialog';
import { endRoomLockRequest } from '../actions';
/**
* Implements a React Component which prompts the user for a password to lock a
* conference/room.
*/
class RoomLockPrompt extends Component {
/**
* RoomLockPrompt component's property types.
*
* @static
*/
static propTypes = {
/**
* The JitsiConference which requires a password.
*
* @type {JitsiConference}
*/
conference: React.PropTypes.object,
dispatch: React.PropTypes.func
};
/**
* Initializes a new RoomLockPrompt instance.
*
* @param {Object} props - The read-only properties with which the new
* instance is to be initialized.
*/
constructor(props) {
super(props);
// Bind event handlers so they are only bound once for every instance.
this._onCancel = this._onCancel.bind(this);
this._onSubmit = this._onSubmit.bind(this);
}
/**
* Implements React's {@link Component#render()}.
*
* @inheritdoc
* @returns {ReactElement}
*/
render() {
return (
<Dialog
bodyKey = 'dialog.passwordLabel'
onCancel = { this._onCancel }
onSubmit = { this._onSubmit }
titleKey = 'toolbar.lock' />
);
}
/**
* Notifies this prompt that it has been dismissed by cancel.
*
* @private
* @returns {boolean} True to hide this dialog/prompt; otherwise, false.
*/
_onCancel() {
// An undefined password is understood to cancel the request to lock the
// conference/room.
return this._onSubmit(undefined);
}
/**
* Notifies this prompt that it has been dismissed by submitting a specific
* value.
*
* @param {string} value - The submitted value.
* @private
* @returns {boolean} False because we do not want to hide this
* dialog/prompt as the hiding will be handled inside endRoomLockRequest
* after setting the password is resolved.
*/
_onSubmit(value) {
this.props.dispatch(endRoomLockRequest(this.props.conference, value));
return false; // Do not hide.
}
}
export default connect()(RoomLockPrompt);
|
src/components/Column/RadioButtonColumn.js | TheBurningRed/react-gridview | 'use strict';
import React from 'react';
require('styles/GridView/RadioButtonColumn.css');
let RadioButtonColumnComponent = (props) => (
<div className="radiobuttoncolumn-component">
Please edit src/components/gridView//RadioButtonColumnComponent.js to update this component!
</div>
);
RadioButtonColumnComponent.displayName = 'GridViewRadioButtonColumnComponent';
// Uncomment properties you need
// RadioButtonColumnComponent.propTypes = {};
// RadioButtonColumnComponent.defaultProps = {};
export default RadioButtonColumnComponent;
|
frontend/src/components/YoutubeVideo.js | carlosascari/opencollective-website | import React from 'react';
export default ({
video,
width='560',
height='315'
}) => {
if(!video || !video.match(/watch\?v=/)) {
return;
}
const id = video.match(/watch\?v=([^&]*)/)[1];
return (
<div className='YoutubeVideo height-100'>
<iframe
width={width}
height={height}
src={`https://www.youtube.com/embed/${id}`}
frameBorder='0'
allowFullScreen>
</iframe>
</div>
);
}
|
src/svg-icons/maps/directions-walk.js | owencm/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let MapsDirectionsWalk = (props) => (
<SvgIcon {...props}>
<path d="M13.5 5.5c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zM9.8 8.9L7 23h2.1l1.8-8 2.1 2v6h2v-7.5l-2.1-2 .6-3C14.8 12 16.8 13 19 13v-2c-1.9 0-3.5-1-4.3-2.4l-1-1.6c-.4-.6-1-1-1.7-1-.3 0-.5.1-.8.1L6 8.3V13h2V9.6l1.8-.7"/>
</SvgIcon>
);
MapsDirectionsWalk = pure(MapsDirectionsWalk);
MapsDirectionsWalk.displayName = 'MapsDirectionsWalk';
MapsDirectionsWalk.muiName = 'SvgIcon';
export default MapsDirectionsWalk;
|
src/svg-icons/action/gavel.js | ichiohta/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let ActionGavel = (props) => (
<SvgIcon {...props}>
<path d="M1 21h12v2H1zM5.245 8.07l2.83-2.827 14.14 14.142-2.828 2.828zM12.317 1l5.657 5.656-2.83 2.83-5.654-5.66zM3.825 9.485l5.657 5.657-2.828 2.828-5.657-5.657z"/>
</SvgIcon>
);
ActionGavel = pure(ActionGavel);
ActionGavel.displayName = 'ActionGavel';
ActionGavel.muiName = 'SvgIcon';
export default ActionGavel;
|
src/svg-icons/image/brightness-3.js | rhaedes/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let ImageBrightness3 = (props) => (
<SvgIcon {...props}>
<path d="M9 2c-1.05 0-2.05.16-3 .46 4.06 1.27 7 5.06 7 9.54 0 4.48-2.94 8.27-7 9.54.95.3 1.95.46 3 .46 5.52 0 10-4.48 10-10S14.52 2 9 2z"/>
</SvgIcon>
);
ImageBrightness3 = pure(ImageBrightness3);
ImageBrightness3.displayName = 'ImageBrightness3';
export default ImageBrightness3;
|
src/components/cropper-view/index.js | olofd/react-native-insta-photo-studio | import {
View,
Text,
StyleSheet,
TouchableOpacity,
Dimensions,
Image,
Animated,
ScrollView,
InteractionManager
} from 'react-native';
import React, { Component } from 'react';
import ImageCopperView from './image-cropper-view';
import BlockView from 'react-native-scroll-block-view';
import { BlurView } from 'react-native-blur';
import { AnimatedCircularProgress } from '../../react-native-circular-progress';
import ToolBar from './tool-bar';
const AnimatedBlurView = Animated.createAnimatedComponent(BlurView);
const loadingViewScale = {
inputRange: [
0, 1
],
outputRange: [1.15, 1]
};
const ACTIVE_POINTER = 'auto';
const INACTIVE_POINTER = 'none';
export default class CropperViewContainer extends Component {
constructor(props) {
super(props);
const images = [];
if (props.image) {
images.push({ loaded: false, image: props.image });
}
this.state = {
currentImageIndex: 0,
images: images,
loadingViewAnim: new Animated.Value(0)
};
}
componentWillReceiveProps(nextProps) {
const currentImage = this.state.images[this.state.currentImageIndex];
if (!currentImage || currentImage.image !== nextProps.image) {
const nextPushIndex = this.getNextPushIndex();
const cropperImageObj = this.state.images[nextPushIndex];
if (cropperImageObj && (cropperImageObj.image === nextProps.image || cropperImageObj.image.uri === nextProps.image.uri)) {
this.onPartialLoad(this.state.images[nextPushIndex], this.currentLoadingGuid);
this.onLoad(this.state.images[nextPushIndex], this.currentLoadingGuid);
} else {
this.state.images[nextPushIndex] = {
loaded: false,
image: nextProps.image
};
if (nextProps.image && nextProps.image.uri) {
this.startLoadingTimer(this.state.images.length === 1);
}
}
this.loadCircle && this.loadCircle.setAnimationValue(0);
this.setState({ currentImageIndex: nextPushIndex, isLoading: false });
}
}
startLoadingTimer(firstImage) {
const currentLoadingGuid = this.guid();
this.currentLoadingGuid = currentLoadingGuid;
setTimeout(() => {
if (this.currentLoadingGuid === currentLoadingGuid) {
this.animateLoadingView(1, undefined, false);
}
}, 350);
}
animateLoadingView(toValue, cb, instant) {
if (instant) {
this.state.loadingViewAnim.setValue(toValue);
} else {
Animated.spring(this.state.loadingViewAnim, {
toValue: toValue,
tension: 10,
friction: 7
}).start(cb);
}
}
guid() {
function s4() {
return Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1);
}
return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
}
getNextPushIndex() {
console.log(this.props.numberOfCroppers);
if (this.state.currentImageIndex < this.props.numberOfCroppers - 1) {
if (this.state.images.length < this.props.numberOfCroppers) {
return this.state.images.length;
}
return this.state.currentImageIndex + 1;
}
return 0;
}
getCurrentImage() {
return this.state.images[this.state.currentImageIndex];
}
onLoad(imageObj, currentLoadingGuid) {
if (currentLoadingGuid === this.currentLoadingGuid) {
this.currentLoadingGuid = null;
this.loadCircle && this.loadCircle.animateFill(100, undefined, false);
setTimeout(() => {
this.animateLoadingView(0, undefined, true);
}, 100);
}
this._setLoadedForImageObj(imageObj);
}
onPartialLoad(imageObj) {
this._setLoadedForImageObj(imageObj);
}
_setLoadedForImageObj(imageObj) {
if (!imageObj.loaded) {
this.state.images.forEach(i => i.loaded = false);
imageObj.loaded = true;
this.forceUpdate();
}
}
onProgress(e) {
const p = Math.round((e.nativeEvent.loaded / e.nativeEvent.total) * 100);
this.loadCircle && this.loadCircle.animateFill(p, undefined, false);
}
renderCroppers(cropperProps) {
const cropperViews = [];
for (var j = 0; j < this.state.images.length; j++) {
const imageObj = this.state.images[j];
const isActive = this.state.currentImageIndex === j;
const style = [
styles.imageCropperView, styles.absoluteStyle, imageObj.loaded
? styles.activeCropperView
: null
];
cropperViews.push(<ImageCopperView
key={j}
magnification={this.props.magnification}
window={this.props.window}
willStartAnimating={this.props.willStartAnimating}
finnishAnimation={this.props.finnishAnimation}
getAnimationValue={this.props.getAnimationValue}
animate={this.props.animate}
resetAnimation={this.props.resetAnimation}
pointerEvents={isActive
? ACTIVE_POINTER
: INACTIVE_POINTER}
isActive={isActive}
onProgress={this.onProgress.bind(this)}
onLoad={this.onLoad.bind(this, imageObj, this.currentLoadingGuid)}
onError={() => alert('error')}
onPartialLoad={this.onPartialLoad.bind(this, imageObj, this.currentLoadingGuid)}
style={style}
image={imageObj.image} />);
}
return cropperViews;
}
render() {
const { width, height } = this.props.window;
const drawerContainer = {
opacity: this.props.anim.interpolate({
inputRange: [
0, width
],
outputRange: [
0, -0.35
],
extrapolate: 'extend'
})
};
const widthHeightStyle = {
width,
height: width
};
return (
<BlockView style={[styles.container, this.props.style]}>
<ScrollView
style={widthHeightStyle}
scrollsToTop={false}
bounces={false}
contentContainerStyle={widthHeightStyle}
scrollEnabled={true}>
{this.renderCroppers()}
</ScrollView>
{this.renderToolbar()}
<Animated.View
pointerEvents={INACTIVE_POINTER}
style={[styles.drawerContainer, styles.absoluteStyle, drawerContainer]}></Animated.View>
{this.renderLoadingView(widthHeightStyle)}
</BlockView>
);
}
renderToolbar() {
return (<ToolBar appService={this.props.appService} image={this.props.image}></ToolBar>);
}
renderLoadingView(widthHeightStyle) {
return (
<Animated.View
pointerEvents={INACTIVE_POINTER}
style={[
styles.absoluteStyle,
styles.blurView, {
backgroundColor: 'black',
opacity: this.state.loadingViewAnim.interpolate({
inputRange: [
0, 1
],
outputRange: [0, 0.65]
}),
transform: [
{
scale: this.state.loadingViewAnim.interpolate(loadingViewScale)
}
]
}
]}
blurType='dark'>
<AnimatedCircularProgress
ref={loadCircle => this.loadCircle = loadCircle}
rotation={0}
style={styles.animatedCircle}
size={50}
width={1.5}
fill={5}
tintColor='white'
backgroundColor="rgba(170, 170, 170, 1)" />
</Animated.View>
);
}
}
CropperViewContainer.defaultProps = {
numberOfCroppers: 2
};
const styles = StyleSheet.create({
container: {
overflow: 'hidden'
},
animatedCircle: {
backgroundColor: 'transparent'
},
absoluteStyle: {
position: 'absolute',
top: 0,
left: 0,
right: 0,
bottom: 0
},
imageCropperView: {
opacity: 0
},
activeCropperView: {
opacity: 1
},
drawerContainer: {
backgroundColor: 'black',
opacity: 0.6
},
blurView: {
alignItems: 'center',
justifyContent: 'center'
}
});
|
client/components/MasterPage.js | JSVillage/military-families-backend | import React from 'react';
import {Link} from 'react-router';
class MasterPage extends React.Component {
render() {
return <div>
<div className="container">
<div className ="row">
<nav className="navbar navbar-default navbar-fixed-top">
<div className="container-fluid">
<div className="navbar-header">
<button type="button" className="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-collapse" aria-expanded="false">
<span className="sr-only">Toggle navigation</span>
<span className="icon-bar"></span>
<span className="icon-bar"></span>
<span className="icon-bar"></span>
</button>
<a href="/" className="navbar-brand">
<i className="fa fa-heartbeat" aria-hidden="true"></i>
Veteran Support</a>
</div>
<div className="navbar-collapse collapse" id="bs-collapse">
<ul className="nav navbar-nav navbar-right">
<li>
<Link to="/services">Services</Link>
</li>
<li>
<Link to="/events">Events</Link>
</li>
<li>
<Link to="/forum">Forum</Link>
</li>
<li>
<Link to="/resources">Resources</Link>
</li>
<li>
<Link to="/about">About</Link>
</li>
</ul>
</div>
</div>
</nav>
</div>
</div>
{this.props.children}
<footer className="text-center">
<p>© JavaScript Village 2016</p>
</footer>
</div>;
}
}
export default MasterPage;
|
app/packs/src/admin/text_templates/TextTemplateIcon.js | ComPlat/chemotion_ELN | import React from 'react';
import PropTypes from 'prop-types';
const TextTemplateIcon = ({ template }) => {
if (!template) return <span />;
const { data, name } = template;
if (data.icon) {
return (
<i className={data.icon} />
);
}
const text = (data || {}).text || name;
return (
<span>{text.toUpperCase()}</span>
);
};
TextTemplateIcon.propTypes = {
// eslint-disable-next-line react/forbid-prop-types
template: PropTypes.object
};
TextTemplateIcon.defaultProps = {
template: null
};
export default TextTemplateIcon;
|
packages/bonde-styleguide/src/content/IconColorful/svg/Abc.js | ourcities/rebu-client | import React from 'react'
const Icon = () => (
<svg xmlns='http://www.w3.org/2000/svg' width='46' height='40' viewBox='0 0 46 40'>
<g fill='none' fillRule='evenodd' transform='translate(-27)'>
<circle cx='52' cy='20' r='20' fill='#E09' opacity='.297' />
<circle cx='52' cy='20' r='16' fill='#E09' opacity='.3' />
<circle cx='52' cy='20' r='12' fill='#E09' />
<text
fill='#000'
fontFamily='SourceSansPro-Bold, Source Sans Pro'
fontSize='28'
fontWeight='bold'
>
<tspan x='27.55' y='29.728'>Abc</tspan>
</text>
</g>
</svg>
)
Icon.displayName = 'IconColorful.Abc'
export default Icon
|
src/components/Toggle/Toggle-story.js | jzhang300/carbon-components-react | import React from 'react';
import { storiesOf } from '@storybook/react';
import { action } from '@storybook/addon-actions';
import Toggle from '../Toggle';
const toggleProps = {
onToggle: action('toggle'),
className: 'some-class',
};
storiesOf('Toggle', module).addWithInfo(
'Default',
`
Toggles are controls that are used to quickly switch between two possible states. The example below shows
an uncontrolled Toggle component. To use the Toggle component as a controlled component, set the toggled property.
Setting the toggled property will allow you to change the value dynamically, whereas setting the defaultToggled
prop will only set the value initially.
`,
() => <Toggle {...toggleProps} className="some-class" id="toggle-1" />
);
|
fields/types/relationship/RelationshipFilter.js | ratecity/keystone | import _ from 'lodash';
import async from 'async';
import React from 'react';
import { findDOMNode } from 'react-dom';
import xhr from 'xhr';
import {
FormField,
FormInput,
SegmentedControl,
} from '../../../admin/client/App/elemental';
import PopoutList from '../../../admin/client/App/shared/Popout/PopoutList';
const INVERTED_OPTIONS = [
{ label: 'Linked To', value: false },
{ label: 'NOT Linked To', value: true },
];
function getDefaultValue () {
return {
inverted: INVERTED_OPTIONS[0].value,
value: [],
};
}
var RelationshipFilter = React.createClass({
propTypes: {
field: React.PropTypes.object,
filter: React.PropTypes.shape({
inverted: React.PropTypes.bool,
value: React.PropTypes.array,
}),
onHeightChange: React.PropTypes.func,
},
statics: {
getDefaultValue: getDefaultValue,
},
getDefaultProps () {
return {
filter: getDefaultValue(),
};
},
getInitialState () {
return {
searchIsLoading: false,
searchResults: [],
searchString: '',
selectedItems: [],
valueIsLoading: true,
};
},
componentDidMount () {
this._itemsCache = {};
this.loadSearchResults(true);
},
componentWillReceiveProps (nextProps) {
if (nextProps.filter.value !== this.props.filter.value) {
this.populateValue(nextProps.filter.value);
}
},
isLoading () {
return this.state.searchIsLoading || this.state.valueIsLoading;
},
populateValue (value) {
async.map(value, (id, next) => {
if (this._itemsCache[id]) return next(null, this._itemsCache[id]);
xhr({
url: Keystone.adminPath + '/api/' + this.props.field.refList.path + '/' + id + '?basic',
responseType: 'json',
}, (err, resp, data) => {
if (err || !data) return next(err);
this.cacheItem(data);
next(err, data);
});
}, (err, items) => {
if (err) {
// TODO: Handle errors better
console.error('Error loading items:', err);
}
this.setState({
valueIsLoading: false,
selectedItems: items || [],
}, () => {
findDOMNode(this.refs.focusTarget).focus();
});
});
},
cacheItem (item) {
this._itemsCache[item.id] = item;
},
buildFilters () {
var filters = {};
_.forEach(this.props.field.filters, function (value, key) {
if (value[0] === ':') return;
filters[key] = value;
}, this);
var parts = [];
_.forEach(filters, function (val, key) {
parts.push('filters[' + key + '][value]=' + encodeURIComponent(val));
});
return parts.join('&');
},
loadSearchResults (thenPopulateValue) {
const searchString = this.state.searchString;
const filters = this.buildFilters();
xhr({
url: Keystone.adminPath + '/api/' + this.props.field.refList.path + '?basic&search=' + searchString + '&' + filters,
responseType: 'json',
}, (err, resp, data) => {
if (err) {
// TODO: Handle errors better
console.error('Error loading items:', err);
this.setState({
searchIsLoading: false,
});
return;
}
data.results.forEach(this.cacheItem);
if (thenPopulateValue) {
this.populateValue(this.props.filter.value);
}
if (searchString !== this.state.searchString) return;
this.setState({
searchIsLoading: false,
searchResults: data.results,
}, this.updateHeight);
});
},
updateHeight () {
if (this.props.onHeightChange) {
this.props.onHeightChange(this.refs.container.offsetHeight);
}
},
toggleInverted (inverted) {
this.updateFilter({ inverted });
},
updateSearch (e) {
this.setState({ searchString: e.target.value }, this.loadSearchResults);
},
selectItem (item) {
const value = this.props.filter.value.concat(item.id);
this.updateFilter({ value });
},
removeItem (item) {
const value = this.props.filter.value.filter(i => { return i !== item.id; });
this.updateFilter({ value });
},
updateFilter (value) {
this.props.onChange({ ...this.props.filter, ...value });
},
renderItems (items, selected) {
const itemIconHover = selected ? 'x' : 'check';
return items.map((item, i) => {
return (
<PopoutList.Item
key={`item-${i}-${item.id}`}
icon="dash"
iconHover={itemIconHover}
label={item.name}
onClick={() => {
if (selected) this.removeItem(item);
else this.selectItem(item);
}}
/>
);
});
},
render () {
const selectedItems = this.state.selectedItems;
const searchResults = this.state.searchResults.filter(i => {
return this.props.filter.value.indexOf(i.id) === -1;
});
const placeholder = this.isLoading() ? 'Loading...' : 'Find a ' + this.props.field.label + '...';
return (
<div ref="container">
<FormField>
<SegmentedControl equalWidthSegments options={INVERTED_OPTIONS} value={this.props.filter.inverted} onChange={this.toggleInverted} />
</FormField>
<FormField style={{ borderBottom: '1px dashed rgba(0,0,0,0.1)', paddingBottom: '1em' }}>
<FormInput autoFocus ref="focusTarget" value={this.state.searchString} onChange={this.updateSearch} placeholder={placeholder} />
</FormField>
{selectedItems.length ? (
<PopoutList>
<PopoutList.Heading>Selected</PopoutList.Heading>
{this.renderItems(selectedItems, true)}
</PopoutList>
) : null}
{searchResults.length ? (
<PopoutList>
<PopoutList.Heading style={selectedItems.length ? { marginTop: '2em' } : null}>Items</PopoutList.Heading>
{this.renderItems(searchResults)}
</PopoutList>
) : null}
</div>
);
},
});
module.exports = RelationshipFilter;
|
src/app/pages/Home.js | skratchdot/audio-links | import React, { Component } from 'react';
import { Row, Col, Button, Input, Jumbotron, Label, Glyphicon } from 'react-bootstrap';
import { connect } from 'react-redux';
import { setFilterText } from '../actions/filterText';
import { addTag, deleteTag, clearTags } from '../actions/tags';
import allTags from '../../../data/tags.json';
import urlData from '../../../data/urls.json';
class Home extends Component {
toggleTag(tag) {
const { dispatch, tags } = this.props;
if (tags.indexOf(tag) === -1) {
dispatch(addTag(tag));
} else {
dispatch(deleteTag(tag));
}
}
render() {
const self = this;
const { dispatch, filterText, tags } = this.props;
const clearTagButton = (
<small>
<a href="#" onClick={(e) => {
e.preventDefault();
dispatch(clearTags());
}}>
clear all
</a>
</small>
);
let extraTag;
if (tags.length === 0) {
extraTag = (<small>No tags selected</small>);
}
// populate results
const searchText = filterText.replace(/ +/g, ' ').toLowerCase();
const results = urlData.filter(function (data) {
if (tags.length === 0) {
return true;
} else {
for (let i = 0; i < tags.length; i++) {
if (data.tags.indexOf(tags[i]) > -1) {
return true;
}
}
}
return false;
}).filter(function (data) {
const props = ['title', 'description', 'tags', 'url'];
if (filterText === '') {
return true;
}
for (let i = 0; i < props.length; i++) {
const text = data[props[i]].toString().replace(/\s+/g, ' ').toLowerCase();
if (text.indexOf(searchText) !== -1) {
return true;
}
}
return false;
});
return (
<div>
<Row>
<Col md={8}>
<Jumbotron>
<div>
<strong>
Filter:
<small><a href="#" onClick={(e) => {
e.preventDefault();
dispatch(setFilterText(''));
}}>clear text</a></small>
<br />
</strong>
<Input
type="text"
placeholder="Filter results..."
value={filterText}
onInput={(e) => {
dispatch(setFilterText(e.target.value));
}}
/>
<div>
<strong>
Tags:
{clearTagButton}
<br />
</strong>
<div>
{tags.map(function (tag, i) {
return (
<Label
key={`tag${i}`}
onClick={() => {
dispatch(deleteTag(tag));
}}
style={{
marginRight: 10,
display: 'inline-block',
cursor: 'pointer'
}}>
<Glyphicon glyph="remove" />
{tag}
</Label>
);
})}
{extraTag}
</div>
</div>
</div>
</Jumbotron>
<hr />
<div style={{marginBottom: 40}}>
<h2>Results <small>({results.length})</small>:</h2>
{results.map(function (data, i) {
const title = data.title || data.url;
const color = i % 2 === 0 ? '#efefef' : '#fafafa';
return (
<div
key={`url${i}`}
style={{
backgroundColor: color,
padding: 20,
borderTop: '1px solid #aaa'
}}>
<a href={data.url} target="_blank">{title}</a>
-
{data.description}
<div> </div>
<div>
<small>
Tags:
{data.tags.map(function (tag, i) {
const comma = i > 0 ? ',' : '';
return (
<span key={`tagLink${i}`}>
{comma}
<a href="#" onClick={(e) => {
e.preventDefault();
if (tags.indexOf(tag) === -1) {
dispatch(addTag(tag));
}
window.scrollTo(0, 0);
}}>
{tag}
</a>
</span>
);
})}
</small>
</div>
</div>
);
})}
</div>
</Col>
<Col md={4}>
<Jumbotron>
<h2 style={{marginTop: 0}}>Tags: {clearTagButton}</h2>
{allTags.map(function (tag, i) {
return (
<Button
key={`tag${i}`}
bsSize="xsmall"
active={tags.indexOf(tag) > -1}
onClick={self.toggleTag.bind(self, tag)}>
{tag}
</Button>
);
})}
</Jumbotron>
</Col>
</Row>
</div>
);
}
}
export default connect(function (state) {
return {
filterText: state.filterText,
tags: state.tags
};
})(Home);
|
src/routes/HelloWorld/Component.js | bryanmartin82/react-starter | import React, { Component } from 'react';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import * as ActionCreators from './actions';
import styles from './styles.css';
import checkmark from 'svg/icons/checkmark.svg';
import Icon from 'components/Icon/Component';
class HelloWorldContainer extends Component {
render() {
const { msg, color } = this.props.helloWorld;
const { changeColor } = this.props;
return (
<div className={styles.root}>
<div className={styles.content} style={{backgroundColor: color}}>
<Icon svg={checkmark} className={styles.interactive} onClick={changeColor} size="64" style={{color}} />
<h1 className={styles.element}>{msg}</h1>
</div>
</div>
);
}
}
const mapState = state => ({
helloWorld: state.get('helloWorld')
});
const mapDispatch = (dispatch) => ({
changeColor() {
dispatch(ActionCreators.changeColor())
}
});
export default connect(mapState, mapDispatch)(HelloWorldContainer); |
src/components/InnerLayout/ImageUpload/ImageUpload.js | Venumteam/loafer-front | import React from 'react'
// styles
import classNames from 'classnames/bind'
import styles from './ImageUpload.scss'
// constants
const avatarPlaceholder = require('../../../../static/user.svg')
const cx = classNames.bind(styles)
export default class ImageUpload extends React.Component {
static propTypes = {
user: React.PropTypes.object.isRequired,
uploadImage: React.PropTypes.func.isRequired
};
render () {
const { uploadImage, user } = this.props
return (
<div className="text-center">
<img className="img-rounded block-center img-responsive" role="presentation"
src={user.avatar_url || avatarPlaceholder} style={{ maxWidth: '150px' }} />
<div className={cx('btn btn-default mt-10', 'upload-button-wrapper')}>
<input className={cx('fa fa-upload mr', 'upload')} type="file" onChange={uploadImage} />
<span className="icon-span-filestyle fa fa-upload mr" />
<span className="buttonText">Обновить аватар</span>
</div>
</div>
)
}
}
|
fields/types/boolean/BooleanFilter.js | dryna/keystone-twoje-urodziny | import React from 'react';
import { SegmentedControl } from '../../../admin/client/App/elemental';
const VALUE_OPTIONS = [
{ label: 'Is Checked', value: true },
{ label: 'Is NOT Checked', value: false },
];
function getDefaultValue () {
return {
value: true,
};
}
var BooleanFilter = React.createClass({
propTypes: {
filter: React.PropTypes.shape({
value: React.PropTypes.bool,
}),
},
statics: {
getDefaultValue: getDefaultValue,
},
getDefaultProps () {
return {
filter: getDefaultValue(),
};
},
updateValue (value) {
this.props.onChange({ value });
},
render () {
return <SegmentedControl equalWidthSegments options={VALUE_OPTIONS} value={this.props.filter.value} onChange={this.updateValue} />;
},
});
module.exports = BooleanFilter;
|
js/components/Nav.js | ShadowZheng/CodingLife | import React from 'react';
import {Link} from 'react-router';
import NavAction from '../actions/NavAction';
import NavStore from '../stores/NavStore';
import $ from '../jquery';
function openNav() {
$('#app').addClass('show-nav');
$('#nav-toggle').addClass('uac-close')
$('#nav-toggle').addClass('uac-dark');
}
function closeNav() {
$('#app').removeClass('show-nav');
$('#nav-toggle').removeClass('uac-close')
$('#nav-toggle').removeClass('uac-dark');
}
export default class Nav extends React.Component {
constructor(args) {
super(args);
}
componentDidMount() {
NavStore.addChangeListener(this._onChange);
// store dom elements here
this.ele = {
app:document.getElementById('app'),
navSvgPoints : {
from: [115,800,115,800,115,1,115,1 ],
to: [115,800,5 , 800,115,1,115,1 ],
}
}
this.ele.navSvg = Snap( document.getElementById('nav-svg') );//;
this.ele.navSvgPolygon = this.ele.navSvg.polygon( this.ele.navSvgPoints.from );
this.ele.navSvgPolygon.attr({
id:"nav-svg-poly",
fill: "#ffffff",
});
this.ele.isNavSvgOpen = false;
// -----create a backdrop overlay ------
this.ele.backdrop = document.createElement('div');
this.ele.backdrop.id = 'nav-backdrop';
this.ele.app.appendChild( this.ele.backdrop );
// add event listener to close nav
this.ele.backdrop.addEventListener('click',function(e){
NavAction.toggle('close');
});
this._onChange();
}
componentWillUnmount() {
NavStore.removeChangeListener(this._onChange);
}
_onChange() {
NavStore.getState().isNavOpen ? openNav() : closeNav();
}
onToggle() {
NavAction.toggle();
}
render() {
let svgString = '<svg version="1.1" xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" width="64px" height="64px" viewBox="0 0 64 64" enable-background="new 0 0 64 64" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve"> \
<path class="uac-circle" fill="none" stroke-width="2" stroke-miterlimit="10" d="M16,32h32c0,0,11.723-0.306,10.75-11c-0.25-2.75-1.644-4.971-2.869-7.151C50.728,7.08,42.767,2.569,33.733,2.054C33.159,2.033,32.599,2,32,2C15.432,2,2,15.432,2,32c0,16.566,13.432,30,30,30c16.566,0,30-13.434,30-30C62,15.5,48.5,2,32,2S1.875,15.5,1.875,32"></path> \
</svg> ';
let navSvg = '<svg data-points-hover="114.9,800.5 20,800.5 114.9,0 114.9,0 " id="nav-svg" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 115.9 800" style="enable-background:new 0 0 115.9 800;" xml:space="preserve"> \
</svg>';
return (
<div>
<nav id="nav">
<ul>
<li><Link to="home">Home</Link></li>
<li><Link to="projectList">Projects</Link></li>
<li><a href="http://blog.codinglife.in">Blog</a></li>
<li><Link to="about">About</Link></li>
</ul>
<div id="nav-bottom">
<ul id="gf-nav-social-link">
<li><a href="http://github.com/shadowzheng" target="_blank">Github</a></li>
<li><a href="http://weibo.com/" target="_blank">Weibo</a></li>
<li><a href="http://www.zhihu.com/" target="_blank">知乎</a></li>
</ul>
</div>
<div id="nav-svg-wrap" dangerouslySetInnerHTML={{__html: navSvg }}></div>
</nav>
<div id="nav-toggle" className="uac-toggle-barcircle" onClick={this.onToggle}>
<div className="uac-top"></div>
<div dangerouslySetInnerHTML={{__html: svgString }}></div>
<div className="uac-bottom"></div>
</div>
</div>
)
}
} |
jqwidgets/jqwidgets-react/react_jqxtabs.js | UCF/IKM-APIM | /*
jQWidgets v5.6.0 (2018-Feb)
Copyright (c) 2011-2017 jQWidgets.
License: https://jqwidgets.com/license/
*/
import React from 'react';
const JQXLite = window.JQXLite;
export const jqx = window.jqx;
export default class JqxTabs extends React.Component {
componentDidMount() {
let options = this.manageAttributes();
this.createComponent(options);
};
manageAttributes() {
let properties = ['animationType','autoHeight','closeButtonSize','collapsible','contentTransitionDuration','disabled','enabledHover','enableScrollAnimation','enableDropAnimation','height','initTabContent','keyboardNavigation','next','previous','position','reorder','rtl','scrollAnimationDuration','selectedItem','selectionTracker','scrollable','scrollPosition','scrollStep','showCloseButtons','toggleMode','theme','width'];
let options = {};
for(let item in this.props) {
if(item === 'settings') {
for(let itemTwo in this.props[item]) {
options[itemTwo] = this.props[item][itemTwo];
}
} else {
if(properties.indexOf(item) !== -1) {
options[item] = this.props[item];
}
}
}
return options;
};
createComponent(options) {
if(!this.style) {
for (let style in this.props.style) {
JQXLite(this.componentSelector).css(style, this.props.style[style]);
}
}
if(this.props.className !== undefined) {
let classes = this.props.className.split(' ');
for (let i = 0; i < classes.length; i++ ) {
JQXLite(this.componentSelector).addClass(classes[i]);
}
}
if(!this.template) {
JQXLite(this.componentSelector).html(this.props.template);
}
JQXLite(this.componentSelector).jqxTabs(options);
};
setOptions(options) {
JQXLite(this.componentSelector).jqxTabs('setOptions', options);
};
getOptions() {
if(arguments.length === 0) {
throw Error('At least one argument expected in getOptions()!');
}
let resultToReturn = {};
for(let i = 0; i < arguments.length; i++) {
resultToReturn[arguments[i]] = JQXLite(this.componentSelector).jqxTabs(arguments[i]);
}
return resultToReturn;
};
on(name,callbackFn) {
JQXLite(this.componentSelector).on(name,callbackFn);
};
off(name) {
JQXLite(this.componentSelector).off(name);
};
animationType(arg) {
if (arg !== undefined) {
JQXLite(this.componentSelector).jqxTabs('animationType', arg)
} else {
return JQXLite(this.componentSelector).jqxTabs('animationType');
}
};
autoHeight(arg) {
if (arg !== undefined) {
JQXLite(this.componentSelector).jqxTabs('autoHeight', arg)
} else {
return JQXLite(this.componentSelector).jqxTabs('autoHeight');
}
};
closeButtonSize(arg) {
if (arg !== undefined) {
JQXLite(this.componentSelector).jqxTabs('closeButtonSize', arg)
} else {
return JQXLite(this.componentSelector).jqxTabs('closeButtonSize');
}
};
collapsible(arg) {
if (arg !== undefined) {
JQXLite(this.componentSelector).jqxTabs('collapsible', arg)
} else {
return JQXLite(this.componentSelector).jqxTabs('collapsible');
}
};
contentTransitionDuration(arg) {
if (arg !== undefined) {
JQXLite(this.componentSelector).jqxTabs('contentTransitionDuration', arg)
} else {
return JQXLite(this.componentSelector).jqxTabs('contentTransitionDuration');
}
};
disabled(arg) {
if (arg !== undefined) {
JQXLite(this.componentSelector).jqxTabs('disabled', arg)
} else {
return JQXLite(this.componentSelector).jqxTabs('disabled');
}
};
enabledHover(arg) {
if (arg !== undefined) {
JQXLite(this.componentSelector).jqxTabs('enabledHover', arg)
} else {
return JQXLite(this.componentSelector).jqxTabs('enabledHover');
}
};
enableScrollAnimation(arg) {
if (arg !== undefined) {
JQXLite(this.componentSelector).jqxTabs('enableScrollAnimation', arg)
} else {
return JQXLite(this.componentSelector).jqxTabs('enableScrollAnimation');
}
};
enableDropAnimation(arg) {
if (arg !== undefined) {
JQXLite(this.componentSelector).jqxTabs('enableDropAnimation', arg)
} else {
return JQXLite(this.componentSelector).jqxTabs('enableDropAnimation');
}
};
height(arg) {
if (arg !== undefined) {
JQXLite(this.componentSelector).jqxTabs('height', arg)
} else {
return JQXLite(this.componentSelector).jqxTabs('height');
}
};
initTabContent(arg) {
if (arg !== undefined) {
JQXLite(this.componentSelector).jqxTabs('initTabContent', arg)
} else {
return JQXLite(this.componentSelector).jqxTabs('initTabContent');
}
};
keyboardNavigation(arg) {
if (arg !== undefined) {
JQXLite(this.componentSelector).jqxTabs('keyboardNavigation', arg)
} else {
return JQXLite(this.componentSelector).jqxTabs('keyboardNavigation');
}
};
next(arg) {
if (arg !== undefined) {
JQXLite(this.componentSelector).jqxTabs('next', arg)
} else {
return JQXLite(this.componentSelector).jqxTabs('next');
}
};
previous(arg) {
if (arg !== undefined) {
JQXLite(this.componentSelector).jqxTabs('previous', arg)
} else {
return JQXLite(this.componentSelector).jqxTabs('previous');
}
};
position(arg) {
if (arg !== undefined) {
JQXLite(this.componentSelector).jqxTabs('position', arg)
} else {
return JQXLite(this.componentSelector).jqxTabs('position');
}
};
reorder(arg) {
if (arg !== undefined) {
JQXLite(this.componentSelector).jqxTabs('reorder', arg)
} else {
return JQXLite(this.componentSelector).jqxTabs('reorder');
}
};
rtl(arg) {
if (arg !== undefined) {
JQXLite(this.componentSelector).jqxTabs('rtl', arg)
} else {
return JQXLite(this.componentSelector).jqxTabs('rtl');
}
};
scrollAnimationDuration(arg) {
if (arg !== undefined) {
JQXLite(this.componentSelector).jqxTabs('scrollAnimationDuration', arg)
} else {
return JQXLite(this.componentSelector).jqxTabs('scrollAnimationDuration');
}
};
selectedItem(arg) {
if (arg !== undefined) {
JQXLite(this.componentSelector).jqxTabs('selectedItem', arg)
} else {
return JQXLite(this.componentSelector).jqxTabs('selectedItem');
}
};
selectionTracker(arg) {
if (arg !== undefined) {
JQXLite(this.componentSelector).jqxTabs('selectionTracker', arg)
} else {
return JQXLite(this.componentSelector).jqxTabs('selectionTracker');
}
};
scrollable(arg) {
if (arg !== undefined) {
JQXLite(this.componentSelector).jqxTabs('scrollable', arg)
} else {
return JQXLite(this.componentSelector).jqxTabs('scrollable');
}
};
scrollPosition(arg) {
if (arg !== undefined) {
JQXLite(this.componentSelector).jqxTabs('scrollPosition', arg)
} else {
return JQXLite(this.componentSelector).jqxTabs('scrollPosition');
}
};
scrollStep(arg) {
if (arg !== undefined) {
JQXLite(this.componentSelector).jqxTabs('scrollStep', arg)
} else {
return JQXLite(this.componentSelector).jqxTabs('scrollStep');
}
};
showCloseButtons(arg) {
if (arg !== undefined) {
JQXLite(this.componentSelector).jqxTabs('showCloseButtons', arg)
} else {
return JQXLite(this.componentSelector).jqxTabs('showCloseButtons');
}
};
toggleMode(arg) {
if (arg !== undefined) {
JQXLite(this.componentSelector).jqxTabs('toggleMode', arg)
} else {
return JQXLite(this.componentSelector).jqxTabs('toggleMode');
}
};
theme(arg) {
if (arg !== undefined) {
JQXLite(this.componentSelector).jqxTabs('theme', arg)
} else {
return JQXLite(this.componentSelector).jqxTabs('theme');
}
};
width(arg) {
if (arg !== undefined) {
JQXLite(this.componentSelector).jqxTabs('width', arg)
} else {
return JQXLite(this.componentSelector).jqxTabs('width');
}
};
addAt(index, title, content) {
JQXLite(this.componentSelector).jqxTabs('addAt', index, title, content);
};
addFirst(htmlElement) {
JQXLite(this.componentSelector).jqxTabs('addFirst', htmlElement);
};
addLast(htmlElement1, htmlElemen2t) {
JQXLite(this.componentSelector).jqxTabs('addLast', htmlElement1, htmlElemen2t);
};
collapse() {
JQXLite(this.componentSelector).jqxTabs('collapse');
};
disable() {
JQXLite(this.componentSelector).jqxTabs('disable');
};
disableAt(index) {
JQXLite(this.componentSelector).jqxTabs('disableAt', index);
};
destroy() {
JQXLite(this.componentSelector).jqxTabs('destroy');
};
ensureVisible(index) {
JQXLite(this.componentSelector).jqxTabs('ensureVisible', index);
};
enableAt(index) {
JQXLite(this.componentSelector).jqxTabs('enableAt', index);
};
expand() {
JQXLite(this.componentSelector).jqxTabs('expand');
};
enable() {
JQXLite(this.componentSelector).jqxTabs('enable');
};
focus() {
JQXLite(this.componentSelector).jqxTabs('focus');
};
getTitleAt(index) {
return JQXLite(this.componentSelector).jqxTabs('getTitleAt', index);
};
getContentAt(index) {
return JQXLite(this.componentSelector).jqxTabs('getContentAt', index);
};
getDisabledTabsCount() {
return JQXLite(this.componentSelector).jqxTabs('getDisabledTabsCount');
};
hideCloseButtonAt(index) {
JQXLite(this.componentSelector).jqxTabs('hideCloseButtonAt', index);
};
hideAllCloseButtons() {
JQXLite(this.componentSelector).jqxTabs('hideAllCloseButtons');
};
length() {
return JQXLite(this.componentSelector).jqxTabs('length');
};
removeAt(index) {
JQXLite(this.componentSelector).jqxTabs('removeAt', index);
};
removeFirst() {
JQXLite(this.componentSelector).jqxTabs('removeFirst');
};
removeLast() {
JQXLite(this.componentSelector).jqxTabs('removeLast');
};
select(index) {
JQXLite(this.componentSelector).jqxTabs('select', index);
};
setContentAt(index, htmlElement) {
JQXLite(this.componentSelector).jqxTabs('setContentAt', index, htmlElement);
};
setTitleAt(index, htmlElement) {
JQXLite(this.componentSelector).jqxTabs('setTitleAt', index, htmlElement);
};
showCloseButtonAt(index) {
JQXLite(this.componentSelector).jqxTabs('showCloseButtonAt', index);
};
showAllCloseButtons() {
JQXLite(this.componentSelector).jqxTabs('showAllCloseButtons');
};
val(value) {
if (value !== undefined) {
JQXLite(this.componentSelector).jqxTabs('val', value)
} else {
return JQXLite(this.componentSelector).jqxTabs('val');
}
};
render() {
let id = 'jqxTabs' + JQXLite.generateID();
this.componentSelector = '#' + id;
return (
<div id={id}>{this.props.value}{this.props.children}</div>
)
};
};
|
src/components/PaginationControls/PaginationControls.stories.js | austinknight/ui-components | import React from "react";
import styled from "styled-components";
import { storiesOf, action } from "@storybook/react";
import PaginationControls from "./PaginationControls";
import {
renderThemeIfPresentOrDefault,
wrapComponentWithContainerAndTheme,
colors
} from "../styles";
const Wrapper = styled.div`
background-color: ${renderThemeIfPresentOrDefault({
key: "primary01",
defaultValue: "black"
})};
padding: 10px;
`;
class StatefulWrapper extends React.Component {
constructor() {
super();
this.state = { page: 1 };
}
render = () => {
console.log(this.state.page);
return (
<PaginationControls
currentPage={this.state.page}
totalPages={100}
advanceAPage={e => {
this.setState({ page: this.state.page + 1 });
action("advanceAPage")(e);
}}
goBackAPage={e => {
this.setState({ page: this.state.page - 1 });
action("goBackAPage")(e);
}}
isRequestPageValid={e => {
action("isRequestPageValid")(e);
return true;
}}
requestPage={page => {
this.setState({ page });
action("requestPage")(page);
}}
/>
);
};
}
function renderChapterWithTheme(theme) {
return {
info: `
Usage
~~~
import React from 'react';
import {PaginationControls} from 'insidesales-components';
~~~
`,
chapters: [
{
sections: [
{
title: "Basic PaginationControls",
sectionFn: () =>
wrapComponentWithContainerAndTheme(
theme,
<Wrapper>
<StatefulWrapper />
</Wrapper>
)
},
{
title: "PaginationControls with one page",
sectionFn: () =>
wrapComponentWithContainerAndTheme(
theme,
<Wrapper>
<PaginationControls
currentPage={1}
totalPages={1}
advanceAPage={action("advanceAPage")}
goBackAPage={action("goBackAPage")}
isRequestPageValid={action("isRequestPageValid")}
requestPage={action("requestPage")}
/>
</Wrapper>
)
}
]
}
]
};
}
storiesOf("Components", module)
.addWithChapters("Default PaginationControls", renderChapterWithTheme({}))
.addWithChapters(
"PaginationControls w/ BlueYellow Theme",
renderChapterWithTheme(colors.blueYellowTheme)
);
|
containers/SetupScreenContainer.js | sayakbiswas/Git-Blogger | import React from 'react';
import globalVars from '../config/globalVars';
import SetupScreen from '../components/SetupScreen';
import GitHubAPIUtils from '../utils/GitHubAPIUtils';
class SetupScreenContainer extends React.Component {
constructor(props) {
super(props);
}
render() {
console.log('rendering');
return(
<SetupScreen />
);
}
}
module.exports = SetupScreenContainer;
|
src/components/chat/Chat.js | mBeierl/Better-Twitch-Chat | import React, { Component } from 'react';
import { connect } from 'react-redux';
import { Link } from 'react-router-dom';
import firebase from 'firebase';
import ReactCSSTransitionGroup from 'react-addons-css-transition-group';
import { Card, CardTitle, CardText, CardActions } from 'material-ui/Card';
import TextField from 'material-ui/TextField';
import FloatingActionButton from 'material-ui/FloatingActionButton';
import RaisedButton from 'material-ui/RaisedButton';
import IconMessage from 'material-ui/svg-icons/communication/message';
import Popover from 'material-ui/Popover';
import Twitch from '../../api/Twitch';
import NeuralNet from '../../api/NeuralNet';
import Message from './Message';
import MessagesContainer from './MessagesContainer';
import { uiActions, chatActions } from '../../redux/actions';
import './Chat.css';
class Chat extends Component {
constructor(props) {
super(props);
this.messagesRef = null;
this.numMsgsShowing = 10;
this.state = {
open: false
};
}
_connectToTwitch(identity) {
const { dispatch } = this.props;
const channel = this.props.match.params.channel;
dispatch(uiActions.setCurrentChannel(channel));
if (identity) Twitch.login(identity);
Twitch.join(channel);
}
componentDidMount() {
this._connectToTwitch();
}
componentDidUpdate() {
const { user } = this.props;
if (!this.messagesRef && user.firebaseUser) {
this.messagesRef = firebase
.database()
.ref(`messages/${user.firebaseUser.uid}/`);
}
if (
(!Twitch || !Twitch.client.getOptions().identity.password) &&
user.twitchToken &&
user.twitchUser &&
Twitch.client.readyState() === 'OPEN'
) {
this._connectToTwitch({
username: user.twitchUser.name,
password: user.twitchToken
});
}
}
showSendMessageInterface = event => {
// This prevents ghost click.
event.preventDefault();
this.setState({
...this.state,
open: true,
anchorEl: event.currentTarget
});
};
handleRequestClose = () => {
this.setState({
...this.state,
open: false
});
};
sendMessage = () => {
const { dispatch, ui } = this.props;
if (ui.messageInput) {
dispatch(uiActions.setMessageInput(''));
Twitch.client.say(`${this.props.match.params.channel}`, ui.messageInput);
}
};
_renderMessageInterface() {
const { user, ui, dispatch } = this.props;
const isLoggedIn =
user.firebaseUser && !user.firebaseUser.isAnonymous && user.twitchUser;
return (
<div>
<FloatingActionButton
onTouchTap={this.showSendMessageInterface}
disabled={!isLoggedIn}
style={{
position: 'fixed',
bottom: '1rem',
right: '1rem',
zIndex: '9999'
}}
>
<IconMessage />
</FloatingActionButton>
<Popover
open={this.state.open}
anchorEl={this.state.anchorEl}
anchorOrigin={{ horizontal: 'left', vertical: 'bottom' }}
targetOrigin={{ horizontal: 'left', vertical: 'top' }}
onRequestClose={this.handleRequestClose}
style={{ width: '300px', height: '200px', padding: '1rem' }}
>
<TextField
autoFocus={true}
className="Message-Input"
disabled={!isLoggedIn}
hintText="Kappa"
floatingLabelText="Send Chat-Message"
onChange={(event, newVal) =>
dispatch(uiActions.setMessageInput(newVal))}
value={ui.messageInput}
onKeyPress={event => {
if (event.charCode === 13) {
event.preventDefault();
this.sendMessage();
}
}}
/>
<RaisedButton
label="Send"
fullWidth={true}
primary={true}
disabled={!isLoggedIn || !ui.messageInput}
onTouchTap={this.sendMessage}
/>
</Popover>
</div>
);
}
render() {
const { ui, user, dispatch } = this.props;
return (
<div className="container-center">
<Card className="container">
<CardTitle
title={`Chat: ${ui.currentChannel}`}
subtitle="Vote up or down to further train your model"
/>
<CardText>
<div className="Chat">
{NeuralNet.isTrained()
? ''
: <Link to="/train">
<RaisedButton
label="Train Neural Network"
fullWidth={true}
secondary={true}
onTouchTap={this.onRetrainModelClick}
/>
</Link>}
<ReactCSSTransitionGroup
component={MessagesContainer}
transitionName="example"
transitionEnterTimeout={400}
transitionLeaveTimeout={300}
>
{ui.messages.map((msg, idx) =>
<Message
key={msg.user['tmi-sent-ts'] + msg.user['user-id']}
message={msg.text}
user={msg.user}
channel={msg.channel}
voted={msg.voted}
showVote={user.training}
onLikeMsg={msg => {
dispatch(uiActions.votedOnMessage(idx));
if (this.messagesRef)
this.messagesRef
.push({ message: msg, liked: true })
.once('value')
.then(snapshot =>
dispatch(
uiActions.setVotedMessage(
snapshot.key,
snapshot.val()
)
)
);
}}
onDislikeMsg={msg => {
// TODO add to votedMessages accordingly
dispatch(uiActions.votedOnMessage(idx));
if (this.messagesRef)
this.messagesRef
.push({ message: msg, liked: false })
.once('value')
.then(snapshot =>
dispatch(
uiActions.setVotedMessage(
snapshot.key,
snapshot.val()
)
)
);
}}
/>
)}
</ReactCSSTransitionGroup>
{this._renderMessageInterface()}
</div>
</CardText>
</Card>
{this._renderMessageInterface()}
</div>
);
}
}
export default connect(state => ({
ui: state.ui,
user: state.user
}))(Chat);
|
src/svg-icons/av/explicit.js | verdan/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let AvExplicit = (props) => (
<SvgIcon {...props}>
<path d="M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-4 6h-4v2h4v2h-4v2h4v2H9V7h6v2z"/>
</SvgIcon>
);
AvExplicit = pure(AvExplicit);
AvExplicit.displayName = 'AvExplicit';
AvExplicit.muiName = 'SvgIcon';
export default AvExplicit;
|
app/javascript/client_messenger/gdprView.js | michelson/chaskiq | import React from 'react'
import styled from '@emotion/styled'
import tw from 'twin.macro'
export const Wrapper = styled.div`
top: 0px;
z-index: 999999;
position: fixed;
width: 100%;
height: 100vh;
background: white;
//font-size: .92em;
//line-height: 1.5em;
//color: #eee;
`
export const Padder = tw.div`px-4 py-5 sm:p-6 overflow-auto h-full`
export const Title = tw.div`text-lg leading-6 font-medium text-gray-900`
export const TextContent = tw.div`space-y-4 mt-2 max-w-xl text-sm text-gray-800`
export const ButtonWrapped = tw.div`my-3 text-sm flex justify-between items-center`
export const Link = tw.a`font-medium text-gray-600 hover:text-gray-500`
export const Button = tw.button`inline-flex items-center justify-center px-4
py-2 border border-transparent font-medium rounded-md text-green-700 bg-green-100
hover:bg-green-200 focus:outline-none focus:ring-2 focus:ring-offset-2
focus:ring-green-500 sm:text-sm`
export const ButtonCancel = tw.button`inline-flex items-center justify-center px-4
py-2 border border-transparent font-medium rounded-md text-gray-700 bg-gray-100
hover:bg-gray-200 focus:outline-none focus:ring-2 focus:ring-offset-2
focus:ring-gray-500 sm:text-sm`
export default function View ({ confirm, cancel, t, app }) {
return (
<Wrapper>
<Padder>
<Title>
{t('gdpr_title')}
</Title>
<TextContent dangerouslySetInnerHTML={
{ __html: t('gdpr', { name: app.name }) }
}>
</TextContent>
<ButtonWrapped>
<Button onClick={confirm}>
{t('gdpr_ok')}
</Button>
<ButtonCancel onClick={cancel}>
{t('gdpr_nok')}
</ButtonCancel>
</ButtonWrapped>
{/* <Link href="#">
View our privacy police here <span aria-hidden="true">→</span>
</Link> */}
</Padder>
</Wrapper>
)
}
|
frontend/src/Components/Menu/FilterMenuContent.js | lidarr/Lidarr | import PropTypes from 'prop-types';
import React, { Component } from 'react';
import FilterMenuItem from './FilterMenuItem';
import MenuContent from './MenuContent';
import MenuItem from './MenuItem';
import MenuItemSeparator from './MenuItemSeparator';
class FilterMenuContent extends Component {
//
// Render
render() {
const {
selectedFilterKey,
filters,
customFilters,
showCustomFilters,
onFilterSelect,
onCustomFiltersPress,
...otherProps
} = this.props;
return (
<MenuContent {...otherProps}>
{
filters.map((filter) => {
return (
<FilterMenuItem
key={filter.key}
filterKey={filter.key}
selectedFilterKey={selectedFilterKey}
onPress={onFilterSelect}
>
{filter.label}
</FilterMenuItem>
);
})
}
{
customFilters.map((filter) => {
return (
<FilterMenuItem
key={filter.id}
filterKey={filter.id}
selectedFilterKey={selectedFilterKey}
onPress={onFilterSelect}
>
{filter.label}
</FilterMenuItem>
);
})
}
{
showCustomFilters &&
<MenuItemSeparator />
}
{
showCustomFilters &&
<MenuItem onPress={onCustomFiltersPress}>
Custom Filters
</MenuItem>
}
</MenuContent>
);
}
}
FilterMenuContent.propTypes = {
selectedFilterKey: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
filters: PropTypes.arrayOf(PropTypes.object).isRequired,
customFilters: PropTypes.arrayOf(PropTypes.object).isRequired,
showCustomFilters: PropTypes.bool.isRequired,
onFilterSelect: PropTypes.func.isRequired,
onCustomFiltersPress: PropTypes.func.isRequired
};
FilterMenuContent.defaultProps = {
showCustomFilters: false
};
export default FilterMenuContent;
|
src/svg-icons/action/payment.js | jacklam718/react-svg-iconx | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let ActionPayment = (props) => (
<SvgIcon {...props}>
<path d="M20 4H4c-1.11 0-1.99.89-1.99 2L2 18c0 1.11.89 2 2 2h16c1.11 0 2-.89 2-2V6c0-1.11-.89-2-2-2zm0 14H4v-6h16v6zm0-10H4V6h16v2z"/>
</SvgIcon>
);
ActionPayment = pure(ActionPayment);
ActionPayment.displayName = 'ActionPayment';
ActionPayment.muiName = 'SvgIcon';
export default ActionPayment;
|
docs/src/app/components/pages/components/DatePicker/ExampleControlled.js | hwo411/material-ui | import React from 'react';
import DatePicker from 'material-ui/DatePicker';
/**
* `DatePicker` can be implemented as a controlled input,
* where `value` is handled by state in the parent component.
*/
export default class DatePickerExampleControlled extends React.Component {
constructor(props) {
super(props);
this.state = {
controlledDate: null,
};
}
handleChange = (event, date) => {
this.setState({
controlledDate: date,
});
};
render() {
return (
<DatePicker
hintText="Controlled Date Input"
value={this.state.controlledDate}
onChange={this.handleChange}
/>
);
}
}
|
examples/example2.js | gabrielbull/react-tether2 | import React, { Component } from 'react';
import Target from './example2/target';
const style = {
position: 'fixed',
top: '0px',
left: '0px',
width: '100%',
height: '50px',
display: 'flex',
justifyContent: 'center'
};
class Example2 extends Component {
render() {
return (
<div style={style}>
<Target/>
</div>
);
}
}
export default Example2;
|
packages/icons/src/md/content/LowPriority.js | suitejs/suitejs | import React from 'react';
import IconBase from '@suitejs/icon-base';
function MdLowPriority(props) {
return (
<IconBase viewBox="0 0 48 48" {...props}>
<path d="M28 9h16v4H28V9zm0 11h16v4H28v-4zm0 11h16v4H28v-4zM4 22c0 7.17 5.83 13 13 13h1v4l6-6-6-6v4h-1c-4.96 0-9-4.04-9-9s4.04-9 9-9h7V9h-7C9.83 9 4 14.83 4 22z" />
</IconBase>
);
}
export default MdLowPriority;
|
app/javascript/mastodon/components/column.js | musashino205/mastodon | import React from 'react';
import PropTypes from 'prop-types';
import { supportsPassiveEvents } from 'detect-passive-events';
import { scrollTop } from '../scroll';
export default class Column extends React.PureComponent {
static propTypes = {
children: PropTypes.node,
label: PropTypes.string,
bindToDocument: PropTypes.bool,
};
scrollTop () {
const scrollable = this.props.bindToDocument ? document.scrollingElement : this.node.querySelector('.scrollable');
if (!scrollable) {
return;
}
this._interruptScrollAnimation = scrollTop(scrollable);
}
handleWheel = () => {
if (typeof this._interruptScrollAnimation !== 'function') {
return;
}
this._interruptScrollAnimation();
}
setRef = c => {
this.node = c;
}
componentDidMount () {
if (this.props.bindToDocument) {
document.addEventListener('wheel', this.handleWheel, supportsPassiveEvents ? { passive: true } : false);
} else {
this.node.addEventListener('wheel', this.handleWheel, supportsPassiveEvents ? { passive: true } : false);
}
}
componentWillUnmount () {
if (this.props.bindToDocument) {
document.removeEventListener('wheel', this.handleWheel);
} else {
this.node.removeEventListener('wheel', this.handleWheel);
}
}
render () {
const { label, children } = this.props;
return (
<div role='region' aria-label={label} className='column' ref={this.setRef}>
{children}
</div>
);
}
}
|
src/svg-icons/communication/chat-bubble.js | mmrtnz/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let CommunicationChatBubble = (props) => (
<SvgIcon {...props}>
<path d="M20 2H4c-1.1 0-2 .9-2 2v18l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2z"/>
</SvgIcon>
);
CommunicationChatBubble = pure(CommunicationChatBubble);
CommunicationChatBubble.displayName = 'CommunicationChatBubble';
CommunicationChatBubble.muiName = 'SvgIcon';
export default CommunicationChatBubble;
|
src/layouts/PageLayout/PageLayout.js | larsdolvik/portfolio | import React from 'react'
import {IndexLink, Link} from 'react-router'
import PropTypes from 'prop-types'
import './PageLayout.scss'
export const PageLayout = ({children}) => (
<div className='container text-center'>
<h1>Lars Bendik Dølvik</h1>
<IndexLink to='/' activeClassName='page-layout__nav-item--active'>
<button className="button">Home</button>
</IndexLink>
{' · '}
<Link to='/projects' activeClassName='page-layout__nav-item--active'>
<button className="button">Projects</button>
</Link>
{' · '}
<Link to='/aboutme' activeClassName='page-layout__nav-item--active'>
<button className="button">About me</button>
</Link>
{/* <Link to='/counter' activeClassName='page-layout__nav-item--active'><button className="button">Counter</button></Link> */}
<div className='page-layout__viewport'>
{children}
</div>
<footer>
Made by Lars Dølvik
</footer>
</div>
)
PageLayout.propTypes = {
children: PropTypes.node
}
export default PageLayout
|
src/components/stories/Gallery.js | neontribe/spool | import React from 'react';
import { storiesOf } from '@kadira/storybook';
import { Gallery } from '../Gallery';
import { entries } from './fixtures';
const initialData = {
role: {
entries: {
edges: []
}
}
};
const entriesData = {
role: {
entries: {
edges: entries.map((e) => { return {node: e}; })
}
}
};
storiesOf('Gallery', module)
.add('Initial View', () => (
<Gallery viewer={initialData} />
))
.add('With entries', () => (
<Gallery viewer={entriesData} />
));
|
client/components/icons/icon-components/instagram-white.js | HelpAssistHer/help-assist-her | import React from 'react'
export default function InstagramWhite(props) {
return (
<svg
version="1.1"
id="Layer_1"
xmlns="http://www.w3.org/2000/svg"
xmlnsXlink="http://www.w3.org/1999/xlink"
x="0px"
y="0px"
viewBox="-6 -8 229 232"
enableBackground="new -6 -8 229 232"
xmlSpace="preserve"
width={229}
height={232}
{...props}
>
<g id="Symbols">
<g id="Instagram_White_Mobile">
<g id="Group">
<path
fill="#FFFFFF"
d="M108,218.7C47,218.7-2.7,169-2.7,108S47-2.7,108-2.7S218.7,47,218.7,108S169,218.7,108,218.7z M108,2.7C49.7,2.7,2.7,49.7,2.7,108s47,105.3,105.3,105.3s105.3-47,105.3-105.3S166.3,2.7,108,2.7z"
/>
<path
fill="#FFFFFF"
d="M108,88c-10.8,0-20,8.6-20,20c0,10.8,8.6,20,20,20s20-8.6,20-20C128,97.2,118.8,88,108,88L108,88zM108,82.6c14,0,25.4,11.3,25.4,25.4S122,133.4,108,133.4S82.6,122,82.6,108C82.6,94,94,82.6,108,82.6L108,82.6z M136.1,71.3c3.2,0,5.4,2.7,5.4,5.4c0,3.2-2.7,5.4-5.4,5.4c-3.2,0-5.4-2.7-5.4-5.4C130.7,74,132.8,71.3,136.1,71.3L136.1,71.3z M85.3,62.6c-12.4,0-22.7,10.3-22.7,22.7v45.4c0,12.4,10.3,22.7,22.7,22.7h45.4c12.4,0,22.7-10.3,22.7-22.7V85.3c0-12.4-10.3-22.7-22.7-22.7H85.3L85.3,62.6z M85.3,57.2h45.4c15.7,0,28.1,12.4,28.1,28.1v45.4c0,15.7-12.4,28.1-28.1,28.1H85.3c-15.7,0-28.1-12.4-28.1-28.1V85.3C57.2,69.7,69.7,57.2,85.3,57.2L85.3,57.2z M78.3,45.9c-17.8,0-32.4,14.6-32.4,32.4v59.4c0,17.8,14.6,32.4,32.4,32.4h59.4c17.8,0,32.4-14.6,32.4-32.4V78.3c0-17.8-14.6-32.4-32.4-32.4H78.3L78.3,45.9z"
/>
</g>
</g>
</g>
</svg>
)
}
|
packages/react-instantsearch-dom/src/components/SearchBox.js | algolia/react-instantsearch | import React, { Component } from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import { translatable } from 'react-instantsearch-core';
import { createClassNames } from '../core/utils';
const cx = createClassNames('SearchBox');
const defaultLoadingIndicator = (
<svg
width="18"
height="18"
viewBox="0 0 38 38"
xmlns="http://www.w3.org/2000/svg"
stroke="#444"
className={cx('loadingIcon')}
>
<g fill="none" fillRule="evenodd">
<g transform="translate(1 1)" strokeWidth="2">
<circle strokeOpacity=".5" cx="18" cy="18" r="18" />
<path d="M36 18c0-9.94-8.06-18-18-18">
<animateTransform
attributeName="transform"
type="rotate"
from="0 18 18"
to="360 18 18"
dur="1s"
repeatCount="indefinite"
/>
</path>
</g>
</g>
</svg>
);
const defaultReset = (
<svg
className={cx('resetIcon')}
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 20 20"
width="10"
height="10"
>
<path d="M8.114 10L.944 2.83 0 1.885 1.886 0l.943.943L10 8.113l7.17-7.17.944-.943L20 1.886l-.943.943-7.17 7.17 7.17 7.17.943.944L18.114 20l-.943-.943-7.17-7.17-7.17 7.17-.944.943L0 18.114l.943-.943L8.113 10z" />
</svg>
);
const defaultSubmit = (
<svg
className={cx('submitIcon')}
xmlns="http://www.w3.org/2000/svg"
width="10"
height="10"
viewBox="0 0 40 40"
>
<path d="M26.804 29.01c-2.832 2.34-6.465 3.746-10.426 3.746C7.333 32.756 0 25.424 0 16.378 0 7.333 7.333 0 16.378 0c9.046 0 16.378 7.333 16.378 16.378 0 3.96-1.406 7.594-3.746 10.426l10.534 10.534c.607.607.61 1.59-.004 2.202-.61.61-1.597.61-2.202.004L26.804 29.01zm-10.426.627c7.323 0 13.26-5.936 13.26-13.26 0-7.32-5.937-13.257-13.26-13.257C9.056 3.12 3.12 9.056 3.12 16.378c0 7.323 5.936 13.26 13.258 13.26z" />
</svg>
);
class SearchBox extends Component {
static propTypes = {
currentRefinement: PropTypes.string,
className: PropTypes.string,
refine: PropTypes.func.isRequired,
translate: PropTypes.func.isRequired,
loadingIndicator: PropTypes.node,
reset: PropTypes.node,
submit: PropTypes.node,
focusShortcuts: PropTypes.arrayOf(
PropTypes.oneOfType([PropTypes.string, PropTypes.number])
),
autoFocus: PropTypes.bool,
searchAsYouType: PropTypes.bool,
onSubmit: PropTypes.func,
onReset: PropTypes.func,
onChange: PropTypes.func,
isSearchStalled: PropTypes.bool,
showLoadingIndicator: PropTypes.bool,
inputRef: PropTypes.oneOfType([
PropTypes.func,
PropTypes.exact({ current: PropTypes.object }),
]),
inputId: PropTypes.string,
};
static defaultProps = {
currentRefinement: '',
className: '',
focusShortcuts: ['s', '/'],
autoFocus: false,
searchAsYouType: true,
showLoadingIndicator: false,
isSearchStalled: false,
loadingIndicator: defaultLoadingIndicator,
reset: defaultReset,
submit: defaultSubmit,
};
constructor(props) {
super();
this.state = {
query: props.searchAsYouType ? null : props.currentRefinement,
};
}
componentDidMount() {
document.addEventListener('keydown', this.onKeyDown);
}
componentWillUnmount() {
document.removeEventListener('keydown', this.onKeyDown);
}
componentDidUpdate(prevProps) {
if (
!this.props.searchAsYouType &&
prevProps.currentRefinement !== this.props.currentRefinement
) {
this.setState({
query: this.props.currentRefinement,
});
}
}
getQuery = () =>
this.props.searchAsYouType
? this.props.currentRefinement
: this.state.query;
onInputMount = (input) => {
this.input = input;
if (!this.props.inputRef) return;
if (typeof this.props.inputRef === 'function') {
this.props.inputRef(input);
} else {
this.props.inputRef.current = input;
}
};
// From https://github.com/algolia/autocomplete.js/pull/86
onKeyDown = (e) => {
if (!this.props.focusShortcuts) {
return;
}
const shortcuts = this.props.focusShortcuts.map((key) =>
typeof key === 'string' ? key.toUpperCase().charCodeAt(0) : key
);
const elt = e.target || e.srcElement;
const tagName = elt.tagName;
if (
elt.isContentEditable ||
tagName === 'INPUT' ||
tagName === 'SELECT' ||
tagName === 'TEXTAREA'
) {
// already in an input
return;
}
const which = e.which || e.keyCode;
if (shortcuts.indexOf(which) === -1) {
// not the right shortcut
return;
}
this.input.focus();
e.stopPropagation();
e.preventDefault();
};
onSubmit = (e) => {
e.preventDefault();
e.stopPropagation();
this.input.blur();
const { refine, searchAsYouType } = this.props;
if (!searchAsYouType) {
refine(this.getQuery());
}
return false;
};
onChange = (event) => {
const { searchAsYouType, refine, onChange } = this.props;
const value = event.target.value;
if (searchAsYouType) {
refine(value);
} else {
this.setState({ query: value });
}
if (onChange) {
onChange(event);
}
};
onReset = (event) => {
const { searchAsYouType, refine, onReset } = this.props;
refine('');
this.input.focus();
if (!searchAsYouType) {
this.setState({ query: '' });
}
if (onReset) {
onReset(event);
}
};
render() {
const {
className,
inputId,
translate,
autoFocus,
loadingIndicator,
submit,
reset,
} = this.props;
const query = this.getQuery();
const searchInputEvents = Object.keys(this.props).reduce((props, prop) => {
if (
['onsubmit', 'onreset', 'onchange'].indexOf(prop.toLowerCase()) ===
-1 &&
prop.indexOf('on') === 0
) {
return { ...props, [prop]: this.props[prop] };
}
return props;
}, {});
const isSearchStalled =
this.props.showLoadingIndicator && this.props.isSearchStalled;
return (
<div className={classNames(cx(''), className)}>
<form
noValidate
onSubmit={this.props.onSubmit ? this.props.onSubmit : this.onSubmit}
onReset={this.onReset}
className={cx('form', isSearchStalled && 'form--stalledSearch')}
action=""
role="search"
>
<input
ref={this.onInputMount}
id={inputId}
type="search"
placeholder={translate('placeholder')}
autoFocus={autoFocus}
autoComplete="off"
autoCorrect="off"
autoCapitalize="off"
spellCheck="false"
required
maxLength="512"
value={query}
onChange={this.onChange}
{...searchInputEvents}
className={cx('input')}
/>
<button
type="submit"
title={translate('submitTitle')}
className={cx('submit')}
>
{submit}
</button>
<button
type="reset"
title={translate('resetTitle')}
className={cx('reset')}
hidden={!query || isSearchStalled}
>
{reset}
</button>
{this.props.showLoadingIndicator && (
<span hidden={!isSearchStalled} className={cx('loadingIndicator')}>
{loadingIndicator}
</span>
)}
</form>
</div>
);
}
}
export default translatable({
resetTitle: 'Clear the search query.',
submitTitle: 'Submit your search query.',
placeholder: 'Search here…',
})(SearchBox);
|
docs/app/Examples/modules/Checkbox/States/CheckboxExampleChecked.js | mohammed88/Semantic-UI-React | import React from 'react'
import { Checkbox } from 'semantic-ui-react'
const CheckboxExampleChecked = () => (
<Checkbox label='This checkbox comes pre-checked' defaultChecked />
)
export default CheckboxExampleChecked
|
src/components/Loading/Loading.js | MinisterioPublicoRJ/inLoco-2.0 | import React from 'react'
const Loading = ({ layers, showLoader, downloadLoader }) => {
let loadingClass = 'module-loading'
if (!showLoader && showLoader !== undefined) {
loadingClass += ' hidden'
}
if (downloadLoader && downloadLoader === true) {
loadingClass = 'module-loading'
}
return (
<div className={loadingClass}>
<div className="spinner">
<i className="fa fa-spinner fa-spin" aria-hidden="true"></i><br />
Carregando...</div>
</div>
)
}
export default Loading
|
node_modules/react-bootstrap/es/MediaRight.js | Technaesthetic/ua-tools | 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 Media from './Media';
import { bsClass, getClassSet, prefix, splitBsProps } from './utils/bootstrapUtils';
var propTypes = {
/**
* Align the media to the top, middle, or bottom of the media object.
*/
align: React.PropTypes.oneOf(['top', 'middle', 'bottom'])
};
var MediaRight = function (_React$Component) {
_inherits(MediaRight, _React$Component);
function MediaRight() {
_classCallCheck(this, MediaRight);
return _possibleConstructorReturn(this, _React$Component.apply(this, arguments));
}
MediaRight.prototype.render = function render() {
var _props = this.props,
align = _props.align,
className = _props.className,
props = _objectWithoutProperties(_props, ['align', 'className']);
var _splitBsProps = splitBsProps(props),
bsProps = _splitBsProps[0],
elementProps = _splitBsProps[1];
var classes = getClassSet(bsProps);
if (align) {
// The class is e.g. `media-top`, not `media-right-top`.
classes[prefix(Media.defaultProps, align)] = true;
}
return React.createElement('div', _extends({}, elementProps, {
className: classNames(className, classes)
}));
};
return MediaRight;
}(React.Component);
MediaRight.propTypes = propTypes;
export default bsClass('media-right', MediaRight); |
app/javascript/components/RoundMap/Map/ReferencePoints/index.js | skyderby/skyderby | import React from 'react'
import { useSelector } from 'react-redux'
import { selectAssignedReferencePoints } from 'redux/events/round/selectors'
import Marker from './Marker'
const ReferencePoints = () => {
const referencePoints = useSelector(selectAssignedReferencePoints)
return (
<>
{referencePoints.map(el => (
<Marker key={el.id} {...el} />
))}
</>
)
}
export default ReferencePoints
|
test/components/counter.spec.js | TYRONEMICHAEL/recompose | import test from 'tape';
import sinon from 'sinon';
import createDocument from '../utils/createDocument';
import React from 'react';
import ReactDOM from 'react-dom';
import ReactTestUtils from 'react-addons-test-utils';
import counterFactory from '../../src/components/counter';
function setup() {
const document = createDocument();
const Counter = counterFactory(React);
const container = document.createElement('div');
const actions = {
increment: sinon.spy(),
incrementIfOdd: sinon.spy(),
incrementAsync: sinon.spy(),
decrement: sinon.spy()
};
ReactDOM.render(<Counter counter={1} {...actions} />, container);
return {
actions: actions,
container: container
};
};
test('Counter component', (t) => {
t.test('should display count', (t) => {
const { container } = setup();
const count = container.getElementsByClassName('counter__value')[0];
t.equal(count.innerHTML, '1');
t.end();
});
t.test('increment button should call increment action', (t) => {
const { actions, container } = setup();
const btn = container.getElementsByClassName('counter__increment')[0];
ReactTestUtils.Simulate.click(btn);
t.equal(actions.increment.calledOnce, true, );
t.end();
});
t.test('decrement button should call decrement action', (t) => {
const { actions, container } = setup();
const btn = container.getElementsByClassName('counter__decrement')[0];
ReactTestUtils.Simulate.click(btn);
t.equal(actions.decrement.calledOnce, true, );
t.end();
});
t.test('odd button should call incrementIfOdd action', (t) => {
const { actions, container } = setup();
const btn = container.getElementsByClassName('counter__odd')[0];
ReactTestUtils.Simulate.click(btn);
t.equal(actions.incrementIfOdd.calledOnce, true, );
t.end();
});
t.end();
});
|
test/dummy/client/components/posts/record-expanded-content.js | factore/tenon | import React from 'react';
module.exports = (props) => {
const editPath = props.record.edit_path;
const onDelete = props.onDelete;
return (
<div className="record__expanded-content">
<div dangerouslySetInnerHTML={{ __html: props.record.excerpt }} />
<div className="record__expanded-actions">
<div className="record__expanded-action-text">
<a
className="action-text"
href={editPath}
title="Edit">
Edit
</a>
</div>
<div className="record__expanded-action-text">
<a
className="action-text"
onClick={onDelete}
href="#!"
title="Delete">
Delete
</a>
</div>
</div>
</div>
);
};
|
docs/app/Examples/collections/Table/States/TableExampleWarningShorthand.js | shengnian/shengnian-ui-react | import React from 'react'
import { Table } from 'shengnian-ui-react'
const tableData = [
{ name: undefined, status: undefined, notes: undefined },
{ name: 'Jimmy', status: 'Requires Action', notes: undefined },
{ name: 'Jamie', status: undefined, notes: 'Hostile' },
{ name: 'Jill', status: undefined, notes: undefined },
]
const headerRow = [
'Name',
'Status',
'Notes',
]
const renderBodyRow = ({ name, status, notes }, i) => ({
key: name || `row-${i}`,
warning: !!(status && status.match('Requires Action')),
cells: [
name || 'No name specified',
status
? { key: 'status', icon: 'attention', content: status }
: 'Unknown',
notes
? { key: 'notes', icon: 'attention', content: notes, warning: true }
: 'None',
],
})
const TableExampleWarningShorthand = () => (
<Table
celled
headerRow={headerRow}
renderBodyRow={renderBodyRow}
tableData={tableData}
/>
)
export default TableExampleWarningShorthand
|
src/components/Gauge/Gauge.js | Zoomdata/nhtsa-dashboard-2.2 | import styles from './Gauge.css';
import React from 'react';
import GaugeChart from '../GaugeChart/GaugeChart';
const Gauge = ({
name,
id,
data,
max
}) => {
return (
<div
className={styles.root}
id={id}
>
<GaugeChart
name={name}
data={data}
max={max}
/>
</div>
)
};
export default Gauge; |
src/components/Player/extensions/playerEvents.js | Magics-Group/throw-client | import {
throttle
}
from 'lodash';
import {
EventEmitter
}
from 'events';
import dns from 'dns'
import os from 'os'
import Promise from 'bluebird'
import {
remote
}
from 'electron'
import React from 'react'
import ReactQR from 'react-qr'
import socketIO from 'socket.io'
import getPort from 'get-port'
const getInternalIP = () => {
return new Promise((resolve, reject) => dns.lookup(os.hostname(), (err, add, fam) => {
if (err) return reject(err)
resolve(add)
}))
}
export default class PlayerEvents extends EventEmitter {
constructor(title) {
super()
this.title = title
this.on('wcjsLoaded', wcjs => {
this._wcjs = wcjs
this._wcjs.onPositionChanged = throttle(pos => this.emit('position', pos), 500)
this._wcjs.onOpening = () => this.emit('opening')
this._wcjs.onTimeChanged = time => this.emit('time', time)
this._wcjs.onBuffering = throttle(buf => this.emit('buffering', buf), 500)
this._wcjs.onLengthChanged = length => this.emit('length', length)
this._wcjs.onSeekableChanged = Seekable => this.emit('seekable', Seekable)
this._wcjs.onFrameRendered = (width, height) => {
const win = remote.getCurrentWindow()
win.setSize(width, height + 30)
win.center()
}
this._wcjs.onPlaying = () => this.emit('playing', true)
this._wcjs.onPaused = () => this.emit('playing', false)
this._wcjs.onStopped = () => this.emit('playing', false)
this._wcjs.onEndReached = () => this.emit('ended')
this._wcjs.onEncounteredError = err => this.emit('error', err)
this._wcjs.onMediaChanged = () => this.emit('changed')
})
this.on('scrobble', time => this._wcjs.time = time)
this.on('togglePause', () => this._wcjs.togglePause())
this.on('skipForward', () => this._wcjs.time += 30000)
this.on('skipBackward', () => this._wcjs.time -= 30000)
this.on('play', url => this._wcjs.play(url));
this.on('toggleMute', () => this._wcjs.toggleMute())
this.on('volumeChange', volume => {
this._wcjs.volume = volume
this.emit('volume', volume)
})
this.on('close', () => {
this._wcjs.stop()
const events = ['opening', 'position', 'qrCode', 'time', 'volume', 'buffering', 'length', 'seekable', 'playing', 'togglePause', 'ended', 'changed', 'mouseMove', 'closed']
events.forEach(event => this.removeAllListeners(event))
const win = remote.getCurrentWindow()
win.setKiosk(false)
win.setSize(575, 350)
win.setTitle(`Throw Player`)
win.center()
this.emit('closed')
})
this.PIN = parseInt(('0' + Math.floor(Math.random() * (9999 - 0 + 1)) + 0).substr(-4))
Promise.all([getInternalIP(), getPort()])
.spread((ip, port) => {
this.ioServer = socketIO()
this.ioServer.on('connection', socket => {
let authed = false
socket.on('pin', pin => {
authed = parseInt(pin) === parseInt(this.PIN)
})
socket.emit('title', this.title)
socket.on('position', percent => {
if (!authed) return
const scrobbleTime = this._wcjs.totalTime * percent
console.log(scrobbleTime)
})
socket.on('playing', () => {
if (authed) this.emit('togglePause')
})
socket.on('muted', () => {
if (authed) this.emit('toggleMute')
})
socket.on('forward', () => {
if (authed) this.emit('skipForward')
})
socket.on('backward', () => {
if (authed) this.emit('skipBackward')
})
this.on('position', position => socket.emit('position', position))
this.on('time', time => socket.emit('time', time))
this.on('length', length => socket.emit('length', length))
this.on('playing', playing => returnsocket.emit('playing', playing))
this.on('ended', () => socket.emit('ended'))
this.on('closed', () => {
socket.emit('ended')
socket.disconnect()
})
})
this.ioServer.listen(port)
console.log(`PlayerAPI socket server running @ ${ip}:${port} w/ PIN of ${this.PIN}`)
this.emit('qrCode', <ReactQR text={JSON.stringify({pin: this.PIN,ip,port})} />)
})
}
} |
src/index.js | hofnarwillie/weather-demo | /* eslint-disable import/default */
import React from 'react';
import {render} from 'react-dom';
import { Provider } from 'react-redux';
import { Router, browserHistory } from 'react-router';
import routes from './routes';
import {getWeather} from './actions/weatherActions';
import configureStore from './store/configureStore';
import { syncHistoryWithStore } from 'react-router-redux';
//styles
import './scss/index.scss';
//setup Redux
const store = configureStore();
const history = syncHistoryWithStore(browserHistory, store);
//initial data load
store.dispatch(getWeather());
//create React entry point
render(
<Provider store={store}>
<Router history={history} routes={routes} />
</Provider>, document.getElementById('app')
);
|
docs/src/app/components/pages/components/DatePicker/ExampleInternational.js | w01fgang/material-ui | import React from 'react';
import DatePicker from 'material-ui/DatePicker';
import areIntlLocalesSupported from 'intl-locales-supported';
let DateTimeFormat;
/**
* Use the native Intl.DateTimeFormat if available, or a polyfill if not.
*/
if (areIntlLocalesSupported(['fr', 'fa-IR'])) {
DateTimeFormat = global.Intl.DateTimeFormat;
} else {
const IntlPolyfill = require('intl');
DateTimeFormat = IntlPolyfill.DateTimeFormat;
require('intl/locale-data/jsonp/fr');
require('intl/locale-data/jsonp/fa-IR');
}
/**
* `DatePicker` can be localised using the `locale` property. The first example is localised in French.
* Note that the buttons must be separately localised using the `cancelLabel` and `okLabel` properties.
*
* The second example shows `firstDayOfWeek` set to `0`, (Sunday), and `locale` to `en-US` which matches the
* behavior of the Date Picker prior to 0.15.0. Note that the 'en-US' locale is built in, and so does not require
* `DateTimeFormat` to be supplied.
*
* The final example displays the resulting date in a custom format using the `formatDate` property.
*/
const DatePickerExampleInternational = () => (
<div>
<DatePicker
hintText="fr locale"
DateTimeFormat={DateTimeFormat}
okLabel="OK"
cancelLabel="Annuler"
locale="fr"
/>
<DatePicker
hintText="fa-IR locale"
DateTimeFormat={DateTimeFormat}
okLabel="تایید"
cancelLabel="لغو"
locale="fa-IR"
/>
<DatePicker
hintText="en-US locale"
locale="en-US"
firstDayOfWeek={0}
/>
<DatePicker
hintText="Custom date format"
firstDayOfWeek={0}
formatDate={new DateTimeFormat('en-US', {
day: 'numeric',
month: 'long',
year: 'numeric',
}).format}
/>
</div>
);
export default DatePickerExampleInternational;
|
src/svg-icons/image/slideshow.js | igorbt/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let ImageSlideshow = (props) => (
<SvgIcon {...props}>
<path d="M10 8v8l5-4-5-4zm9-5H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H5V5h14v14z"/>
</SvgIcon>
);
ImageSlideshow = pure(ImageSlideshow);
ImageSlideshow.displayName = 'ImageSlideshow';
ImageSlideshow.muiName = 'SvgIcon';
export default ImageSlideshow;
|
src/ModalDialog.js | andrew-d/react-bootstrap | /*eslint-disable react/prop-types */
import React from 'react';
import classNames from 'classnames';
import BootstrapMixin from './BootstrapMixin';
const ModalDialog = React.createClass({
mixins: [ BootstrapMixin ],
propTypes: {
/**
* A Callback fired when the header closeButton or non-static backdrop is clicked.
* @type {function}
* @required
*/
onHide: React.PropTypes.func.isRequired,
/**
* A css class to apply to the Modal dialog DOM node.
*/
dialogClassName: React.PropTypes.string
},
getDefaultProps() {
return {
bsClass: 'modal',
closeButton: true
};
},
render() {
let modalStyle = { display: 'block'};
let bsClass = this.props.bsClass;
let dialogClasses = this.getBsClassSet();
delete dialogClasses.modal;
dialogClasses[`${bsClass}-dialog`] = true;
return (
<div
{...this.props}
title={null}
tabIndex="-1"
role="dialog"
style={modalStyle}
className={classNames(this.props.className, bsClass)}
>
<div className={classNames(this.props.dialogClassName, dialogClasses)}>
<div className={`${bsClass}-content`} role='document'>
{ this.props.children }
</div>
</div>
</div>
);
}
});
export default ModalDialog;
|
react16-feature/src/App.js | wefine/reactjs-guide | import React, { Component } from 'react';
import ReactDOM from 'react-dom';
class Overlay extends Component {
constructor(props) {
super(props);
this.container = document.createElement('div');
document.body.appendChild(this.container);
}
componentWillUnmount() {
document.body.removeChild(this.container);
}
render() {
return ReactDOM.createPortal(
<div className="overlay">
<span className="overlay__close" onClick={this.props.onClose}>
×
</span>
{this.props.children}
</div>,
this.container
);
}
}
class App extends Component {
constructor(props) {
super(props);
this.state = { overlayActive: true };
}
closeOverlay() {
this.setState({ overlayActive: false });
}
render() {
return (
<div>
<h2>Dashboard</h2>
{this.state.overlayActive && <Overlay onClose={this.closeOverlay.bind(this)}>overlay content</Overlay>}
</div>
);
}
}
export default App;
|
src/components/DeviceCardComponent.js | hzburki/innexiv-front-end | import React, { Component } from 'react';
import { Panel, Col } from 'react-bootstrap';
import { Link } from 'react-router';
class DeviceCardComponent extends Component {
state = {
id: this.props.device.id,
}
onDeviceClick() {
this.props.deviceClick(this.state.id);
}
render() {
const { enteries, device } = this.props;
return (
<Col md={4} sm={6} xs={12} onClick={this.onDeviceClick.bind(this)}>
<Panel header={device.location}>
<h4>Device ID: {device.id}</h4>
<span style={{ fontSize: 12 }}>Total Number of Enteries: {enteries}</span>
</Panel>
</Col>
);
}
}
export default DeviceCardComponent;
|
src/js/components/Camera.js | deluxe-pig/Aquila | import {Entity} from 'aframe-react';
import React from 'react';
export default props => (
<Entity>
<Entity camera="" look-controls="" wasd-controls="" {...props}/>
</Entity>
);
|
react/src/SpinnerDonut.js | Chalarangelo/react-mini.css | import React from 'react';
// Module constants (change according to your flavor file)
var spinnerDonutClassName = 'spinner-donut';
// Donut Spinner component.
export function SpinnerDonut (props){
var outProps = Object.assign({}, props);
if (typeof outProps.children !== 'undefined') throw "Error: A 'SpinnerDonut' component must not have any children.";
if (typeof outProps.progressBar === 'undefined') outProps.progressBar = false;
if (typeof outProps.elementType === 'undefined') outProps.elementType = 'div';
if (typeof outProps.className === 'undefined')
outProps.className = spinnerDonutClassName;
else
outProps.className += ' ' + spinnerDonutClassName;
if (outProps.progressBar)
outProps.role = 'progressbar';
delete outProps.progressBar;
var elementType = outProps.elementType == 'span' ? 'span' : 'div';
delete outProps.elementType;
return React.createElement(
elementType, outProps, outProps.children
);
}
|
src/svg-icons/toggle/star-border.js | manchesergit/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let ToggleStarBorder = (props) => (
<SvgIcon {...props}>
<path d="M22 9.24l-7.19-.62L12 2 9.19 8.63 2 9.24l5.46 4.73L5.82 21 12 17.27 18.18 21l-1.63-7.03L22 9.24zM12 15.4l-3.76 2.27 1-4.28-3.32-2.88 4.38-.38L12 6.1l1.71 4.04 4.38.38-3.32 2.88 1 4.28L12 15.4z"/>
</SvgIcon>
);
ToggleStarBorder = pure(ToggleStarBorder);
ToggleStarBorder.displayName = 'ToggleStarBorder';
ToggleStarBorder.muiName = 'SvgIcon';
export default ToggleStarBorder;
|
main.js | FindEarth/app | import Expo from 'expo'
import React from 'react'
import { Platform, StatusBar, View } from 'react-native'
import { NavigationProvider, StackNavigation } from '@expo/ex-navigation'
import { FontAwesome } from '@expo/vector-icons'
import Router from './navigation/Router'
import cacheAssetsAsync from './utilities/cacheAssetsAsync'
import styles from './styles/AppContainer'
import { Provider } from 'react-redux'
import store from './store'
class AppContainer extends React.Component {
state = {
appIsReady: false,
}
componentWillMount() {
this._loadAssetsAsync()
}
async _loadAssetsAsync() {
try {
await cacheAssetsAsync({
images: [
require('./assets/images/userM.png'),
require('./assets/images/userF.png'),
],
fonts: [
FontAwesome.font,
{ 'space-mono': require('./assets/fonts/SpaceMono-Regular.ttf') },
],
})
} catch (e) {
console.warn(
'There was an error caching assets (see: main.js), perhaps due to a ' +
'network timeout, so we skipped caching. Reload the app to try again.'
)
console.log(e.message)
} finally {
this.setState({ appIsReady: true })
}
}
render() {
if (!this.state.appIsReady) {
return <Expo.AppLoading />
}
return (
<Provider store={store}>
<View style={styles.container}>
<NavigationProvider router={Router}>
<StackNavigation
id="root"
initialRoute={Router.getRoute('rootNavigation')}
/>
</NavigationProvider>
{Platform.OS === 'ios' && <StatusBar barStyle='dark-content' />}
</View>
</Provider>
)
}
}
Expo.registerRootComponent(AppContainer)
|
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.