path stringlengths 5 195 | repo_name stringlengths 5 79 | content stringlengths 25 1.01M |
|---|---|---|
src/components/Select/Select.js | ilyagru/react-currency-converter | import React from 'react';
import Option from '../Option';
function Select(props) {
const { selectedCurrency, handleSelectChange, rates } = props;
let options = rates;
if (options !== undefined) {
options = options.map((rate, index) => {
return <Option currency={rate.currency} key={rate.currency}/>;
});
}
return (
<select value={selectedCurrency} onChange={handleSelectChange}>
<Option currency={selectedCurrency} key={selectedCurrency}/>>
{options}
</select>
);
}
export default Select;
|
src/clincoded/static/components/score/viewer.js | ClinGen/clincoded | 'use strict';
import React from 'react';
import PropTypes from 'prop-types';
import createReactClass from 'create-react-class';
import CASE_INFO_TYPES from './constants/case_info_types';
import { getAffiliationName } from '../../libs/get_affiliation_name';
var _ = require('underscore');
// Render scores viewer in Gene Curation Interface
var ScoreViewer = module.exports.ScoreViewer = createReactClass({
propTypes: {
session: PropTypes.object, // Session object passed from parent
evidence: PropTypes.object, // Individual, Experimental or Case Control
otherScores: PropTypes.bool, // TRUE if we only want show scores by others
affiliation: PropTypes.object // Affiliation object passed from parent
},
getInitialState() {
return {
evidenceScores: [] // One or more scores
};
},
componentDidMount() {
this.loadData();
},
loadData() {
let evidenceObj = this.props.evidence;
// Get evidenceScore object for the logged-in user if exists
if (evidenceObj.scores && evidenceObj.scores.length) {
this.setState({evidenceScores: evidenceObj.scores});
}
},
// Find the scores owned by other users
getOtherScores(evidenceScores) {
let validScores = [], filteredScores = [];
let user = this.props.session && this.props.session.user_properties;
let otherScores = this.props.otherScores;
let affiliation = this.props.affiliation;
if (evidenceScores && evidenceScores.length) {
if (otherScores) {
filteredScores = evidenceScores.filter(score => {
if (affiliation && Object.keys(affiliation).length) {
return !score.affiliation || score.affiliation !== affiliation.affiliation_id;
} else {
return score.submitted_by.uuid !== user.uuid || score.affiliation;
}
});
} else {
filteredScores = evidenceScores;
}
}
// Insanity check for erroneous score objects with Score Status value as 'none'
_.map(filteredScores, score => {
if (score.scoreStatus !== 'none') {
validScores.push(score);
}
});
return validScores;
},
render() {
// states
let evidenceScores = this.state.evidenceScores;
// variables
let scores = this.getOtherScores(evidenceScores);
let affiliation = this.props.affiliation;
return (
<div className="row">
{scores.length ?
scores.map((item, i) => {
return (
<div key={i} className="evidence-score-list-viewer">
<h5>Curator: {item.affiliation ? getAffiliationName(item.affiliation) : item.submitted_by.title}</h5>
<div>
{item.scoreStatus && item.scoreStatus !== 'none' && this.props.evidence['@type'][0] !== 'caseControl' ?
<dl className="dl-horizontal">
<dt>Score Status</dt>
<dd>{item.scoreStatus}</dd>
</dl>
: null}
{item.caseInfoType ?
<dl className="dl-horizontal">
<dt>Case Information Type</dt>
<dd>{renderCaseInfoType(item.caseInfoType)}</dd>
</dl>
: null}
{item.calculatedScore ?
<dl className="dl-horizontal">
<dt>Default Score</dt>
<dd>{item.calculatedScore}</dd>
</dl>
: null}
{item.score ?
<dl className="dl-horizontal">
<dt>Changed Score</dt>
<dd>{item.score}</dd>
</dl>
: null}
{item.scoreExplanation ?
<dl className="dl-horizontal">
<dt>Reaon(s) for score change</dt>
<dd>{item.scoreExplanation}</dd>
</dl>
: null}
</div>
</div>
);
})
:
<span className="other-score-status-note">This evidence has not been scored by other curators.</span>
}
</div>
);
},
});
// Transform the stored Case Information type 'value' into 'description'
function renderCaseInfoType(value) {
let description;
// Put CASE_INFO_TYPES object keys into an array
const caseInfoTypeKeys = Object.keys(CASE_INFO_TYPES);
// Use the 'OTHER' group because it has all 5 Case Information types
let caseInfoTypeGroup = CASE_INFO_TYPES.OTHER;
// Assign different number of variant kinds given a matched modeInheritance
caseInfoTypeGroup.forEach(item => {
if (value === item.TYPE) {
description = item.DESCRIPTION;
}
});
return description;
}
|
components/devices.js | gembarrett/hamara-internet-app | import React from 'react';
import { StyleSheet, ImageBackground, TouchableOpacity, Text, View, Button, ScrollView } from 'react-native';
import MenuText from './sub/menuText.js';
import { devices } from '../routes/lvl2.js';
import { prefs } from '../routes/prefs.js';
import { translatedTitle, translatedText } from '../routes/shared.js';
import { globals } from '../styles/globals.js';
import { submenuStyles } from '../styles/submenus.js';
import { menuStyles } from '../styles/menus.js';
import { icons } from '../content/images.js';
export default class DevicesScreen extends React.Component {
static navigationOptions = {
title: prefs.language === "pk" ? devices[0].textPK : devices[0].textEN,
}
get buttons() {
var buttonsListArr = [];
for (let i = 0; i < devices.length; i++){
const route = devices[i].route;
text = translatedText(devices, i);
buttonsListArr.push(
<View key = {devices[i].id}>
<TouchableOpacity onPress={() => this.props.navigation.navigate(devices[i].route)}>
{prefs.language === 'pk'
? <ImageBackground
source={require('../assets/menu-button-1-pk.png')}
resizeMode="contain"
style={submenuStyles.button}><MenuText>{devices[i].textPK}</MenuText></ImageBackground>
: <ImageBackground
source={require('../assets/menu-button-1-en.png')}
resizeMode="contain"
style={submenuStyles.button}><MenuText>{devices[i].textEN}</MenuText></ImageBackground>}
</TouchableOpacity>
</View>
)
}
return buttonsListArr;
}
render() {
return (
<ScrollView contentContainerStyle={[globals.green, globals.base, globals.menuButtons]}>
<ImageBackground source={icons.devices.uri} style={globals.screenBg} resizeMode="cover">
<View style={[submenuStyles.base]}>
{this.buttons}
</View>
</ImageBackground>
</ScrollView>
);
}
}
|
actor-apps/app-web/src/app/components/activity/UserProfileContactInfo.react.js | sfshine/actor-platform | import _ from 'lodash';
import React from 'react';
import ReactMixin from 'react-mixin';
import addons from 'react/addons';
const {addons: { PureRenderMixin }} = addons;
@ReactMixin.decorate(PureRenderMixin)
class UserProfileContactInfo extends React.Component {
static propTypes = {
phones: React.PropTypes.array
};
constructor(props) {
super(props);
}
render() {
let phones = this.props.phones;
let contactPhones = _.map(phones, (phone, i) => {
return (
<li className="profile__list__item row" key={i}>
<i className="material-icons">call</i>
<div className="col-xs">
<span className="contact">+{phone.number}</span>
<span className="title">{phone.title}</span>
</div>
</li>
);
});
return (
<ul className="profile__list profile__list--contacts">
{contactPhones}
</ul>
);
}
}
export default UserProfileContactInfo;
|
src/toast/toast.js | ricsv/react-leonardo-ui | import React, { Component } from 'react';
import { createPortal } from 'react-dom';
import TOAST_STATE from '../overlay-state';
import { luiClassName } from '../util';
const FADE_DURATION = 200;
let currentId = 0;
const getOrCreateContainer = (parentElement) => {
let element = document.getElementById('lui-toast-container');
if (!element) {
element = document.createElement('div');
element.classList.add('lui-toast-container');
element.id = 'lui-toast-container';
parentElement.appendChild(element);
}
return element;
};
class Toast extends Component {
constructor(props) {
super(props);
currentId += 1;
this.portalId = `rlui-toast-${currentId}`;
this.state = {
toastState: TOAST_STATE.closed,
};
this.openToast = this.openToast.bind(this);
this.closeToast = this.closeToast.bind(this);
if (typeof document !== 'undefined') {
this.parentElement = props.parentElement || document.getElementById('show-service-overlay') || document.body;
}
}
componentDidMount() {
if (this.props.show) {
this.openToast();
}
}
componentDidUpdate(prevProps) {
const { show } = this.props;
if (!prevProps.show && show) {
this.openToast();
} else if (prevProps.show && !show) {
this.closeToast();
}
if (this.state.toastState === TOAST_STATE.opening) {
setTimeout(() => {
this.setState(() => ({
toastState: TOAST_STATE.open,
}));
if (typeof this.props.onOutside === 'function') {
document.addEventListener('click', this.outsideListener);
}
if (typeof this.props.onOpen === 'function') {
this.props.onOpen();
}
});
} else if (this.state.toastState === TOAST_STATE.closing) {
if (typeof this.props.onOutside === 'function') {
document.removeEventListener('click', this.outsideListener);
}
setTimeout(() => {
this.setState(() => ({
toastState: TOAST_STATE.closed,
}));
if (typeof this.props.onClose === 'function') {
this.props.onClose();
}
}, FADE_DURATION);
}
}
openToast() {
this.setState(() => ({
toastState: TOAST_STATE.opening,
}));
}
closeToast() {
this.setState(() => ({
toastState: TOAST_STATE.closing,
}));
}
render() {
const { toastState } = this.state;
if (toastState === TOAST_STATE.closed) {
return null;
}
const {
className,
children,
dock,
alignTo,
inline,
variant,
// Avoid passing
show,
onOpen,
onClose,
parentElement,
...extraProps
} = this.props;
let toastClassName = luiClassName('toast', {
className,
modifiers: { variant },
});
const style = {
bottom: '-50px',
};
if (toastState === TOAST_STATE.opening || toastState === TOAST_STATE.closing) {
toastClassName += ' lui-fade';
} else {
style.bottom = '10px';
}
const containerElement = getOrCreateContainer(this.parentElement);
return (
createPortal(
<div
ref={(el) => { this.toast = el; }}
className={toastClassName}
style={style}
{...extraProps}
>
{children}
</div>,
containerElement
)
);
}
}
export default Toast;
|
contrib/webui/src/arxiv/row/index.js | roscopecoltran/papernet | import React from 'react';
import { List } from 'immutable';
import { Link } from 'react-router';
import moment from 'moment';
import PropTypes from 'prop-types';
import Tooltip from 'rc-tooltip';
import 'rc-tooltip/assets/bootstrap.css';
import ReadMoreMarkdown from 'components/markdown/read-more';
import TagList from 'components/taglist';
import { paperPropType } from 'utils/constants';
import './row.scss';
const extractAbstract = (text) => {
const stops = ['#', '\n'];
let end = text.length;
stops.forEach((stop) => {
const i = text.indexOf(stop);
if (i > 0 && i < end) {
end = i;
}
});
return text.substring(0, end);
};
const ImportButtonOrLink = ({ paperID, onImport }) => {
if (paperID !== 0) {
return (
<Link
className="btn btn-sm btn-outline-primary"
to={`papers/${paperID}`}
>
See on Papernet
</Link>
);
}
return (
<button className="btn btn-sm btn-primary" onClick={onImport}>
Import in Papernet
</button>
);
};
ImportButtonOrLink.propTypes = {
paperID: PropTypes.number.isRequired,
onImport: PropTypes.func.isRequired,
};
const ImportRow = ({ onImport, paper }) => {
const abstract = extractAbstract(paper.get('summary'));
const tags = paper.get('tags') || List();
return (
<div className="ImportRow card">
<div className="card-block">
<h5 className="card-title">{paper.get('title')}</h5>
<ReadMoreMarkdown text={abstract} />
<div className="card-text ImportRow__Links">
<ImportButtonOrLink paperID={paper.get('id')} onImport={onImport} />
<a
href={paper.getIn(['references', 0])}
className="btn btn-sm btn-outline-primary"
target="_blank"
rel="noopener noreferrer"
>
See on arXiv
</a>
<a
href={paper.getIn(['references', 1])}
className="btn btn-sm btn-outline-primary"
target="_blank"
rel="noopener noreferrer"
>
PDF
</a>
</div>
<p className="card-text">
<small
className="text-muted"
data-for={paper.get('id').toString()}
data-tip
>
<Tooltip
placement="bottom"
mouseEnterDelay={0.3}
overlay={<small>{moment(paper.get('updatedAt')).format('LLL')}</small>}
>
<span>Modified {moment(paper.get('updatedAt')).fromNow()}</span>
</Tooltip>
</small>
</p>
</div>
<div className="card-footer">
<div className="ImportRow__Tags">
<i className="fa fa-tag" />
<TagList tags={tags} max={5} />
</div>
</div>
</div>
);
};
ImportRow.propTypes = {
onImport: PropTypes.func.isRequired,
paper: paperPropType.isRequired,
};
export default ImportRow;
|
templates/rubix/demo/src/routes/Codemirrorjs.js | jeffthemaximum/jeffline | import React from 'react';
import {
Row,
Col,
Grid,
Panel,
PanelBody,
PanelHeader,
FormControl,
PanelContainer,
} from '@sketchpixy/rubix';
import codesnippet from './codesnippet.txt';
export default class Codemirrorjs extends React.Component {
componentDidMount() {
var editor = CodeMirror.fromTextArea($('#code').get(0), {
lineNumbers: true,
styleActiveLine: true,
matchBrackets: true,
theme: 'ambiance'
});
}
render() {
return (
<div>
<Row>
<Col sm={12}>
<PanelContainer>
<PanelHeader className='bg-blue fg-white' style={{margin: 0}}>
<Grid>
<Row>
<Col xs={12}>
<h3>Codemirror</h3>
</Col>
</Row>
</Grid>
</PanelHeader>
<PanelBody>
<Grid>
<Row>
<Col xs={12} style={{padding: 25}}>
<FormControl componentClass='textarea' id='code' name='code' defaultValue={codesnippet} />
</Col>
</Row>
</Grid>
</PanelBody>
</PanelContainer>
</Col>
</Row>
</div>
);
}
}
|
src/svg-icons/editor/insert-comment.js | spiermar/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let EditorInsertComment = (props) => (
<SvgIcon {...props}>
<path d="M20 2H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h14l4 4V4c0-1.1-.9-2-2-2zm-2 12H6v-2h12v2zm0-3H6V9h12v2zm0-3H6V6h12v2z"/>
</SvgIcon>
);
EditorInsertComment = pure(EditorInsertComment);
EditorInsertComment.displayName = 'EditorInsertComment';
EditorInsertComment.muiName = 'SvgIcon';
export default EditorInsertComment;
|
src/components/catalog/Catalog.js | dloret/support-hub | import React from 'react';
import './Catalog.css';
import dataSource from '../../assets/data-sources/links.json';
import {Title} from './Title';
const menus = [...new Set(dataSource.map((link) => link.context))];
export default class Catalog extends React.Component {
constructor(props) {
super(props);
this.state = {
selectedMenu: (this.props.location.pathname.slice(1)) ? this.props.location.pathname.slice(1) : menus[0],
items: '',
titles: '',
};
}
componentWillMount() {
this.setState({
items: dataSource.filter((item) => item.context === this.state.selectedMenu),
titles: [...new Set(dataSource.filter((item) => item.context === this.state.selectedMenu).map((item) => item.category))],
})
}
componentWillReceiveProps(nextProps) {
if (nextProps.location.pathname.slice(1) !== this.props.location.pathname.slice(1)) {
this.setState({
selectedMenu: nextProps.location.pathname.slice(1),
items: dataSource.filter((item) => item.context === nextProps.location.pathname.slice(1)),
titles: [...new Set(dataSource.filter((item) => item.context === nextProps.location.pathname.slice(1)).map((item) => item.category))],
})
}
}
render() {
return (
<div>
<ul>
{this.state.titles.map(
title => <Title
key={title}
title={title}
items={this.state.items} />
)}
</ul>
</div>
)
}
} |
example/src/components/legend-options.js | jerairrest/react-chartjs-2 | import React from 'react';
import {Pie} from 'react-chartjs-2';
const data = {
labels: [
'Red',
'Green',
'Yellow'
],
datasets: [{
data: [300, 50, 100],
backgroundColor: [
'#FF6384',
'#36A2EB',
'#FFCE56'
],
hoverBackgroundColor: [
'#FF6384',
'#36A2EB',
'#FFCE56'
]
}]
};
const legendOpts = {
display: true,
position: 'top',
fullWidth: true,
reverse: false,
labels: {
fontColor: 'rgb(255, 99, 132)'
}
};
export default React.createClass({
displayName: 'LegendExample',
getInitialState() {
return {
legend: legendOpts
}
},
applyLegendSettings() {
const { value } = this.legendOptsInput;
try {
const opts = JSON.parse(value);
this.setState({
legend: opts
});
} catch(e) {
alert(e.message);
throw Error(e);
}
},
render() {
return (
<div>
<h2>Legend Options Example</h2>
<textarea
cols="40"
rows="15"
ref={input => { this.legendOptsInput = input; }}
defaultValue={JSON.stringify(this.state.legend, null, 2)}></textarea>
<div>
<button onClick={this.applyLegendSettings}>Apply legend settings</button>
</div>
<Pie data={data} legend={this.state.legend} redraw />
</div>
);
}
}) |
imports/client/ui/pages/WhitePaper/Why/Content.js | mordka/fl-events | // External Libraries
import React from 'react'
import { Container, Col } from 'reactstrap'
// Internal Imports
import DCSLink from '/imports/client/ui/components/DCSLink/index.js'
import i18n from '/imports/both/i18n/en/'
const Content = (props) => {
return (
<React.Fragment>
<Container className="mt-5 mb-4">
<h1>The World Needs a Public Happiness Economy Because:</h1>
<br />
<h3>Short</h3>
</Container>
{i18n.Whitepaper.Why.concise.map((item, index) => {
return (
<Col key={index} className="pl-5 mt-3 wp-item" xs={11}>
<details>
<summary>
<h5>{item.heading} </h5>
<DCSLink
badge="true"
format="speech-bubble"
title=" "
subtitle="discuss"
triggerId={`short${index + 1}`}
display="inline"
/>
</summary>
<li className="mb-1 mt-2 text-left">{item.text}</li>
</details>
</Col>
);
})}
<Container className="mt-5 mb-4">
<h3>Longer</h3>
</Container>
{i18n.Whitepaper.Why['more depth'].map((item, index) => {
return (
<Col key={index} className="pl-5 mt-3 wp-item" xs={11}>
<details>
<summary>
<h5>{item.heading} </h5>
<DCSLink
badge="true"
format="speech-bubble"
title=" "
subtitle="discuss"
triggerId={`longer${index + 1}`}
display="inline"
/>
</summary>
<li className="mb-1 mt-2 text-left">{item.text}</li>
<li className="mb-1 text-left">{item.answer}</li>
</details>
</Col>
);
})}
</React.Fragment>
);
}
export default Content
|
docs/src/app/components/pages/components/Divider/ExampleMenu.js | spiermar/material-ui | import React from 'react';
import Divider from 'material-ui/Divider';
import {Menu, MenuItem} from 'material-ui/Menu';
const style = {
// Without this, the menu overflows the CodeExample container.
float: 'left',
};
const DividerExampleMenu = () => (
<Menu desktop={true} style={style}>
<MenuItem primaryText="Settings" />
<MenuItem primaryText="Help & feedback" />
<Divider />
<MenuItem primaryText="Sign out" />
</Menu>
);
export default DividerExampleMenu;
|
app/containers/StatusPage/index.js | liuyanghejerry/react-westworld | /*
*
* StatusPage
*
*/
import React from 'react';
import { connect } from 'react-redux';
import selectStatusPage from './selectors';
// import { FormattedMessage } from 'react-intl';
import styled from 'styled-components';
// import messages from './messages';
import { LargeProgressBar, SmallProgressBar } from '../../components/HorizontalProgressBar';
import PropertyCircle from '../../components/PropertyCircle';
import Profile from '../../components/Profile';
const Layout = styled.div`
display: flex;
align-items: flex-end;
align-content: space-around;
padding: 4px;
& > * {
flex-shrink: 0;
flex-grow: 0;
}
`;
const ProfileLayout = styled.div`
position: absolute;
top: 0;
right: 4px;
`;
const FakeGroupContent = styled.div`
width: 100px;
height: 300px;
`;
const ProgressBarLayout = styled.div`
display: flex;
flex-direction: column;
& > * {
margin: 0 0 20px 0;
&:last-child {
margin: 0;
}
}
`;
export class StatusPage extends React.PureComponent { // eslint-disable-line react/prefer-stateless-function
render() {
return (
<Layout>
<ProfileLayout>
<Profile
hostId={this.props.profile.hostId}
tags={this.props.profile.tags}
metrics={this.props.profile.metrics}
liveStatusInfo={this.props.profile.liveStatusInfo}
liveNumbers={this.props.profile.liveNumbers}
/>
</ProfileLayout>
<PropertyCircle
properties={this.props.personalities}
selectedItem={this.props.selectedItem}
/>
<FakeGroupContent></FakeGroupContent>
<LargeProgressBar
min={this.props.bulkApperception.min} max={this.props.bulkApperception.max} current={this.props.bulkApperception.current} title={this.props.bulkApperception.title}
/>
<ProgressBarLayout>
<SmallProgressBar
min={this.props.cordination.min} max={this.props.cordination.max} current={this.props.cordination.current} title={this.props.cordination.title}
/>
<SmallProgressBar
min={this.props.aggression.min} max={this.props.aggression.max} current={this.props.aggression.current} title={this.props.aggression.title}
/>
</ProgressBarLayout>
<ProgressBarLayout>
<SmallProgressBar
min={this.props.selfPreservation.min} max={this.props.selfPreservation.max} current={this.props.selfPreservation.current} title={this.props.selfPreservation.title}
/>
<SmallProgressBar
min={this.props.loyalty.min} max={this.props.loyalty.max} current={this.props.loyalty.current} title={this.props.loyalty.title}
/>
</ProgressBarLayout>
</Layout>
);
}
}
const mapStateToProps = selectStatusPage();
function mapDispatchToProps(dispatch) {
return {
dispatch,
};
}
export default connect(mapStateToProps, mapDispatchToProps)(StatusPage);
|
website/src/pages/index.js | facebook/litho | /**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* 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.
*
* @format
*/
import React from 'react';
import clsx from 'clsx';
import Layout from '@theme/Layout';
import Link from '@docusaurus/Link';
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
import useBaseUrl from '@docusaurus/useBaseUrl';
import styles from './styles.module.scss';
const features = [
{
title: <>Declarative</>,
imageUrl: 'images/home-code.png',
description: (
<>
Litho uses a declarative API to define UI components. You simply
describe the layout for your UI based on a set of immutable inputs and
the framework takes care of the rest. With code generation, Litho can
perform optimisations for your UI under the hood, while keeping your
code simple and easy to maintain.
</>
),
dark: false,
},
{
title: <>Asynchronous layout</>,
imageUrl: 'images/home-async.png',
description: (
<>
Litho can measure and layout your UI ahead of time without blocking the
UI thread. By decoupling its layout system from the traditional Android
View system, Litho can drop the UI thread constraint imposed by Android.
</>
),
dark: true,
},
{
title: <>Flatter view hierarchies</>,
imageUrl: 'images/home-flat-not-flat.png',
description: (
<>
Litho uses <a href="https://yogalayout.com/docs">Yoga</a> for layout and
automatically reduces the number of ViewGroups that your UI contains.
This, in addition to Litho's text optimizations, allows for much smaller
view hierarchies and improves both memory and scroll performance.
</>
),
dark: false,
},
{
title: <>Fine-grained recycling</>,
imageUrl: 'images/home-incremental-mount.png',
description: (
<>
With Litho, each UI item such as text, image, or video is recycled
individually. As soon as an item goes off screen, it can be reused
anywhere in the UI and pieced together with other items to create new UI
elements. Such recycling reduces the need of having multiple view types
and improves memory usage and scroll performance.
</>
),
dark: true,
},
];
function Feature({imageUrl, title, description, dark}) {
const imgUrl = useBaseUrl(imageUrl);
return (
<section
className={clsx(
dark && styles.darkFeature,
!dark && styles.lightFeature,
)}>
<div className={styles.featureContent}>
<img className={styles.featureImage} src={imgUrl} alt={title} />
<div className={styles.featureText}>
<h3 className={styles.featureTitle}>{title}</h3>
<p className={styles.featureBody}>{description}</p>
</div>
</div>
</section>
);
}
function VideoContainer() {
return (
<div className="container text--center margin-bottom--xl margin-top--lg">
<div className="row">
<div className="col">
<h2>Check it out in the intro video</h2>
<div className={styles.ytVideo}>
<iframe
width="560"
height="315"
src="https://www.youtube.com/embed/RFI-fuiMRK4"
title="Explain Like I'm 5: Litho"
frameBorder="0"
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
allowFullScreen
/>
</div>
</div>
</div>
</div>
);
}
function Home() {
const context = useDocusaurusContext();
const {siteConfig = {}} = context;
return (
<Layout description="Home page of Litho: A declarative UI framework for Android">
<div className={styles.heroBanner}>
<div className={styles.heroInner}>
<img
className={styles.heroImage}
src={useBaseUrl('images/logo.svg')}
/>
<div className={styles.heroTitle}>
{'Litho: ' + siteConfig.tagline}
</div>
<div className={styles.buttons}>
<Link
className={clsx('button button--outline', styles.button)}
to={useBaseUrl('docs/mainconcepts/components-basics')}>
GET STARTED
</Link>
<Link
className={clsx('button button--outline', styles.button)}
to={useBaseUrl('docs/intro')}>
LEARN MORE
</Link>
<Link
className={clsx('button button--outline', styles.button)}
to={useBaseUrl('docs/tutorial/overview')}>
TUTORIAL
</Link>
</div>
</div>
</div>
<main>
<div>
<div className={styles.banner}>
Support Ukraine 🇺🇦{' '}
<Link to="https://opensource.facebook.com/support-ukraine">
Help Provide Humanitarian Aid to Ukraine
</Link>
.
</div>
</div>
<VideoContainer />
{features &&
features.length > 0 &&
features.map((props, idx) => <Feature key={idx} {...props} />)}
</main>
</Layout>
);
}
export default Home;
|
tp-3/marisol/src/components/pages/about/AboutPage.js | jpgonzalezquinteros/sovos-reactivo-2017 | import React from 'react';
// Since this component is simple and static, there's no parent container for it.
const AboutPage = () => {
return (
<div>
<h2 className="alt-header">About Me</h2>
<p>
About Page
</p>
</div>
);
};
export default AboutPage;
|
src/app/core/atoms/icon/icons/anchor.js | blowsys/reservo | import React from 'react'; const Anchor = (props) => <svg {...props} viewBox="0 0 24 24"><g><g><path d="M12.0361,20 C8.3661,20 4.9791,18.005 3.1971,14.794 L4.9461,13.823 C6.2061,16.094 8.4661,17.603 11.0001,17.93 L11.0001,10.013 L6.7371,8.308 C6.4801,8.205 6.3111,7.956 6.3111,7.678 C6.3111,7.304 6.6151,7 6.9891,7 L10.0001,7 L10.0001,5 C10.0001,3.895 10.8951,3 12.0001,3 C13.1041,3 14.0001,3.895 14.0001,5 L14.0001,7 L17.0101,7 C17.3851,7 17.6891,7.304 17.6891,7.678 C17.6891,7.956 17.5201,8.205 17.2621,8.308 L13.0001,10.013 L13.0001,17.935 C15.5621,17.627 17.8541,16.115 19.1251,13.823 L20.8741,14.794 C19.0921,18.005 15.7051,20 12.0361,20 Z"/></g></g></svg>; export default Anchor;
|
src/svg-icons/maps/local-printshop.js | matthewoates/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let MapsLocalPrintshop = (props) => (
<SvgIcon {...props}>
<path d="M19 8H5c-1.66 0-3 1.34-3 3v6h4v4h12v-4h4v-6c0-1.66-1.34-3-3-3zm-3 11H8v-5h8v5zm3-7c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1zm-1-9H6v4h12V3z"/>
</SvgIcon>
);
MapsLocalPrintshop = pure(MapsLocalPrintshop);
MapsLocalPrintshop.displayName = 'MapsLocalPrintshop';
MapsLocalPrintshop.muiName = 'SvgIcon';
export default MapsLocalPrintshop;
|
Examples/SlideButtonExample/SlideButtonExample.js | sreejithr/react-native-slide-button | /**
* Slide Button Example Component
**/
'use strict';
import React, { Component } from 'react';
import {
StyleSheet,
Text,
View,
Image
} from 'react-native';
import { SlideButton, SlideDirection } from 'react-native-slide-button';
var Dimensions = require('Dimensions');
var SCREEN_WIDTH = Dimensions.get('window').width;
const NORMAL_COLOR = '#0FACF3';
const SUCCESS_COLOR = '#39ca74';
export default class SlideButtonExample extends Component {
constructor(props) {
super(props);
this.state = {
swiped: false,
leftSwiped: false,
rightSwiped: false,
};
}
onLeftSlide() {
var self = this;
this.setState({swiped: true, leftSwiped: true}, () => {
setTimeout(() => self.setState({swiped: false, leftSwiped: false}), 2500);
});
}
onRightSlide() {
var self = this;
this.setState({swiped: true, rightSwiped: true}, () => {
setTimeout(() => self.setState({swiped: false, rightSwiped: false}), 2500);
});
}
onBothSlide() {
var self = this;
this.setState({swiped: true, bothSwiped: true}, () => {
setTimeout(() => self.setState({swiped: false, bothSwiped: false}), 2500);
});
}
render() {
var message = this.state.swiped ? "Slide Successful!" : "Slide Any Button";
var messageColor = this.state.swiped ? SUCCESS_COLOR : NORMAL_COLOR;
var leftButtonColor = this.state.leftSwiped ? SUCCESS_COLOR : NORMAL_COLOR;
var rightButtonColor = this.state.rightSwiped ? SUCCESS_COLOR : NORMAL_COLOR;
var bothButtonColor = this.state.bothSwiped ? SUCCESS_COLOR : NORMAL_COLOR;
return (
<View style={styles.container}>
<View>
<Text style={{color: messageColor}}>
{message}
</Text>
</View>
<View style={{marginTop: 20, backgroundColor: rightButtonColor}}>
<SlideButton
onSlideSuccess={this.onRightSlide.bind(this)}
width={SCREEN_WIDTH-40}
height={50}>
<View style={styles.buttonInner}>
<Text style={styles.button}>Slide Right</Text>
</View>
</SlideButton>
</View>
<View style={{marginTop: 20, backgroundColor: leftButtonColor}}>
<SlideButton
onSlideSuccess={this.onLeftSlide.bind(this)}
slideDirection={SlideDirection.LEFT}
width={SCREEN_WIDTH-40}
height={50}>
<View style={styles.buttonInner}>
<Text style={styles.button}>Slide Left</Text>
</View>
</SlideButton>
</View>
<View style={{marginTop: 20, backgroundColor: bothButtonColor}}>
<SlideButton
onSlideSuccess={this.onBothSlide.bind(this)}
slideDirection={SlideDirection.BOTH}
width={SCREEN_WIDTH-40}
height={50}>
<View style={styles.buttonInner}>
<Text style={styles.button}>Slide Any Direction</Text>
</View>
</SlideButton>
</View>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center'
},
buttonOuter: {
marginTop: 20
},
buttonInner: {
width: SCREEN_WIDTH-40,
height: 50,
justifyContent: 'center',
alignItems: 'center'
},
button: {
color: 'white',
fontSize: 15,
fontWeight: 'bold'
}
});
|
docs/pages/blog/april-2019-update.js | lgollut/material-ui | import React from 'react';
import TopLayoutBlog from 'docs/src/modules/components/TopLayoutBlog';
import { prepareMarkdown } from 'docs/src/modules/utils/parseMarkdown';
const pageFilename = 'blog/april-2019-update';
const requireRaw = require.context('!raw-loader!./', false, /april-2019-update\.md$/);
export default function Page({ docs }) {
return <TopLayoutBlog docs={docs} />;
}
Page.getInitialProps = () => {
const { demos, docs } = prepareMarkdown({ pageFilename, requireRaw });
return { demos, docs };
};
|
src/components_backup/Feedback/Feedback.js | justincdalton/iso-birchbox | /*! React Starter Kit | MIT License | http://www.reactstarterkit.com/ */
import React from 'react';
import styles from './Feedback.less';
import withStyles from '../../decorators/withStyles';
@withStyles(styles)
class Feedback {
render() {
return (
<div className="Feedback">
<div className="Feedback-container">
<a className="Feedback-link" href="https://gitter.im/kriasoft/react-starter-kit">Ask a question</a>
<span className="Feedback-spacer">|</span>
<a className="Feedback-link" href="https://github.com/kriasoft/react-starter-kit/issues/new">Report an issue</a>
</div>
</div>
);
}
}
export default Feedback;
|
features/apimgt/org.wso2.carbon.apimgt.admin.feature/src/main/resources/admin/source/src/app/components/Shared/Message.js | Minoli/carbon-apimgt | /*
* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import React from 'react';
import Snackbar from 'material-ui/Snackbar';
import IconButton from 'material-ui/IconButton';
import CloseIcon from '@material-ui/icons/Close';
import Info from '@material-ui/icons/Info';
import Error from '@material-ui/icons/Error';
import Warning from '@material-ui/icons/Warning';
class Message extends React.Component {
constructor(props) {
super(props);
this.state = {
open: false,
message: '',
type: '',
};
this.info = this.info.bind(this);
this.error = this.error.bind(this);
this.warning = this.warning.bind(this);
this.handleRequestClose = this.handleRequestClose.bind(this);
}
info(message) {
this.setState({ open: true, type: 'info', message });
}
error(message) {
this.setState({ open: true, type: 'error', message });
}
warning(message) {
this.setState({ open: true, type: 'warning', message });
}
handleRequestClose(event, reason) {
if (reason === 'clickaway') {
return;
}
this.setState({ open: false });
}
render() {
return (
<Snackbar
anchorOrigin={{
vertical: 'top',
horizontal: 'center',
}}
open={this.state.open}
autoHideDuration={12000}
onClose={this.handleRequestClose}
SnackbarContentProps={{
'aria-describedby': 'message-id',
}}
message={
<div id='message-id' className='message-content-box'>
{this.state.type === 'info' && <Info />}
{this.state.type === 'error' && <Error />}
{this.state.type === 'warning' && <Warning />}
<span>{this.state.message}</span>
</div>
}
action={[
<IconButton key='close' aria-label='Close' color='inherit' onClick={this.handleRequestClose}>
<CloseIcon />
</IconButton>,
]}
/>
);
}
}
export default Message;
|
src/components/MaintainSources/MaintainSources.js | RegOpz/RegOpzWebApp | import React, { Component } from 'react';
import ReactDOM from 'react-dom';
import { connect } from 'react-redux';
import { bindActionCreators, dispatch } from 'redux';
import { Link } from 'react-router';
import _ from 'lodash';
import DatePicker from 'react-datepicker';
import moment from 'moment';
import {
actionFetchSources
} from '../../actions/MaintainSourcesAction';
import {
actionLeftMenuClick,
} from '../../actions/LeftMenuAction';
import SourceCatalogList from './SourceCatalog';
import AddSources from './AddSources/AddSources';
import AuditModal from '../AuditModal/AuditModal';
import ModalAlert from '../ModalAlert/ModalAlert';
require('./MaintainSources.css');
require('react-datepicker/dist/react-datepicker.css');
class MaintainSources extends Component {
constructor(props){
super(props)
this.state = {
sources:null,
itemEditable: true,
display: false,
sourceFileName: null
}
this.formData = {};
this.renderDynamic = this.renderDynamic.bind(this);
this.handleSourceClick = this.handleSourceClick.bind(this);
this.handleAddSourceClick = this.handleAddSourceClick.bind(this);
this.handleClose = this.handleClose.bind(this);
this.handleModalOkayClick = this.handleModalOkayClick.bind(this);
this.handleAuditOkayClick = this.handleAuditOkayClick.bind(this);
this.viewOnly = _.find(this.props.privileges, { permission: "View Sources" }) ? true : false;
this.writeOnly = _.find(this.props.privileges, { permission: "Manage Sources" }) ? true : false;
}
componentWillMount() {
this.props.fetchSources('ALL',this.props.login_details.domainInfo.country);
}
componentDidUpdate() {
console.log("Dates",this.state.startDate);
this.props.leftMenuClick(false);
}
componentWillReceiveProps(nextProps){
console.log("nextProps",this.props.leftmenu);
if(this.props.leftmenu){
this.setState({
display: false
});
}
}
handleSourceClick(item) {
console.log("selected item",item);
this.formData=item;
this.setState({
display: "editSources",
sourceFileName: item.source_file_name
});
}
handleAddSourceClick() {
this.formData={
source_table_name: null,
source_id: null,
country: null,
id: null,
source_description: '',
source_file_name: null,
source_file_delimiter: null,
last_updated_by: null
};
this.setState({
display: "addSources",
sourceFileName: "Adding New Source"
});
}
handleClose() {
this.setState({
display: false,
});
}
renderDynamic(displayOption) {
switch (displayOption) {
case "addSources":
return(
<AddSources
formData={ this.formData }
readOnly={ !this.writeOnly }
requestType={ "add" }
handleClose={ this.handleClose.bind(this) }
/>
);
break;
case "editSources":
return(
<AddSources
formData={ this.formData }
readOnly={ !this.writeOnly }
requestType={ "edit" }
handleClose={ this.handleClose.bind(this) }
/>
);
break;
default:
return(
<SourceCatalogList
sourceCatalog={this.props.sourceCatalog.country}
navMenu={false}
handleSourceClick={this.handleSourceClick}
/>
);
}
}
handleModalOkayClick(event){
// TODO
}
handleAuditOkayClick(auditInfo){
//TODO
}
render(){
if (typeof this.props.sourceCatalog !== 'undefined') {
return(
<div>
<div className="row form-container">
<div className="x_panel">
<div className="x_title">
{
((displayOption) => {
if (!displayOption) {
return(
<h2>Maintain Sources <small>Available Sources to Maintain Definition</small></h2>
);
}
return(
<h2>Maintain Source <small>{' Source '}</small>
<small><i className="fa fa-file-text"></i></small>
<small>{this.state.sourceFileName }</small>
</h2>
);
})(this.state.display)
}
<div className="row">
<ul className="nav navbar-right panel_toolbox">
<li>
<a className="user-profile dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
<i className="fa fa-rss"></i><small>{' Sources '}</small>
<i className="fa fa-caret-down"></i>
</a>
<ul className="dropdown-menu dropdown-usermenu pull-right" style={{ "zIndex": 9999 }}>
<li style={{ "padding": "5px" }}>
<Link to="/dashboard/maintain-sources"
onClick={()=>{ this.setState({ display: false }) }}
>
<i className="fa fa-bars"></i> All Sources List
</Link>
</li>
<li>
<SourceCatalogList
sourceCatalog={this.props.sourceCatalog.country}
navMenu={true}
handleSourceClick={this.handleSourceClick}
/>
</li>
</ul>
</li>
</ul>
{
!this.state.display &&
<ul className="nav navbar-right panel_toolbox">
<li>
<a className="user-profile"
aria-expanded="false"
data-toggle="tooltip"
data-placement="top"
title="Refresh List"
onClick={
(event) => {
this.props.fetchSources('ALL',this.props.login_details.domainInfo.country);
}
}
>
<i className="fa fa-refresh"></i><small>{' Refresh '}</small>
</a>
</li>
</ul>
}
</div>
<div className="clearfix"></div>
</div>
<div className="col col-lg-2">
<button
className="btn btn-success btn-sm"
disabled = { !this.writeOnly }
onClick={()=>{this.handleAddSourceClick()}}>
New Source
</button>
</div>
<div className="x_content">
{
this.renderDynamic(this.state.display)
}
</div>
</div>
</div>
<ModalAlert
ref={(modalAlert) => {this.modalAlert = modalAlert}}
onClickOkay={this.handleModalOkayClick}
/>
< AuditModal showModal={this.state.showAuditModal}
onClickOkay={this.handleAuditOkayClick}
/>
</div>
);
} else {
return(
<h4> Loading.....</h4>
);
}
}
}
function mapStateToProps(state){
console.log("On mapState ", state, state.view_data_store, state.report_store);
return {
//data_date_heads:state.view_data_store.dates,
sourceCatalog: state.source_feeds.sources,
login_details: state.login_store,
leftmenu: state.leftmenu_store.leftmenuclick,
}
}
const mapDispatchToProps = (dispatch) => {
return {
fetchSources:(sources,country)=>{
dispatch(actionFetchSources(sources,country))
},
leftMenuClick:(isLeftMenu) => {
dispatch(actionLeftMenuClick(isLeftMenu));
},
}
}
const VisibleMaintainSources = connect(
mapStateToProps,
mapDispatchToProps
)(MaintainSources);
export default VisibleMaintainSources;
|
components/TodoItem.js | lsgoulart/another-todo-list | import React, { Component } from 'react';
import actions from '../redux/actions';
export default class TodoItem extends Component {
_toggleComplete(_id) {
this.props.dispatch(actions.toggleCompleteTodo(_id));
}
_setPriority(_id) {
this.props.dispatch(actions.setPriorityTodo(_id));
}
_removeTodo(_id) {
this.props.dispatch(actions.removeTodo(_id));
}
_getPriorityColorTriangle(priority) {
let style = '';
switch (priority) {
case 0:
style = 'transparent transparent transparent #81e808';
break;
case 1:
style = 'transparent transparent transparent #ffa800';
break
case 3:
style = 'transparent transparent transparent #eb3e3e';
break
default:
style = 'transparent transparent transparent #eb3e3e';
}
return style;
}
_getPriority(priority) {
switch (priority) {
case 0:
return 'Low';
break;
case 1:
return 'Medium';
break;
case 2:
return 'High';
break;
default:
return 'Low';
}
}
_getPriorityColor(priority, completed) {
let style = '';
switch (priority) {
case 0:
style = '#81e808';
break;
case 1:
style = '#ffa800';
break
case 3:
style = '#eb3e3e';
break
default:
style = '#eb3e3e';
}
return style;
}
render() {
const { todo } = this.props;
return (
<li className="todo">
<div className="priority" onClick={ this._setPriority.bind(this, todo._id) } style={{ backgroundColor: this._getPriorityColor(todo.priority, todo.completed) }}>
<div className="tooltip" style={{ backgroundColor: this._getPriorityColor(todo.priority, todo.completed) }}>
{ this._getPriority(todo.priority) } priority
<div className="triangle" style={{ borderColor: this._getPriorityColorTriangle(todo.priority) }}></div>
</div>
</div>
<div className="complete" onClick={ this._toggleComplete.bind(this, todo._id) }>
<i className="fa fa-check" style={{ color: (todo.completed) ? '#81e808' : '#5a5a58' }}></i>
</div>
<span style={{ textDecoration: (todo.completed) ? 'line-through' : 'none', opacity: (todo.completed) ? .5 : 1}} >{todo.text}</span>
<div className="pull-right">
<div className="remove" onClick={ this._removeTodo.bind(this, todo._id) }>
<i className="fa fa-close"></i>
</div>
</div>
</li>
)
}
}
|
src/svg-icons/device/signal-cellular-connected-no-internet-0-bar.js | matthewoates/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let DeviceSignalCellularConnectedNoInternet0Bar = (props) => (
<SvgIcon {...props}>
<path fillOpacity=".3" d="M22 8V2L2 22h16V8z"/><path d="M20 22h2v-2h-2v2zm0-12v8h2v-8h-2z"/>
</SvgIcon>
);
DeviceSignalCellularConnectedNoInternet0Bar = pure(DeviceSignalCellularConnectedNoInternet0Bar);
DeviceSignalCellularConnectedNoInternet0Bar.displayName = 'DeviceSignalCellularConnectedNoInternet0Bar';
DeviceSignalCellularConnectedNoInternet0Bar.muiName = 'SvgIcon';
export default DeviceSignalCellularConnectedNoInternet0Bar;
|
src/InputBase.js | jamon/react-bootstrap | import React from 'react';
import classNames from 'classnames';
import FormGroup from './FormGroup';
class InputBase extends React.Component {
getInputDOMNode() {
return React.findDOMNode(this.refs.input);
}
getValue() {
if (this.props.type === 'static') {
return this.props.value;
} else if (this.props.type) {
if (this.props.type === 'select' && this.props.multiple) {
return this.getSelectedOptions();
} else {
return this.getInputDOMNode().value;
}
} else {
throw 'Cannot use getValue without specifying input type.';
}
}
getChecked() {
return this.getInputDOMNode().checked;
}
getSelectedOptions() {
let values = [];
Array.prototype.forEach.call(
this.getInputDOMNode().getElementsByTagName('option'),
(option) => {
if (option.selected) {
let value = option.getAttribute('value') || option.innerHtml;
values.push(value);
}
});
return values;
}
isCheckboxOrRadio() {
return this.props.type === 'checkbox' || this.props.type === 'radio';
}
isFile() {
return this.props.type === 'file';
}
renderInputGroup(children) {
let addonBefore = this.props.addonBefore ? (
<span className="input-group-addon" key="addonBefore">
{this.props.addonBefore}
</span>
) : null;
let addonAfter = this.props.addonAfter ? (
<span className="input-group-addon" key="addonAfter">
{this.props.addonAfter}
</span>
) : null;
let buttonBefore = this.props.buttonBefore ? (
<span className="input-group-btn">
{this.props.buttonBefore}
</span>
) : null;
let buttonAfter = this.props.buttonAfter ? (
<span className="input-group-btn">
{this.props.buttonAfter}
</span>
) : null;
let inputGroupClassName;
switch (this.props.bsSize) {
case 'small': inputGroupClassName = 'input-group-sm'; break;
case 'large': inputGroupClassName = 'input-group-lg'; break;
}
return addonBefore || addonAfter || buttonBefore || buttonAfter ? (
<div className={classNames(inputGroupClassName, 'input-group')} key="input-group">
{addonBefore}
{buttonBefore}
{children}
{addonAfter}
{buttonAfter}
</div>
) : children;
}
renderIcon() {
let classes = {
'glyphicon': true,
'form-control-feedback': true,
'glyphicon-ok': this.props.bsStyle === 'success',
'glyphicon-warning-sign': this.props.bsStyle === 'warning',
'glyphicon-remove': this.props.bsStyle === 'error'
};
return this.props.hasFeedback ? (
<span className={classNames(classes)} key="icon" />
) : null;
}
renderHelp() {
return this.props.help ? (
<span className="help-block" key="help">
{this.props.help}
</span>
) : null;
}
renderCheckboxAndRadioWrapper(children) {
let classes = {
'checkbox': this.props.type === 'checkbox',
'radio': this.props.type === 'radio'
};
return (
<div className={classNames(classes)} key="checkboxRadioWrapper">
{children}
</div>
);
}
renderWrapper(children) {
return this.props.wrapperClassName ? (
<div className={this.props.wrapperClassName} key="wrapper">
{children}
</div>
) : children;
}
renderLabel(children) {
let classes = {
'control-label': !this.isCheckboxOrRadio()
};
classes[this.props.labelClassName] = this.props.labelClassName;
return this.props.label ? (
<label htmlFor={this.props.id} className={classNames(classes)} key="label">
{children}
{this.props.label}
</label>
) : children;
}
renderInput() {
if (!this.props.type) {
return this.props.children;
}
switch (this.props.type) {
case 'select':
return (
<select {...this.props} className={classNames(this.props.className, 'form-control')} ref="input" key="input">
{this.props.children}
</select>
);
case 'textarea':
return <textarea {...this.props} className={classNames(this.props.className, 'form-control')} ref="input" key="input" />;
case 'static':
return (
<p {...this.props} className={classNames(this.props.className, 'form-control-static')} ref="input" key="input">
{this.props.value}
</p>
);
}
let className = this.isCheckboxOrRadio() || this.isFile() ? '' : 'form-control';
return <input {...this.props} className={classNames(this.props.className, className)} ref="input" key="input" />;
}
renderFormGroup(children) {
return <FormGroup {...this.props}>{children}</FormGroup>;
}
renderChildren() {
return !this.isCheckboxOrRadio() ? [
this.renderLabel(),
this.renderWrapper([
this.renderInputGroup(
this.renderInput()
),
this.renderIcon(),
this.renderHelp()
])
] : this.renderWrapper([
this.renderCheckboxAndRadioWrapper(
this.renderLabel(
this.renderInput()
)
),
this.renderHelp()
]);
}
render() {
let children = this.renderChildren();
return this.renderFormGroup(children);
}
}
InputBase.propTypes = {
type: React.PropTypes.string,
label: React.PropTypes.node,
help: React.PropTypes.node,
addonBefore: React.PropTypes.node,
addonAfter: React.PropTypes.node,
buttonBefore: React.PropTypes.node,
buttonAfter: React.PropTypes.node,
bsSize: React.PropTypes.oneOf(['small', 'medium', 'large']),
bsStyle: React.PropTypes.oneOf(['success', 'warning', 'error']),
hasFeedback: React.PropTypes.bool,
id: React.PropTypes.string,
groupClassName: React.PropTypes.string,
wrapperClassName: React.PropTypes.string,
labelClassName: React.PropTypes.string,
multiple: React.PropTypes.bool,
disabled: React.PropTypes.bool,
value: React.PropTypes.any
};
export default InputBase;
|
project/vip/frontend/src/router/routeMap.js | webLeeSun/webleesun.github.io | import React from 'react'
// import { Router, Route, IndexRoute } from 'react-router'
import { Switch, Route, Router, Redirect } from 'react-router'
import Home from '../containers/Home'
import Room from '../containers/Room/index'
//import ShippingAddress from '../containers/ShippingAddress'
import LivingEnd from '../containers/LivingEnd'
/*代码分片*/
// import asyncComponent from '../components/asyncComponent/asyncComponent.js'
// const AsyncRankList = asyncComponent(() => import("../containers/RankList"));
// 如果是大型项目,router部分就需要做更加复杂的配置
// 参见 https://github.com/reactjs/react-router/tree/master/examples/huge-apps
class RouterMap extends React.Component {
render() {
return (
<Router history={this.props.history}>
<Switch>
<Route exact path="/" component={Home}/>
<Route path="/home" component={Home}/>
<Route path="/room/:id" component={Room}/>
<Route path="/LivingEnd" component={LivingEnd}/>
<Redirect path='/' to={{pathname:'/'}}/>
</Switch>
</Router>
)
}
}
// RouterMap.propTypes = {
// history: PropTypes.object.isRequired,
// };
export default RouterMap
// {/* <Route path="/ranklist" component={AsyncRankList} /> */}
|
client/src/components/NotFound.js | fraktio/teamdaily | import React from 'react';
export default () =>
<div>
<div>404 LOSONAAMA</div>
<div>Grande pagina non esiste</div>
</div>;
|
src/svg-icons/av/forward-5.js | spiermar/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let AvForward5 = (props) => (
<SvgIcon {...props}>
<path d="M4 13c0 4.4 3.6 8 8 8s8-3.6 8-8h-2c0 3.3-2.7 6-6 6s-6-2.7-6-6 2.7-6 6-6v4l5-5-5-5v4c-4.4 0-8 3.6-8 8zm6.7.9l.2-2.2h2.4v.7h-1.7l-.1.9s.1 0 .1-.1.1 0 .1-.1.1 0 .2 0h.2c.2 0 .4 0 .5.1s.3.2.4.3.2.3.3.5.1.4.1.6c0 .2 0 .4-.1.5s-.1.3-.3.5-.3.2-.5.3-.4.1-.6.1c-.2 0-.4 0-.5-.1s-.3-.1-.5-.2-.2-.2-.3-.4-.1-.3-.1-.5h.8c0 .2.1.3.2.4s.2.1.4.1c.1 0 .2 0 .3-.1l.2-.2s.1-.2.1-.3v-.6l-.1-.2-.2-.2s-.2-.1-.3-.1h-.2s-.1 0-.2.1-.1 0-.1.1-.1.1-.1.1h-.6z"/>
</SvgIcon>
);
AvForward5 = pure(AvForward5);
AvForward5.displayName = 'AvForward5';
AvForward5.muiName = 'SvgIcon';
export default AvForward5;
|
src/container/dev-tools.js | KleeGroup/focus-notifications | import React from 'react';
import { createDevTools } from 'redux-devtools';
import LogMonitor from 'redux-devtools-log-monitor';
import DockMonitor from 'redux-devtools-dock-monitor';
//npm i redux-devtools-dock-monitor redux-devtools-log-monitor
export default createDevTools(
<DockMonitor
toggleVisibilityKey='ctrl-h'
changePositionKey='ctrl-q'
defaultIsVisible={false}>
<LogMonitor />
</DockMonitor>
);
|
spec/javascripts/jsx/theme_editor/ThemeEditorSpec.js | djbender/canvas-lms | /*
* Copyright (C) 2017 - present Instructure, Inc.
*
* This file is part of Canvas.
*
* Canvas is free software: you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License as published by the Free
* Software Foundation, version 3 of the License.
*
* Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import React from 'react'
import ThemeEditor from 'jsx/theme_editor/ThemeEditor'
import {shallow} from 'enzyme'
import {fromPairs} from 'lodash'
QUnit.module('Theme Editor')
test('when something has changed it puts tabIndex=-1 and aria-hidden on the preview frame', () => {
const props = {
brandConfig: {
md5: '9e3c6d00c73e0fa989896e63077b45a8',
variables: {}
},
hasUnsavedChanges: true,
variableSchema: [],
accountID: '1'
}
sessionStorage.setItem(
'sharedBrandConfigBeingEdited',
JSON.stringify({
brand_config: {md5: '9e3c6d00c73e0fa989896e63077b45aa', variables: {}},
name: 'Fake'
})
)
const wrapper = shallow(<ThemeEditor {...props} />)
wrapper.instance().changeSomething('bgColor', '#fff', false)
const iframe = wrapper.find('#previewIframe')
ok(iframe.prop('aria-hidden'))
equal(iframe.prop('tabIndex'), '-1')
})
let testProps
const getDefaultFileList = () => {
const KEYS = ['js_overrides', 'css_overrides', 'mobile_js_overrides', 'mobile_css_overrides']
return KEYS.map(x => ({
customFileUpload: true,
variable_name: x,
value: undefined
}))
}
QUnit.module('Theme Editor Theme Store', {
setup: () => {
testProps = {
brandConfig: {
md5: '9e3c6d00c73e0fa989896e63077b45a8',
variables: {
'ic-brand-primary': 'green',
'ic-brand-global-nav-ic-icon-svg-fill': '#efefef'
}
},
hasUnsavedChanges: true,
variableSchema: [
{
group_key: 'global_branding',
variables: [
{
variable_name: 'ic-brand-primary',
type: 'color',
default: '#008EE2',
human_name: 'Primary Brand Color'
},
{
variable_name: 'ic-brand-font-color-dark',
type: 'color',
default: '#2D3B45',
human_name: 'Main Text Color'
}
],
group_name: 'Global Branding'
},
{
group_key: 'global_navigation',
variables: [
{
variable_name: 'ic-brand-global-nav-bgd',
type: 'color',
default: '#394B58',
human_name: 'Nav Background'
},
{
variable_name: 'ic-brand-global-nav-ic-icon-svg-fill',
type: 'color',
default: '#ffffff',
human_name: 'Nav Icon'
}
],
group_name: 'Global Navigation'
},
{
group_key: 'watermarks',
variables: [
{
variable_name: 'ic-brand-favicon',
type: 'image',
accept: 'image/vnd.microsoft.icon,image/x-icon,image/png,image/gif',
default: '/images/favicon.ico',
human_name: 'Favicon',
helper_text: 'You can use a single 16x16, 32x32, 48x48 ico file.'
}
]
}
],
accountID: '1'
}
sessionStorage.setItem(
'sharedBrandConfigBeingEdited',
JSON.stringify({
brand_config: {md5: '9e3c6d00c73e0fa989896e63077b45aa', variables: {}},
name: 'Fake'
})
)
},
teardown: () => {
testProps = null
}
})
test('constructor sets the theme store state properly using variableSchema and brandConfig props', () => {
const wrapper = shallow(<ThemeEditor {...testProps} />)
deepEqual(wrapper.state('themeStore'), {
properties: {
'ic-brand-primary': 'green',
'ic-brand-font-color-dark': '#2D3B45',
'ic-brand-global-nav-bgd': '#394B58',
'ic-brand-global-nav-ic-icon-svg-fill': '#efefef',
'ic-brand-favicon': '/images/favicon.ico'
},
files: getDefaultFileList()
})
})
test('handleThemeStateChange updates theme store', () => {
const wrapper = shallow(<ThemeEditor {...testProps} />)
wrapper.instance().handleThemeStateChange('ic-brand-font-color-dark', 'black')
deepEqual(wrapper.state('themeStore'), {
properties: {
'ic-brand-primary': 'green',
'ic-brand-font-color-dark': 'black',
'ic-brand-global-nav-bgd': '#394B58',
'ic-brand-global-nav-ic-icon-svg-fill': '#efefef',
'ic-brand-favicon': '/images/favicon.ico'
},
files: getDefaultFileList()
})
})
test('handleThemeStateChange updates when there is a file', () => {
const wrapper = shallow(<ThemeEditor {...testProps} />)
const key = 'ic-brand-favicon'
const value = new File(['foo'], 'foo.png')
wrapper.instance().handleThemeStateChange(key, value)
deepEqual(wrapper.state('themeStore'), {
properties: {
'ic-brand-primary': 'green',
'ic-brand-font-color-dark': '#2D3B45',
'ic-brand-global-nav-bgd': '#394B58',
'ic-brand-global-nav-ic-icon-svg-fill': '#efefef',
'ic-brand-favicon': '/images/favicon.ico'
},
files: [
...getDefaultFileList(),
{
value,
variable_name: key
}
]
})
})
test('handleThemeStateChange sets the file object to have the customFileUpload flag when there is a customFileUpload', () => {
const wrapper = shallow(<ThemeEditor {...testProps} />)
const key = 'custom_css'
const value = new File(['foo'], 'foo.png')
wrapper.instance().handleThemeStateChange(key, value, {customFileUpload: true})
deepEqual(wrapper.state('themeStore'), {
properties: {
'ic-brand-primary': 'green',
'ic-brand-font-color-dark': '#2D3B45',
'ic-brand-global-nav-bgd': '#394B58',
'ic-brand-global-nav-ic-icon-svg-fill': '#efefef',
'ic-brand-favicon': '/images/favicon.ico'
},
files: [
...getDefaultFileList(),
{
value,
variable_name: key,
customFileUpload: true
}
]
})
})
test('handleThemeStateChange resets to default when opts.resetValue is set', () => {
const wrapper = shallow(<ThemeEditor {...testProps} />)
wrapper.instance().handleThemeStateChange('ic-brand-font-color-dark', 'black')
wrapper.instance().handleThemeStateChange('ic-brand-font-color-dark', null, {resetValue: true})
deepEqual(wrapper.state('themeStore'), {
properties: {
'ic-brand-primary': 'green',
'ic-brand-font-color-dark': '#2D3B45',
'ic-brand-global-nav-bgd': '#394B58',
'ic-brand-global-nav-ic-icon-svg-fill': '#efefef',
'ic-brand-favicon': '/images/favicon.ico'
},
files: getDefaultFileList()
})
})
test('handleThemeStateChange sets values to original default values when opts.useDefault is set', () => {
const wrapper = shallow(<ThemeEditor {...testProps} />)
wrapper.instance().handleThemeStateChange('ic-brand-favicon', '/path/to/some/image.ico')
wrapper
.instance()
.handleThemeStateChange('ic-brand-favicon', null, {resetValue: true, useDefault: true})
deepEqual(wrapper.state('themeStore'), {
properties: {
'ic-brand-primary': 'green',
'ic-brand-font-color-dark': '#2D3B45',
'ic-brand-global-nav-bgd': '#394B58',
'ic-brand-global-nav-ic-icon-svg-fill': '#efefef',
'ic-brand-favicon': '/images/favicon.ico'
},
files: getDefaultFileList()
})
})
test('handleThemeStateChange sets file objects in the store to their previous value when opts.resetValue is set', () => {
const wrapper = shallow(<ThemeEditor {...testProps} />)
const key = 'ic-brand-favicon'
const value = new File(['foo'], 'foo.png')
wrapper.instance().handleThemeStateChange(key, value)
wrapper.instance().handleThemeStateChange(key, null, {resetValue: true})
deepEqual(wrapper.state('themeStore'), {
properties: {
'ic-brand-primary': 'green',
'ic-brand-font-color-dark': '#2D3B45',
'ic-brand-global-nav-bgd': '#394B58',
'ic-brand-global-nav-ic-icon-svg-fill': '#efefef',
'ic-brand-favicon': '/images/favicon.ico'
},
files: [
...getDefaultFileList(),
{
value: undefined,
variable_name: 'ic-brand-favicon'
}
]
})
})
test('processThemeStoreForSubmit puts the themeStore into a FormData and returns it', () => {
const wrapper = shallow(<ThemeEditor {...testProps} />)
const fileValue = new File(['foo'], 'foo.png')
wrapper.instance().handleThemeStateChange('ic-brand-favicon', fileValue)
wrapper.instance().handleThemeStateChange('ic-brand-font-color-dark', 'black')
wrapper.instance().changeSomething('ic-brand-font-color-dark', 'black', false)
const formData = wrapper.instance().processThemeStoreForSubmit()
const formObj = fromPairs(Array.from(formData.entries()))
deepEqual(formObj, {
'brand_config[variables][ic-brand-font-color-dark]': 'black',
'brand_config[variables][ic-brand-global-nav-ic-icon-svg-fill]': '#efefef',
'brand_config[variables][ic-brand-primary]': 'green',
'brand_config[variables][ic-brand-favicon]': fileValue,
css_overrides: '',
js_overrides: '',
mobile_css_overrides: '',
mobile_js_overrides: ''
})
})
test('processThemeStoreForSubmit sets the correct keys for custom uploads', () => {
const wrapper = shallow(<ThemeEditor {...testProps} />)
const key = 'css_overrides'
const value = new File(['foo'], 'foo.png')
wrapper.instance().handleThemeStateChange(key, value, {customFileUpload: true})
const formData = wrapper.instance().processThemeStoreForSubmit()
const formObj = fromPairs(Array.from(formData.entries()))
deepEqual(formObj, {
'brand_config[variables][ic-brand-global-nav-ic-icon-svg-fill]': '#efefef',
'brand_config[variables][ic-brand-primary]': 'green',
js_overrides: '',
mobile_css_overrides: '',
mobile_js_overrides: '',
[key]: value
})
})
test('processThemeStoreForSubmit sets the correct keys for custom uploads that already have values', () => {
testProps.brandConfig.js_overrides = '/some/path/to/a/file'
const wrapper = shallow(<ThemeEditor {...testProps} />)
const key = 'css_overrides'
const value = new File(['foo'], 'foo.png')
wrapper.instance().handleThemeStateChange(key, value, {customFileUpload: true})
const formData = wrapper.instance().processThemeStoreForSubmit()
const formObj = fromPairs(Array.from(formData.entries()))
deepEqual(formObj, {
'brand_config[variables][ic-brand-global-nav-ic-icon-svg-fill]': '#efefef',
'brand_config[variables][ic-brand-primary]': 'green',
js_overrides: '/some/path/to/a/file',
mobile_css_overrides: '',
mobile_js_overrides: '',
[key]: value
})
})
|
assets/js/src/components/Dashboard/Dashboard.js | nathandao/git.report | import React from 'react';
import _ from 'lodash';
import RepoCell from 'components/Charts/RepoCell';
import HourlyCommits from 'components/Charts/HourlyCommits';
import TodayOverview from 'components/Dashboard/TodayOverview';
import ReposOverview from 'components/Dashboard/ReposOverview';
import RepoSelector from 'components/RepoSelector/RepoSelector';
class Dashboard extends React.Component {
_getVisibleRepos() {
return _.select(this.props.repos, (repo) => {
return repo.visible === true;
});
}
repoPulses() {
let repos = this._getVisibleRepos();
let content = repos.map((repo) => {
let pulse = _.find(this.props.repoPulses, pulseData => {
return pulseData.repoId === repo.id;
});
return <RepoCell pulse={ pulse } repo={ repo } key={ 'repo-cell-' + repo.id }/>;
});
return content;
}
render() {
return (
<div>
<section>
<div className="col-half">
<section>
<div className="col-third">
<h3>Commits today</h3>
<TodayOverview commits={ this.props.commits } visibleRepos={ this._getVisibleRepos() } />
</div>
<div className="col-two-third">
<h3>Switch visibility</h3>
<RepoSelector repos={ this.props.repos }/>
</div>
</section>
<div className="col-full">
<h3>Hourly commits</h3>
<HourlyCommits repos={ this._getVisibleRepos() } commits={ this.props.commits }/>
</div>
</div>
<div className="col-half">
<h3>Overviews</h3>
<ReposOverview repos={ this._getVisibleRepos() } overviews={ this.props.overviews }/>
</div>
</section>
<h1>Commit counts in the past 7 days</h1>
<section>
{ this.repoPulses() }
</section>
</div>
);
}
}
export default Dashboard;
|
src/Value.js | Paveltarno/react-select | import React from 'react';
import classNames from 'classnames';
const Value = React.createClass({
displayName: 'Value',
propTypes: {
children: React.PropTypes.node,
disabled: React.PropTypes.bool, // disabled prop passed to ReactSelect
onClick: React.PropTypes.func, // method to handle click on value label
onRemove: React.PropTypes.func, // method to handle removal of the value
value: React.PropTypes.object.isRequired, // the option object for this value
},
handleMouseDown (event) {
if (event.type === 'mousedown' && event.button !== 0) {
return;
}
if (this.props.onClick) {
event.stopPropagation();
this.props.onClick(this.props.value, event);
return;
}
if (this.props.value.href) {
event.stopPropagation();
}
},
onRemove (event) {
event.preventDefault();
event.stopPropagation();
this.props.onRemove(this.props.value);
},
handleTouchEndRemove (event){
// Check if the view is being dragged, In this case
// we don't want to fire the click event (because the user only wants to scroll)
if(this.dragging) return;
// Fire the mouse events
this.onRemove(event);
},
handleTouchMove (event) {
// Set a flag that the view is being dragged
this.dragging = true;
},
handleTouchStart (event) {
// Set a flag that the view is not being dragged
this.dragging = false;
},
renderRemoveIcon () {
if (this.props.disabled || !this.props.onRemove) return;
return (
<span className="Select-value-icon"
onMouseDown={this.onRemove}
onTouchEnd={this.handleTouchEndRemove}
onTouchStart={this.handleTouchStart}
onTouchMove={this.handleTouchMove}>
×
</span>
);
},
renderLabel () {
let className = 'Select-value-label';
return this.props.onClick || this.props.value.href ? (
<a className={className} href={this.props.value.href} target={this.props.value.target} onMouseDown={this.handleMouseDown} onTouchEnd={this.handleMouseDown}>
{this.props.children}
</a>
) : (
<span className={className}>
{this.props.children}
</span>
);
},
render () {
return (
<div className={classNames('Select-value', this.props.value.className)}
style={this.props.value.style}
title={this.props.value.title}
>
{this.renderRemoveIcon()}
{this.renderLabel()}
</div>
);
}
});
module.exports = Value;
|
src/js/components/n-radio.js | bradwoo8621/parrot2 | import React from 'react'
import ReactDOM from 'react-dom'
import jQuery from 'jquery'
import classnames from 'classnames'
let $ = jQuery;
import {Envs} from '../envs'
import {Model} from '../model/model'
import {NComponent, NCodeTableComponent} from './n-component'
class NRadio extends NCodeTableComponent(NComponent) {
renderText(item) {
return (<span className='n-radio-text n-control'>
{item.text}
</span>);
}
renderTextOnLeft(options) {
if (options.left) {
return this.renderText(options.item);
}
}
renderTextOnRight(options) {
if (!options.left) {
return this.renderText(options.item);
}
}
renderRadioButton() {
return (<span className='n-radio-box n-control'>
<span className='n-radio-box-rect' />
</span>);
}
renderCodeItem(item, itemIndex) {
let textOnLeft = this.isTextOnLeft();
let className = classnames('n-radio', {
'n-checked': this.isChecked(item),
'n-radio-text-left': textOnLeft,
'n-radio-text-right': !textOnLeft
});
return (<div className={className}
onClick={this.onComponentClicked.bind(this, item)}
onKeyPress={this.onComponentKeyPressed.bind(this, item)}
tabIndex={this.getTabIndex()}
key={itemIndex}>
{this.renderTextOnLeft({left: textOnLeft, item: item})}
{this.renderRadioButton()}
{this.renderTextOnRight({left: textOnLeft, item: item})}
</div>);
}
renderInNormal() {
let className = classnames(this.getComponentStyle(), {
'n-radio-vertical': this.isOnVertical()
});
return (<div className={className}
ref='me'>
{this.getCodeTable().map((item, itemIndex) => {
return this.renderCodeItem(item, itemIndex);
})}
</div>);
}
getComponentClassName() {
return 'n-radio-group';
}
isTextOnLeft() {
return this.getLayoutOptionValue('textOnLeft', false);
}
isOnVertical() {
return this.getLayoutOptionValue('vertical', false);
}
onComponentClicked(item, evt) {
if (!this.isEnabled()) {
return;
}
evt.preventDefault();
this.setValueToModel(item.id);
let target = $(ReactDOM.findDOMNode(evt.target));
if (target.hasClass('n-radio')) {
target.focus();
} else {
target.closest('.n-radio').focus();
}
}
onComponentKeyPressed(item, evt) {
if (!this.isEnabled()) {
return;
}
if (evt.charCode === 32 && item.id != this.getValueFromModel()) {
// space bar
evt.preventDefault();
this.setValueToModel(item.id);
}
}
isChecked(item) {
return this.getValueFromModel() == item.id;
}
}
class NRadioButton extends NCodeTableComponent(NComponent) {
renderCodeItem(item, itemIndex) {
let checked = this.isChecked(item);
let layout = {
label: item.text,
comp: {
type: Envs.COMPONENT_TYPES.BUTTON,
style: this.getButtonStyle(),
enabled: this.isEnabled()
},
evt: {
click: this.onItemClicked.bind(this, item, itemIndex)
}
};
if (checked) {
let checkedStyle = this.getCheckedStyle();
if (checkedStyle) {
layout.comp.style = checkedStyle;
}
layout.styles = {comp: 'n-checked'};
}
if (item.icon) {
layout.comp.leftIcon = {
comp: {
type: Envs.COMPONENT_TYPES.ICON,
icon: item.icon
}
};
}
return this.renderInternalComponent(layout, {
key: itemIndex
});
}
renderInNormal() {
return (<div className={this.getComponentStyle()}
ref='me'>
{this.getCodeTable().map((item, itemIndex) => {
return this.renderCodeItem(item, itemIndex);
})}
</div>);
}
getComponentClassName() {
return 'n-radio-button-group';
}
getButtonStyle() {
return this.getLayoutOptionValue('style');
}
getCheckedStyle() {
return this.getLayoutOptionValue('checkedStyle');
}
isChecked(item) {
return this.getValueFromModel() == item.id;
}
onItemClicked(item, itemIndex, evt) {
if (item.id != this.getValueFromModel()) {
evt.preventDefault();
this.setValueToModel(item.id);
}
}
}
Envs.COMPONENT_TYPES.RADIO = {type: 'n-radio', label: true, error: true};
Envs.setRenderer(Envs.COMPONENT_TYPES.RADIO.type, function (options) {
return <NRadio {...options} />;
});
Envs.COMPONENT_TYPES.RADIO_BUTTON = {type: 'n-radio-button', label: true, error: true};
Envs.setRenderer(Envs.COMPONENT_TYPES.RADIO_BUTTON.type, function (options) {
return <NRadioButton {...options} />;
});
export {NRadio, NRadioButton}
|
src/App.js | AndreStabile/pokedex | import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';
class App extends Component {
render() {
return (
<div className="App">
<div className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<h2>Welcome to React</h2>
</div>
<p className="App-intro">
To get started, edit <code>src/App.js</code> and save to reload.
</p>
</div>
);
}
}
export default App;
|
packages/es-components/src/components/controls/DismissButton.js | jrios/es-components | import React from 'react';
import styled from 'styled-components';
import screenReaderOnly from '../patterns/screenReaderOnly/screenReaderOnly';
import Icon from '../base/icons/Icon';
const DismissButtonBase = styled.button`
background-color: transparent;
border: 0;
cursor: pointer;
display: flex;
font-weight: bold;
opacity: 0.2;
padding: 0;
&:hover,
&:focus {
opacity: 0.5;
}
`;
const ScreenReaderText = screenReaderOnly('span');
const DismissButton = React.forwardRef(function DismissButton(props, ref) {
return (
<DismissButtonBase aria-label="Close" type="button" {...props} ref={ref}>
<Icon name="remove" />
<ScreenReaderText>Close</ScreenReaderText>
</DismissButtonBase>
);
});
export default DismissButton;
|
packages/react/src/components/DataTable/TableBatchAction.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 PropTypes from 'prop-types';
import React from 'react';
import { AddFilled16 as iconAddSolid } from '@carbon/icons-react';
import Button from '../Button';
const TableBatchAction = (props) => <Button {...props} />;
TableBatchAction.propTypes = {
/**
* Specify if the button is an icon-only button
*/
hasIconOnly: PropTypes.bool,
/**
* If specifying the `renderIcon` prop, provide a description for that icon that can
* be read by screen readers
*/
iconDescription: (props) => {
if (props.renderIcon && !props.children && !props.iconDescription) {
return new Error(
'renderIcon property specified without also providing an iconDescription property.'
);
}
return undefined;
},
/**
* Optional function to render your own icon in the underlying button
*/
renderIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
};
TableBatchAction.defaultProps = {
renderIcon: iconAddSolid,
};
export default TableBatchAction;
|
src/components/DevTools.js | pahomovda/react-redux-router-material-ui-seed | import React from 'react';
import { createDevTools } from 'redux-devtools';
import LogMonitor from 'redux-devtools-log-monitor';
import DockMonitor from 'redux-devtools-dock-monitor';
export default createDevTools(
<DockMonitor
toggleVisibilityKey="ctrl-h"
changePositionKey="ctrl-q"
defaultIsVisible={false} >
<LogMonitor />
</DockMonitor>
);
|
src/svg-icons/image/photo-camera.js | jacklam718/react-svg-iconx | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let ImagePhotoCamera = (props) => (
<SvgIcon {...props}>
<circle cx="12" cy="12" r="3.2"/><path d="M9 2L7.17 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2h-3.17L15 2H9zm3 15c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5z"/>
</SvgIcon>
);
ImagePhotoCamera = pure(ImagePhotoCamera);
ImagePhotoCamera.displayName = 'ImagePhotoCamera';
ImagePhotoCamera.muiName = 'SvgIcon';
export default ImagePhotoCamera;
|
views/components/Logo/index.js | Chibaheit/eventer | /*
* Blipay Logo
*/
import React from 'react';
import logo from './logo.png';
class Logo extends React.Component {
render() {
return (
<img src={logo} {...this.props} />
);
}
}
export default Logo;
|
app/components/team/Members/user.js | fotinakis/buildkite-frontend | import React from 'react';
import PropTypes from 'prop-types';
import User from '../../shared/User';
export default class TeamMembersUser extends React.PureComponent {
static displayName = "Team.Members.User";
static propTypes = {
user: PropTypes.shape({
name: PropTypes.string.isRequired,
email: PropTypes.string.isRequired,
avatar: PropTypes.shape({
url: PropTypes.string.isRequired
}).isRequired
}).isRequired
};
render() {
return (
<User user={this.props.user} />
);
}
}
|
geonode/monitoring/frontend/monitoring/src/components/cels/alerts/index.js | francbartoli/geonode | /*
#########################################################################
#
# Copyright (C) 2019 OSGeo
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#########################################################################
*/
import React from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import HoverPaper from '../../atoms/hover-paper';
import actions from '../../organisms/alert-list/actions';
import styles from './styles';
import {withRouter} from 'react-router-dom';
const mapStateToProps = (state) => ({
alertList: state.alertList.response,
interval: state.interval.interval,
timestamp: state.interval.timestamp,
});
@connect(mapStateToProps, actions)
class Alerts extends React.Component {
static propTypes = {
alertList: PropTypes.object,
get: PropTypes.func.isRequired,
interval: PropTypes.number,
style: PropTypes.object,
timestamp: PropTypes.instanceOf(Date),
}
constructor(props) {
super(props);
this.handleClick = () => {
this.props.history.push('/alerts');
};
this.get = (interval = this.props.interval) => {
this.props.get(interval);
};
}
componentWillMount() {
this.get();
}
componentWillReceiveProps(nextProps) {
if (nextProps) {
if (nextProps.timestamp && nextProps.timestamp !== this.props.timestamp) {
this.get(nextProps.interval);
}
}
}
render() {
const alertList = this.props.alertList;
const alertNumber = alertList && alertList.data
? alertList.data.problems.length
: 0;
const extraStyle = alertNumber > 0
? { backgroundColor: '#ffa031', color: '#fff' }
: {};
const style = {
...styles.content,
...this.props.style,
...extraStyle,
};
return (
<HoverPaper style={style}>
<div onClick={this.handleClick} style={styles.clickable}>
<h3>Alerts</h3>
<span style={styles.stat}>{alertNumber} Alerts to show</span>
</div>
</HoverPaper>
);
}
}
export default withRouter(Alerts);
|
src/common/components/CloseButton.js | killpowa/Twickt-Launcher | import React from 'react';
import styled from 'styled-components';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faWindowClose } from '@fortawesome/free-solid-svg-icons';
const CloseButton = props => {
return (
// eslint-disable-next-line
<CloseIcon {...props}>
<FontAwesomeIcon icon={faWindowClose} />
</CloseIcon>
);
};
export default CloseButton;
const CloseIcon = styled.div`
font-size: 20px;
width: 20px;
cursor: pointer;
transition: all 0.15s ease-in-out;
&:hover {
color: ${props => props.theme.palette.error.main};
}
`;
|
src/svg-icons/social/party-mode.js | tan-jerene/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let SocialPartyMode = (props) => (
<SvgIcon {...props}>
<path d="M20 4h-3.17L15 2H9L7.17 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm-8 3c1.63 0 3.06.79 3.98 2H12c-1.66 0-3 1.34-3 3 0 .35.07.69.18 1H7.1c-.06-.32-.1-.66-.1-1 0-2.76 2.24-5 5-5zm0 10c-1.63 0-3.06-.79-3.98-2H12c1.66 0 3-1.34 3-3 0-.35-.07-.69-.18-1h2.08c.07.32.1.66.1 1 0 2.76-2.24 5-5 5z"/>
</SvgIcon>
);
SocialPartyMode = pure(SocialPartyMode);
SocialPartyMode.displayName = 'SocialPartyMode';
SocialPartyMode.muiName = 'SvgIcon';
export default SocialPartyMode;
|
app/javascript/mastodon/features/notifications/components/column_settings.js | tri-star/mastodon | import React from 'react';
import PropTypes from 'prop-types';
import ImmutablePropTypes from 'react-immutable-proptypes';
import { FormattedMessage } from 'react-intl';
import ClearColumnButton from './clear_column_button';
import GrantPermissionButton from './grant_permission_button';
import SettingToggle from './setting_toggle';
export default class ColumnSettings extends React.PureComponent {
static propTypes = {
settings: ImmutablePropTypes.map.isRequired,
pushSettings: ImmutablePropTypes.map.isRequired,
onChange: PropTypes.func.isRequired,
onClear: PropTypes.func.isRequired,
onRequestNotificationPermission: PropTypes.func,
alertsEnabled: PropTypes.bool,
browserSupport: PropTypes.bool,
browserPermission: PropTypes.bool,
};
onPushChange = (path, checked) => {
this.props.onChange(['push', ...path], checked);
}
render () {
const { settings, pushSettings, onChange, onClear, alertsEnabled, browserSupport, browserPermission, onRequestNotificationPermission } = this.props;
const filterShowStr = <FormattedMessage id='notifications.column_settings.filter_bar.show' defaultMessage='Show' />;
const filterAdvancedStr = <FormattedMessage id='notifications.column_settings.filter_bar.advanced' defaultMessage='Display all categories' />;
const alertStr = <FormattedMessage id='notifications.column_settings.alert' defaultMessage='Desktop notifications' />;
const showStr = <FormattedMessage id='notifications.column_settings.show' defaultMessage='Show in column' />;
const soundStr = <FormattedMessage id='notifications.column_settings.sound' defaultMessage='Play sound' />;
const showPushSettings = pushSettings.get('browserSupport') && pushSettings.get('isSubscribed');
const pushStr = showPushSettings && <FormattedMessage id='notifications.column_settings.push' defaultMessage='Push notifications' />;
return (
<div>
{alertsEnabled && browserSupport && browserPermission === 'denied' && (
<div className='column-settings__row column-settings__row--with-margin'>
<span className='warning-hint'><FormattedMessage id='notifications.permission_denied' defaultMessage='Desktop notifications are unavailable due to previously denied browser permissions request' /></span>
</div>
)}
{alertsEnabled && browserSupport && browserPermission === 'default' && (
<div className='column-settings__row column-settings__row--with-margin'>
<span className='warning-hint'>
<FormattedMessage id='notifications.permission_required' defaultMessage='Desktop notifications are unavailable because the required permission has not been granted.' /> <GrantPermissionButton onClick={onRequestNotificationPermission} />
</span>
</div>
)}
<div className='column-settings__row'>
<ClearColumnButton onClick={onClear} />
</div>
<div role='group' aria-labelledby='notifications-filter-bar'>
<span id='notifications-filter-bar' className='column-settings__section'>
<FormattedMessage id='notifications.column_settings.filter_bar.category' defaultMessage='Quick filter bar' />
</span>
<div className='column-settings__row'>
<SettingToggle id='show-filter-bar' prefix='notifications' settings={settings} settingPath={['quickFilter', 'show']} onChange={onChange} label={filterShowStr} />
<SettingToggle id='show-filter-bar' prefix='notifications' settings={settings} settingPath={['quickFilter', 'advanced']} onChange={onChange} label={filterAdvancedStr} />
</div>
</div>
<div role='group' aria-labelledby='notifications-follow'>
<span id='notifications-follow' className='column-settings__section'><FormattedMessage id='notifications.column_settings.follow' defaultMessage='New followers:' /></span>
<div className='column-settings__row'>
<SettingToggle disabled={browserPermission === 'denied'} prefix='notifications_desktop' settings={settings} settingPath={['alerts', 'follow']} onChange={onChange} label={alertStr} />
{showPushSettings && <SettingToggle prefix='notifications_push' settings={pushSettings} settingPath={['alerts', 'follow']} onChange={this.onPushChange} label={pushStr} />}
<SettingToggle prefix='notifications' settings={settings} settingPath={['shows', 'follow']} onChange={onChange} label={showStr} />
<SettingToggle prefix='notifications' settings={settings} settingPath={['sounds', 'follow']} onChange={onChange} label={soundStr} />
</div>
</div>
<div role='group' aria-labelledby='notifications-follow-request'>
<span id='notifications-follow-request' className='column-settings__section'><FormattedMessage id='notifications.column_settings.follow_request' defaultMessage='New follow requests:' /></span>
<div className='column-settings__row'>
<SettingToggle disabled={browserPermission === 'denied'} prefix='notifications_desktop' settings={settings} settingPath={['alerts', 'follow_request']} onChange={onChange} label={alertStr} />
{showPushSettings && <SettingToggle prefix='notifications_push' settings={pushSettings} settingPath={['alerts', 'follow_request']} onChange={this.onPushChange} label={pushStr} />}
<SettingToggle prefix='notifications' settings={settings} settingPath={['shows', 'follow_request']} onChange={onChange} label={showStr} />
<SettingToggle prefix='notifications' settings={settings} settingPath={['sounds', 'follow_request']} onChange={onChange} label={soundStr} />
</div>
</div>
<div role='group' aria-labelledby='notifications-favourite'>
<span id='notifications-favourite' className='column-settings__section'><FormattedMessage id='notifications.column_settings.favourite' defaultMessage='Favourites:' /></span>
<div className='column-settings__row'>
<SettingToggle disabled={browserPermission === 'denied'} prefix='notifications_desktop' settings={settings} settingPath={['alerts', 'favourite']} onChange={onChange} label={alertStr} />
{showPushSettings && <SettingToggle prefix='notifications_push' settings={pushSettings} settingPath={['alerts', 'favourite']} onChange={this.onPushChange} label={pushStr} />}
<SettingToggle prefix='notifications' settings={settings} settingPath={['shows', 'favourite']} onChange={onChange} label={showStr} />
<SettingToggle prefix='notifications' settings={settings} settingPath={['sounds', 'favourite']} onChange={onChange} label={soundStr} />
</div>
</div>
<div role='group' aria-labelledby='notifications-mention'>
<span id='notifications-mention' className='column-settings__section'><FormattedMessage id='notifications.column_settings.mention' defaultMessage='Mentions:' /></span>
<div className='column-settings__row'>
<SettingToggle disabled={browserPermission === 'denied'} prefix='notifications_desktop' settings={settings} settingPath={['alerts', 'mention']} onChange={onChange} label={alertStr} />
{showPushSettings && <SettingToggle prefix='notifications_push' settings={pushSettings} settingPath={['alerts', 'mention']} onChange={this.onPushChange} label={pushStr} />}
<SettingToggle prefix='notifications' settings={settings} settingPath={['shows', 'mention']} onChange={onChange} label={showStr} />
<SettingToggle prefix='notifications' settings={settings} settingPath={['sounds', 'mention']} onChange={onChange} label={soundStr} />
</div>
</div>
<div role='group' aria-labelledby='notifications-reblog'>
<span id='notifications-reblog' className='column-settings__section'><FormattedMessage id='notifications.column_settings.reblog' defaultMessage='Boosts:' /></span>
<div className='column-settings__row'>
<SettingToggle disabled={browserPermission === 'denied'} prefix='notifications_desktop' settings={settings} settingPath={['alerts', 'reblog']} onChange={onChange} label={alertStr} />
{showPushSettings && <SettingToggle prefix='notifications_push' settings={pushSettings} settingPath={['alerts', 'reblog']} onChange={this.onPushChange} label={pushStr} />}
<SettingToggle prefix='notifications' settings={settings} settingPath={['shows', 'reblog']} onChange={onChange} label={showStr} />
<SettingToggle prefix='notifications' settings={settings} settingPath={['sounds', 'reblog']} onChange={onChange} label={soundStr} />
</div>
</div>
<div role='group' aria-labelledby='notifications-poll'>
<span id='notifications-poll' className='column-settings__section'><FormattedMessage id='notifications.column_settings.poll' defaultMessage='Poll results:' /></span>
<div className='column-settings__row'>
<SettingToggle disabled={browserPermission === 'denied'} prefix='notifications_desktop' settings={settings} settingPath={['alerts', 'poll']} onChange={onChange} label={alertStr} />
{showPushSettings && <SettingToggle prefix='notifications_push' settings={pushSettings} settingPath={['alerts', 'poll']} onChange={this.onPushChange} label={pushStr} />}
<SettingToggle prefix='notifications' settings={settings} settingPath={['shows', 'poll']} onChange={onChange} label={showStr} />
<SettingToggle prefix='notifications' settings={settings} settingPath={['sounds', 'poll']} onChange={onChange} label={soundStr} />
</div>
</div>
<div role='group' aria-labelledby='notifications-status'>
<span id='notifications-status' className='column-settings__section'><FormattedMessage id='notifications.column_settings.status' defaultMessage='New toots:' /></span>
<div className='column-settings__row'>
<SettingToggle disabled={browserPermission === 'denied'} prefix='notifications_desktop' settings={settings} settingPath={['alerts', 'status']} onChange={onChange} label={alertStr} />
{showPushSettings && <SettingToggle prefix='notifications_push' settings={pushSettings} settingPath={['alerts', 'status']} onChange={this.onPushChange} label={pushStr} />}
<SettingToggle prefix='notifications' settings={settings} settingPath={['shows', 'status']} onChange={onChange} label={showStr} />
<SettingToggle prefix='notifications' settings={settings} settingPath={['sounds', 'status']} onChange={onChange} label={soundStr} />
</div>
</div>
</div>
);
}
}
|
frontend/src/components/posts-list/post/select.js | 1905410/Misago | /* jshint ignore:start */
import React from 'react';
import { isVisible } from './controls';
import * as posts from 'misago/reducers/posts';
import store from 'misago/services/store';
export default class extends React.Component{
onClick = () => {
if (this.props.post.isSelected) {
store.dispatch(posts.deselect(this.props.post));
} else {
store.dispatch(posts.select(this.props.post));
}
};
render() {
if (!(this.props.thread.acl.can_merge_posts || isVisible(this.props.post.acl))) {
return null;
}
return (
<div className="pull-right">
<button
className="btn btn-default btn-icon"
onClick={this.onClick}
type="button"
>
<span className="material-icon">
{this.props.post.isSelected ? 'check_box' : 'check_box_outline_blank'}
</span>
</button>
</div>
);
}
} |
src/components/SearchGiphy.js | aalselius/Test | import React, { Component } from 'react';
import Input from './Input.js';
import Image from './Image.js';
import InfoText from './InfoText.js';
import Header from './Header.js';
class SearchGiphy extends Component {
constructor() {
super();
this.state = {
imageUrl: '',
url:'',
inputType: '',
imageNumber: 0,
json:'',
images:[],
text: 'cat',
loaded: false,
}
}
componentDidMount() {
this.url = "http://api.giphy.com/v1/gifs/search?q=funny+"+this.state.text+"&api_key=dc6zaTOxFJmzC";
console.log(this.url);
fetch(this.url)
.then((data) => {
return data.json();
})
.then((json) => {
console.log(json);
this.setState({json:json});
this.setState({imageUrl:this.state.json.data[0].images.downsized.url});
this.setState({loaded: true});
})
;
}
updateUrl(category) {
this.url = "http://api.giphy.com/v1/gifs/search?q=funny+"+this.state.text+"&api_key=dc6zaTOxFJmzC";
console.log(this.url);
fetch(this.url)
.then((data) => {
return data.json();
})
.then((json) => {
console.log(json);
this.setState({json:json});
this.setState({imageUrl:this.state.json.data[0].images.downsized.url});
})
;
}
changeLink = (arrow) => {
if (arrow === "left") {
this.setState({imageNumber: this.state.imageNumber -1}); //previous state, if 0 => 25
if (this.state.imageNumber <= 0) {
this.setState({imageNumber: 24}); //previous state, if 0 => 25
}
} else if (arrow === "right") {
this.setState({imageNumber: this.state.imageNumber +1}); // previous state, if 25 => 0
if (this.state.imageNumber >= 24) {
this.setState({imageNumber: 0}); //previous state, if 0 => 25
}
}
console.log(this.state.imageNumber);
let xx=this.state.json;
this.setState ({imageUrl:xx.data[this.state.imageNumber].images.downsized.url});
}
updateText = (event) => {
this.setState({text: event.target.value})
}
handleSubmit = (event) => {
if(event.keyCode === 13) {
this.setState({text: event.target.value})
console.log(this.state.text);
// set new url
this.updateUrl(this.state.text);
event.target.value='';
}
}
render() {
return (
<div className="pageContainer">
<Header headerText="Find Giphy" headerClass="sideHeader"/>
<Header headerText={this.state.text} headerClass="searchHeader"/>
{this.state.loaded ? (
<div className="imageContainer">
<i className="fa fa-angle-left" onClick={()=>this.changeLink("left")}></i>
<Image url={this.state.imageUrl}/>
<i className="fa fa-angle-right" onClick={()=>this.changeLink("right")}></i>
</div>
) : (
<div className="imageContainer"><i className="fa fa-spinner" aria-hidden="true"></i></div>
)}
<Input
inputType={'category'}
handleSubmit = {this.handleSubmit}
updateText = {this.updateText}
/>
<InfoText infoText="To choose several categories write them separated by a +, no spaces." />
<InfoText infoText="For exampel 'funny+spider'." />
</div>
);
}
}
export default SearchGiphy; |
src/scripts/VideoImage.js | whoisandie/yoda | 'use strict';
import React from 'react';
import Join from 'react/lib/joinClasses';
import VideoDuration from './VideoDuration';
export default React.createClass({
componentDidMount() {
var imgTag = React.findDOMNode(this.refs.image);
var imgSrc = imgTag.getAttribute('src');
var img = new window.Image();
img.src = imgSrc;
},
shouldComponentUpdate(nextProps) {
return this.props.src !== nextProps.src;
},
render() {
var imgClasses = 'video-thumbnail image-thumbnail';
return (
<img ref="image" className={imgClasses} {...this.props} />
);
}
});
|
client/Tasks/TaskOne.js | AnnotatedJS/meteor-react-start-app |
import React from 'react';
import TaskDelete from './TaskDelete';
import TaskOpenClosed from './TaskOpenClosed';
import TaskPrivate from './TaskPrivate';
import TaskText from './TaskText';
export default class TaskOne extends React.Component {
constructor(props) {
super(props);
}
isLoggedInUser() { return Meteor.userId() }
/***************************************/
/* RENDER
/***************************************/
render() {
var p = this.props;
return (
<tr className={p.taskListRowClass} >
<td>
<strong>{p.task.username}</strong>
</td>
<td>
<TaskText
task={ p.task }
edit={p.edit}
editTask={p.editTask}
beginTextEdit={p.beginTextEdit}
processTextTyping={p.processTextTyping}
processTextClear={p.processTextClear}
processTextReset={p.processTextReset}
endTextEditSave={p.endTextEditSave}
endTextEditClear={p.endTextEditClear}
/>
</td>
<TaskOpenClosed
task={ p.task }
toggleChecked={p.toggleChecked}
/>
{ p.userOwnsTask ?
<TaskPrivate
task={ p.task }
togglePrivate={p.togglePrivate}
/>
: this.isLoggedInUser() ? <td></td>
: null
}
{ p.userOwnsTask ?
<TaskDelete
task={ p.task }
deleteThisTask={p.deleteThisTask}
/>
: this.isLoggedInUser() ? <td></td>
: null
}
</tr>
);
}
}
|
Examples/UIExplorer/js/ActivityIndicatorExample.js | callstack-io/react-native | /**
* Copyright (c) 2013-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.
*
* The examples provided by Facebook are for non-commercial testing and
* evaluation purposes only.
*
* Facebook reserves all rights not expressly granted.
*
* 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 NON INFRINGEMENT. IN NO EVENT SHALL
* FACEBOOK 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.
*
* @flow
*/
'use strict';
import React, { Component } from 'react';
import { ActivityIndicator, StyleSheet, View } from 'react-native';
/**
* Optional Flowtype state and timer types definition
*/
type State = { animating: boolean; };
type Timer = number;
class ToggleAnimatingActivityIndicator extends Component {
/**
* Optional Flowtype state and timer types
*/
state: State;
_timer: Timer;
constructor(props) {
super(props);
this.state = {
animating: true,
};
}
componentDidMount() {
this.setToggleTimeout();
}
componentWillUnmount() {
clearTimeout(this._timer);
}
setToggleTimeout() {
this._timer = setTimeout(() => {
this.setState({animating: !this.state.animating});
this.setToggleTimeout();
}, 2000);
}
render() {
return (
<ActivityIndicator
animating={this.state.animating}
style={[styles.centering, {height: 80}]}
size="large"
/>
);
}
}
exports.displayName = (undefined: ?string);
exports.framework = 'React';
exports.title = '<ActivityIndicator>';
exports.description = 'Animated loading indicators.';
exports.examples = [
{
title: 'Default (small, white)',
render() {
return (
<ActivityIndicator
style={[styles.centering, styles.gray]}
color="white"
/>
);
}
},
{
title: 'Gray',
render() {
return (
<View>
<ActivityIndicator
style={[styles.centering]}
/>
<ActivityIndicator
style={[styles.centering, {backgroundColor: '#eeeeee'}]}
/>
</View>
);
}
},
{
title: 'Custom colors',
render() {
return (
<View style={styles.horizontal}>
<ActivityIndicator color="#0000ff" />
<ActivityIndicator color="#aa00aa" />
<ActivityIndicator color="#aa3300" />
<ActivityIndicator color="#00aa00" />
</View>
);
}
},
{
title: 'Large',
render() {
return (
<ActivityIndicator
style={[styles.centering, styles.gray]}
size="large"
color="white"
/>
);
}
},
{
title: 'Large, custom colors',
render() {
return (
<View style={styles.horizontal}>
<ActivityIndicator
size="large"
color="#0000ff"
/>
<ActivityIndicator
size="large"
color="#aa00aa"
/>
<ActivityIndicator
size="large"
color="#aa3300"
/>
<ActivityIndicator
size="large"
color="#00aa00"
/>
</View>
);
}
},
{
title: 'Start/stop',
render() {
return <ToggleAnimatingActivityIndicator />;
}
},
{
title: 'Custom size',
render() {
return (
<ActivityIndicator
style={[styles.centering, {transform: [{scale: 1.5}]}]}
size="large"
/>
);
}
},
{
platform: 'android',
title: 'Custom size (size: 75)',
render() {
return (
<ActivityIndicator
style={styles.centering}
size={75}
/>
);
}
},
];
const styles = StyleSheet.create({
centering: {
alignItems: 'center',
justifyContent: 'center',
padding: 8,
},
gray: {
backgroundColor: '#cccccc',
},
horizontal: {
flexDirection: 'row',
justifyContent: 'space-around',
padding: 8,
},
});
|
src/components/app.js | SupachaiChaipratum/ReduxSimpleStarter | import React, { Component } from 'react';
import CommentBox from './comment_box';
import CommentList from './comment_list';
export default class App extends Component {
render() {
return (
<div>
<CommentBox />
<CommentList />
</div>
);
}
}
|
client/modules/User/__tests__/components/PostListItem.spec.js | Hitzk0pf/BetterBackPacking | import React from 'react';
import test from 'ava';
import sinon from 'sinon';
import PostListItem from '../../components/PostListItem/PostListItem';
import { mountWithIntl, shallowWithIntl } from '../../../../util/react-intl-test-helper';
const post = { name: 'Prashant', title: 'Hello Mern', slug: 'hello-mern', cuid: 'f34gb2bh24b24b2', content: "All cats meow 'mern!'" };
const props = {
post,
onDelete: () => {},
};
test('renders properly', t => {
const wrapper = shallowWithIntl(
<PostListItem {...props} />
);
t.truthy(wrapper.hasClass('single-post'));
t.is(wrapper.find('Link').first().prop('children'), post.title);
t.regex(wrapper.find('.author-name').first().text(), new RegExp(post.name));
t.is(wrapper.find('.post-desc').first().text(), post.content);
});
test('has correct props', t => {
const wrapper = mountWithIntl(
<PostListItem {...props} />
);
t.deepEqual(wrapper.prop('post'), props.post);
t.is(wrapper.prop('onClick'), props.onClick);
t.is(wrapper.prop('onDelete'), props.onDelete);
});
test('calls onDelete', t => {
const onDelete = sinon.spy();
const wrapper = shallowWithIntl(
<PostListItem post={post} onDelete={onDelete} />
);
wrapper.find('.post-action > a').first().simulate('click');
t.truthy(onDelete.calledOnce);
});
|
src/index.js | andrit/VideoListReact | import React from 'react';
import ReactDOM from 'react-dom';
import App from './components/app';
ReactDOM.render(
<App />
, document.querySelector('.container'));
|
frontend/src/screens/selection-viewer/selection-viewer.js | desihub/qlf | import React from 'react';
import Paper from '@material-ui/core/Paper';
import { withStyles } from '@material-ui/core/styles';
import PropTypes from 'prop-types';
import Petals from '../../components/petals/petals';
import Radio from '@material-ui/core/Radio';
import RadioGroup from '@material-ui/core/RadioGroup';
import FormControlLabel from '@material-ui/core/FormControlLabel';
import FormLabel from '@material-ui/core/FormLabel';
import { FadeLoader } from 'halogenium';
import Button from '@material-ui/core/Button';
import PNGViewer from './png-viewer/png-viewer';
import LogViewer from './log-viewer/log-viewer';
import GlobalViewer from './global-viewer/global-viewer';
import SpectraViewer from './spectra-viewer/spectra-viewer';
const styles = {
controlsContainer: {
display: 'grid',
alignItems: 'center',
width: '12vw',
justifyContent: 'space-evenly',
borderRight: '1px solid darkgrey',
overflowY: 'auto',
paddingRight: '10px',
boxSizing: 'border-box',
},
column: {
display: 'flex',
flexDirection: 'column',
},
gridRow: {
display: 'grid',
gridTemplateColumns: '12vw calc(100vw - 64px - 12vw)',
width: 'calc(100vw - 64px)',
height: 'calc(100vh - 135px)',
},
viewer: {
width: 'calc(100vw - 64px - 12vw)',
},
fadeLoaderFull: {
position: 'absolute',
paddingLeft: 'calc((100vw - 40px) / 2)',
paddingTop: 'calc(25vh)',
},
fadeLoader: {
position: 'absolute',
paddingLeft: 'calc((100vw - 300px) / 2)',
paddingTop: 'calc(25vh)',
},
selection: {
textAlign: 'center',
},
buttons: {
display: 'grid',
width: '10vw',
},
button: {
float: 'right',
fontSize: '1.2vw',
margin: '10px 0',
},
buttonGreen: {
backgroundColor: 'green',
color: 'white',
},
spectrographLabel: {
paddingBottom: 10,
},
main: {
margin: '16px',
padding: '16px',
height: 'calc(100vh - 135px)',
},
title: {
fontSize: '1.2vw',
},
text: {
fontSize: '1.1vw',
marginLeft: '0.5vw',
},
lineH: {
height: '4.87vh',
marginLeft: 0,
},
wh: {
width: '1.7vw',
height: '3.5vh',
},
};
class SelectionViewer extends React.Component {
constructor(props) {
super(props);
this.state = {
selectArm: '',
selectProcessing: '',
selectSpectrograph: [],
arm: '',
spectrograph: [],
processing: '',
loading: false,
preview: false,
};
}
static propTypes = {
classes: PropTypes.object,
spectrograph: PropTypes.bool,
armAll: PropTypes.bool,
arm: PropTypes.bool,
processing: PropTypes.bool,
};
handleChangeSpectrograph = spectrograph => {
this.setState({
spectrograph: [spectrograph],
preview: false,
loading: false,
});
};
handleChangeArm = evt => {
this.setState({ arm: evt.target.value, preview: false, loading: false });
};
handleChangeProcessing = evt => {
this.setState({
processing: evt.target.value,
preview: false,
loading: false,
});
};
loadStart = () => {
this.setState({ loading: true });
};
loadEnd = () => {
this.setState({ loading: false });
};
renderLoading = () => {
if (!this.state.loading) return null;
const showControls =
this.props.arm || this.props.spectrograph || this.props.processing;
const classLoading = showControls
? styles.fadeLoader
: styles.fadeLoaderFull;
return (
<div className={this.props.classes.loading}>
<FadeLoader
style={classLoading}
color="#424242"
size="16px"
margin="4px"
/>
</div>
);
};
handleSubmit = () => {
this.setState({
selectProcessing: this.state.processing,
selectSpectrograph: this.state.spectrograph,
selectArm: this.state.arm,
preview: true,
});
this.loadStart();
};
clearSelection = () => {
this.setState({
selectArm: '',
selectProcessing: '',
selectSpectrograph: [],
processing: '',
spectrograph: [],
arm: '',
loading: false,
});
};
renderSpectrographSelection = () => {
const { classes } = this.props;
if (this.props.spectrograph)
return (
<div>
<FormLabel
className={this.props.classes.spectrographLabel}
component="legend"
classes={{ root: classes.title }}
>
Spectrograph:
</FormLabel>
<Petals
selected={this.state.spectrograph}
onClick={this.handleChangeSpectrograph}
size={22}
/>
</div>
);
};
renderArmSelection = () => {
const { classes } = this.props;
if (this.props.arm)
return (
<div className={this.props.classes.selection}>
<FormLabel component="legend" classes={{ root: classes.title }}>
Arm:
</FormLabel>
<div className={this.props.classes.row}>
<RadioGroup
className={this.props.classes.column}
value={this.state.arm}
onChange={this.handleChangeArm}
>
{this.props.armAll ? (
<FormControlLabel
value="all"
control={<Radio classes={{ root: classes.wh }} />}
label="All"
classes={{ label: classes.text, root: classes.lineH }}
/>
) : null}
<FormControlLabel
value="b"
control={<Radio classes={{ root: classes.wh }} />}
label="b"
classes={{ label: classes.text, root: classes.lineH }}
/>
<FormControlLabel
value="r"
control={<Radio classes={{ root: classes.wh }} />}
label="r"
classes={{ label: classes.text, root: classes.lineH }}
/>
<FormControlLabel
value="z"
control={<Radio classes={{ root: classes.wh }} />}
label="z"
classes={{ label: classes.text, root: classes.lineH }}
/>
</RadioGroup>
</div>
</div>
);
};
renderProcessingSelection = () => {
const { classes } = this.props;
if (this.props.processing)
return (
<div className={this.props.classes.selection}>
<FormLabel component="legend" classes={{ root: classes.title }}>
Processing:
</FormLabel>
<RadioGroup
value={this.state.processing}
onChange={this.handleChangeProcessing}
>
<FormControlLabel
value="raw"
control={<Radio classes={{ root: classes.wh }} />}
label="raw"
classes={{ label: classes.text, root: classes.lineH }}
/>
<FormControlLabel
value="reduced"
control={<Radio classes={{ root: classes.wh }} />}
label="reduced"
classes={{ label: classes.text, root: classes.lineH }}
/>
</RadioGroup>
</div>
);
};
renderControls = () => {
const { classes } = this.props;
if (this.props.arm || this.props.spectrograph || this.props.processing)
return (
<div className={classes.controlsContainer}>
{this.renderSpectrographSelection()}
{this.renderArmSelection()}
{this.renderProcessingSelection()}
<div className={classes.buttons}>
{this.renderSubmit()}
{this.renderClear()}
</div>
</div>
);
};
renderClear = () => (
<Button
onClick={this.clearSelection}
variant="raised"
size="small"
className={this.props.classes.button}
>
Clear
</Button>
);
renderSubmit = () => (
<Button
onClick={this.handleSubmit}
variant="raised"
size="small"
className={this.props.classes.button}
classes={{ raised: this.props.classes.buttonGreen }}
disabled={!this.isValid()}
>
Submit
</Button>
);
isValid = () => {
let valid = true;
if (this.props.arm) {
valid = this.state.arm !== '';
}
if (this.props.spectrograph) {
valid = valid && this.state.spectrograph.length !== 0;
}
if (this.props.processing) {
valid = valid && this.state.processing !== '';
}
return valid;
};
renderViewer = () => {
if (!this.state.preview) return;
switch (window.location.pathname) {
case '/ccd-viewer':
return (
<PNGViewer
processing={this.state.selectProcessing}
arm={this.state.selectArm}
spectrograph={this.state.selectSpectrograph}
loadEnd={this.loadEnd}
/>
);
case '/log-viewer':
return (
<LogViewer
arm={this.state.selectArm}
spectrograph={this.state.selectSpectrograph}
loadEnd={this.loadEnd}
loadStart={this.loadStart}
/>
);
case '/fiber-viewer':
return (
<GlobalViewer
screen={'globalfiber'}
loadEnd={this.loadEnd}
loadStart={this.loadStart}
arm={this.state.selectArm}
/>
);
case '/focus-viewer':
return (
<GlobalViewer
screen={'globalfocus'}
loadEnd={this.loadEnd}
loadStart={this.loadStart}
arm={this.state.selectArm}
/>
);
case '/snr-viewer':
return (
<GlobalViewer
screen={'globalsnr'}
loadEnd={this.loadEnd}
loadStart={this.loadStart}
arm={this.state.selectArm}
/>
);
case '/spectra-viewer':
return (
<SpectraViewer
loadEnd={this.loadEnd}
loadStart={this.loadStart}
arm={this.state.selectArm}
/>
);
default:
return null;
}
};
render() {
const { classes } = this.props;
const showControls =
this.props.arm || this.props.spectrograph || this.props.processing;
return (
<Paper elevation={4} className={classes.main}>
<div className={showControls ? classes.gridRow : null}>
{this.renderControls()}
<div className={showControls ? classes.viewer : null}>
{this.renderLoading()}
{this.renderViewer()}
</div>
</div>
</Paper>
);
}
}
export default withStyles(styles)(SelectionViewer);
|
plugins-test/iscroll-react/src/main.js | fengnovo/diary | import React from 'react';
import ReactDom from 'react-dom';
// import 'react-fastclick';
import './css/app.scss';
import App from './js/App.jsx';
ReactDom.render( <App />, document.getElementById('app'));
|
generators/crud/templates/crud-routes/crud-route.tmpl.js | societe-generale/react-loopback-generator | import React from 'react';
import { Route } from 'react-router';
import <%= viewClassName %> from '../containers/<%= entityFileName %>';
const route = (
<Route path="<%= entityFileName %>" component={<%= viewClassName %>} />
);
export default route;
|
components/header.js | hillcitymnag/www.hillcitymnag.church | import React from 'react'
import css from 'next/css'
import {
color,
mediaQuery,
pseudo
} from '../shared/constants'
export default () => (
<div className='parallax' {...parallax}>
<div {...parallaxBackground}>
<img alt='' className='parallax-background-image' src='static/img/background.jpg' {...parallaxImage} />
</div>
<div className='container' {...container}>
<div className='row text-center'>
<div className='col-xs-12'>
<p {...fancy}>Be still</p>
<p {...simple}>and know that</p>
<p className='center-block' {...bold}>I AM GOD</p>
<p {...scripture}>Psalm 46:10</p>
</div>
</div>
</div>
</div>
)
const mediaQuery475 = '@media (min-width: 475px)'
const mediaQuery1675 = '@media (min-width: 1675px)'
const parallax = css({
position: 'relative',
overflow: 'hidden',
// display: 'block', // IE?
// backgroundSize: '100%', // IE?
// width: '100%', // needed?
height: 425,
[mediaQuery475]: { height: 530 },
[mediaQuery.sm]: { height: 700 },
[pseudo.after]: {
position: 'absolute',
display: 'block',
top: 0,
left: 0,
width: '100%',
height: '100%',
backgroundSize: 2000,
content: '""',
opacity: 0.7,
zIndex: 1,
background: [
'url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iIzIzMjUyNiIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiM0MTQzNDUiIHN0b3Atb3BhY2l0eT0iMC44NyIvPgogIDwvbGluZWFyR3JhZGllbnQ+CiAgPHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEiIGhlaWdodD0iMSIgZmlsbD0idXJsKCNncmFkLXVjZ2ctZ2VuZXJhdGVkKSIgLz4KPC9zdmc+)',
'gradient(linear, left top, left bottom, color-stop(0%, rgba(35,37,38,1)), color-stop(100%, rgba(65,67,69,0.87)))',
'linear-gradient(top, rgba(35,37,38,1) 0%, rgba(65,67,69,0.87) 100%)',
'linear-gradient(to bottom, rgba(35,37,38,1) 0%, rgba(65,67,69,0.87) 100%)'
],
filter: 'progid:DXImageTransform.Microsoft.gradient(startColorstr="#232526", endColorstr="#de414345", GradientType=0)'
}
})
const parallaxBackground = css({
position: 'relative',
// width: '100%', // IE?
// height: '100%', // IE?
zIndex: 1,
[mediaQuery.sm]: { top: 0 },
[mediaQuery.md]: { top: -100 },
[mediaQuery.lg]: { top: -240 },
[mediaQuery1675]: { top: -450 }
})
const parallaxImage = css({
// position: 'relative', // IE?
width: '100%'
// height: 'auto' // IE?
})
const container = css({
position: 'absolute',
// marginLeft: 'auto', // IE?
// marginRight: 'auto', // IE?
top: 0,
left: 0,
right: 0,
zIndex: 2
})
const fancy = css({
marginTop: 190,
color: color.lightGray,
fontFamily: 'spumante-regular-plus-shadow, sans-serif',
fontSize: 75,
lineHeight: 1,
[mediaQuery475]: {
marginTop: 300
},
[mediaQuery.sm]: {
marginTop: 400,
fontSize: 100
}
})
const simple = css({
position: 'relative',
color: color.lightGray,
fontFamily: 'reklame-script, sans-serif',
fontSize: 35,
lineHeight: 1,
top: -30,
left: 35,
[mediaQuery.sm]: {
fontSize: 47,
top: -40,
left: 47
}
})
const bold = css({
position: 'relative',
paddingTop: 8,
backgroundColor: color.lightGray,
color: color.charcoal,
fontFamily: 'proxima-nova-condensed, sans-serif',
fontSize: 60,
fontWeight: 900,
lineHeight: 1,
top: -25,
[mediaQuery475]: {
width: 350
},
[mediaQuery.sm]: {
paddingTop: 11,
fontSize: 80,
top: -30,
width: '65%'
},
[mediaQuery.md]: {
width: '55%'
},
[mediaQuery.lg]: {
width: '45%'
}
})
const scripture = css({
position: 'relative',
color: color.lightGray,
fontFamily: 'reklame-script, sans-serif',
fontSize: 20,
lineHeight: 1,
top: -20,
[mediaQuery.sm]: {
fontSize: 27
}
})
|
src/components/WeatherForecast/WeatherForecast.js | Mikosko/EimPanel | /**
* @Author: Miloš Kolčák
* @Date: 2017-01-04T15:32:41+01:00
* @Email: milos.kolcak@gmail.com
* @Last modified by: Miloš Kolčák
* @Last modified time: 2017-01-10T13:29:22+01:00
*/
import React from 'react'
import style from './style.scss'
import Block from './WeatherForecastBlock'
import ComponentWrapper from '../ComponentWrapper'
const WeatherForecastData = {
symbol : "°C",
data : [
{
value: 5,
icon : "snow",
label: "Ně"
},
{
value: 15,
icon : "snow",
label: "Po"
},
{
value: 22,
icon : "sun-cloud",
label: "Út"
},
{
value: 22,
icon : "clouds",
label: "St"
},
{
value: 11,
icon : "clouds",
label: "Čt"
},
{
value: 7,
icon : "sun-cloud",
label: "Pá"
},
{
value: 8,
icon : "sun",
label: "So"
}]
};
class WeatherForecast extends React.Component {
constructor(props) {
super(props);
this.state = {
symbol : "",
data : []
}
}
getDataFromAPI() {
this.setState({
symbol : WeatherForecastData.symbol,
data : function(){
let data = [];
for(let item of WeatherForecastData.data) {
let obj = {
width : 100/WeatherForecastData.data.length,
value : item.value,
icon : item.icon,
label : item.label
}
data.push(obj);
}
return data;
}()
})
}
componentDidMount() {
this.getDataFromAPI();
}
render() {
const { data, symbol } = this.state;
return <ComponentWrapper size={2} color="primary" className="block-offset">
<h3 className={style.title}>Spotřeba tepla v domě</h3>
{data.map((block, i) => {
return <Block key={i} width={block.width} value={block.value} icon={block.icon} symbol={" " + symbol} label={block.label}/>
})}
</ComponentWrapper>
}
}
export default WeatherForecast
|
src/containers/DevTools.js | ToniChaz/react-redux | import React from 'react'
// Exported from redux-devtools
import { createDevTools } from 'redux-devtools'
// Monitors are separate packages, and you can make a custom one
import LogMonitor from 'redux-devtools-log-monitor'
import DockMonitor from 'redux-devtools-dock-monitor'
// createDevTools takes a monitor and produces a DevTools component
const DevTools = createDevTools(
// Monitors are individually adjustable with props.
// Consult their repositories to learn about those props.
// Here, we put LogMonitor inside a DockMonitor.
// Note: DockMonitor is visible by default.
<DockMonitor toggleVisibilityKey='ctrl-h'
changePositionKey='ctrl-q'
defaultIsVisible={true}>
<LogMonitor theme='tomorrow' />
</DockMonitor>
)
export default DevTools
|
src/components/TickerPrice.js | nsisodiya/DemoStockApp | /**
* Created by narendrasisodiya on 06/03/17.
*/
import React from 'react';
import styled from 'styled-components';
function decideBackgroundColor(props) {
let color;
if (props.oldVal === undefined) {
return 'white';
}
if (props.newVal < props.oldVal) {
color = 'red';
} else {
color = 'green';
}
return color;
}
function decideColor(props) {
let color;
if (props.oldVal === undefined) {
return 'black';
}
if (props.newVal < props.oldVal) {
color = 'blue';
} else {
color = 'white';
}
return color;
}
const Label = styled.span`
background: ${decideBackgroundColor};
color: ${decideColor};
`;
function TickerPrice(props) {
return <Label {...props}>{props.newVal}</Label>;
}
export default TickerPrice;
|
src/pages/hush.js | vitorbarbosa19/ziro-online | import React from 'react'
import BrandGallery from '../components/BrandGallery'
export default () => (
<BrandGallery brand='Hush' />
)
|
src/app/components/CurrentBill/index.js | mahimaag/react-web-boilerplate | import React from 'react';
import style from './style.scss';
export default class CurrentBill extends React.Component{
render () {
return (
<div className="card">
<h3 className="title">My Current Bill</h3>
<p>Your Current Bill Amount</p>
<div className="content">
<div className="bill-amount">
<span className="amount">$100.00</span>
</div>
<div className="bill-details">
<span>Issue Date: 16/12/2016</span>
<span>Past Due: $15.00</span>
</div>
<div className="button-actions">
<div>
<a href="#" className="btn">View Bills</a>
</div>
<div>
<a href="#" className="btn">Pay my Bill</a>
</div>
</div>
</div>
</div>
)
}
} |
src/views/task.js | dreitagebart/crispyScrum | import _ from 'lodash'
import React from 'react'
import { connect } from 'react-redux'
import { boardCreate } from '../actions'
import { Button, Col, Row, Form, Input } from 'antd'
@connect((store, props) => {
const { tasks } = store.root
return {
task: _.find(props.tasks, { _id: props.match.params.id })
}
})
export class Task extends React.Component {
render () {
const { task } = this.props
return (
<div>
<Row>
<Col span={24}><h1>{task.title}</h1></Col>
</Row>
<Row>
<Col span={18}>{task.descr}</Col>
</Row>
</div>
)
}
}
|
src/svg-icons/action/swap-horiz.js | w01fgang/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let ActionSwapHoriz = (props) => (
<SvgIcon {...props}>
<path d="M6.99 11L3 15l3.99 4v-3H14v-2H6.99v-3zM21 9l-3.99-4v3H10v2h7.01v3L21 9z"/>
</SvgIcon>
);
ActionSwapHoriz = pure(ActionSwapHoriz);
ActionSwapHoriz.displayName = 'ActionSwapHoriz';
ActionSwapHoriz.muiName = 'SvgIcon';
export default ActionSwapHoriz;
|
node_modules/react-select/examples/src/components/NumericSelect.js | Alex-Shilman/Drupal8Node | import React from 'react';
import Select from 'react-select';
var ValuesAsNumbersField = React.createClass({
displayName: 'ValuesAsNumbersField',
propTypes: {
label: React.PropTypes.string
},
getInitialState () {
return {
options: [
{ value: 10, label: 'Ten' },
{ value: 11, label: 'Eleven' },
{ value: 12, label: 'Twelve' },
{ value: 23, label: 'Twenty-three' },
{ value: 24, label: 'Twenty-four' }
],
matchPos: 'any',
matchValue: true,
matchLabel: true,
value: null,
multi: false
};
},
onChangeMatchStart(event) {
this.setState({
matchPos: event.target.checked ? 'start' : 'any'
});
},
onChangeMatchValue(event) {
this.setState({
matchValue: event.target.checked
});
},
onChangeMatchLabel(event) {
this.setState({
matchLabel: event.target.checked
});
},
onChange(value) {
this.setState({ value });
console.log('Numeric Select value changed to', value);
},
onChangeMulti(event) {
this.setState({
multi: event.target.checked
});
},
render () {
var matchProp = 'any';
if (this.state.matchLabel && !this.state.matchValue) {
matchProp = 'label';
}
if (!this.state.matchLabel && this.state.matchValue) {
matchProp = 'value';
}
return (
<div className="section">
<h3 className="section-heading">{this.props.label}</h3>
<Select
matchPos={this.state.matchPos}
matchProp={matchProp}
multi={this.state.multi}
onChange={this.onChange}
options={this.state.options}
simpleValue
value={this.state.value}
/>
<div className="checkbox-list">
<label className="checkbox">
<input type="checkbox" className="checkbox-control" checked={this.state.multi} onChange={this.onChangeMulti} />
<span className="checkbox-label">Multi-Select</span>
</label>
<label className="checkbox">
<input type="checkbox" className="checkbox-control" checked={this.state.matchValue} onChange={this.onChangeMatchValue} />
<span className="checkbox-label">Match value only</span>
</label>
<label className="checkbox">
<input type="checkbox" className="checkbox-control" checked={this.state.matchLabel} onChange={this.onChangeMatchLabel} />
<span className="checkbox-label">Match label only</span>
</label>
<label className="checkbox">
<input type="checkbox" className="checkbox-control" checked={this.state.matchPos === 'start'} onChange={this.onChangeMatchStart} />
<span className="checkbox-label">Only include matches from the start of the string</span>
</label>
</div>
<div className="hint">This example uses simple numeric values</div>
</div>
);
}
});
module.exports = ValuesAsNumbersField;
|
docs/src/pages/premium-themes/onepirate/modules/form/RFTextField.js | lgollut/material-ui | import React from 'react';
import PropTypes from 'prop-types';
import TextField from '../components/TextField';
function RFTextField(props) {
const {
autoComplete,
input,
InputProps,
meta: { touched, error, submitError },
...other
} = props;
return (
<TextField
error={Boolean(touched && (error || submitError))}
{...input}
{...other}
InputProps={{
inputProps: {
autoComplete,
},
...InputProps,
}}
helperText={touched ? error || submitError : ''}
/>
);
}
RFTextField.propTypes = {
autoComplete: PropTypes.string,
input: PropTypes.object.isRequired,
InputProps: PropTypes.object,
meta: PropTypes.shape({
error: PropTypes.string,
touched: PropTypes.bool.isRequired,
}).isRequired,
};
export default RFTextField;
|
packages/web/src/components/screens/import/ImportFileDropzone.js | hwaterke/inab | import cuid from 'cuid'
import Papa from 'papaparse'
import PropTypes from 'prop-types'
import {head} from 'ramda'
import React from 'react'
import Dropzone from 'react-dropzone'
import FontAwesome from 'react-fontawesome'
import styled from 'styled-components'
import {Box} from '../../presentational/atoms/Box'
import {CenteredSpinner} from '../../presentational/atoms/CenteredSpinner'
const DropzoneContainer = styled.div`
display: flex;
justify-content: center;
`
const DropzoneInside = styled(Dropzone)`
width: 150px;
height: 150px;
display: flex;
justify-content: center;
align-items: center;
border: 1px dashed rgba(0, 0, 0, 0.4);
font-size: 4rem;
border-radius: 0.5rem;
`
export class ImportFileDropzone extends React.Component {
static propTypes = {
account: PropTypes.shape({
name: PropTypes.string.isRequired,
}).isRequired,
clearImportAccountUuid: PropTypes.func.isRequired,
setImportTransactions: PropTypes.func.isRequired,
}
state = {
loading: false,
errors: null,
}
transformValue = (value, column) => {
const result = value.trim()
if (column === 'amount') {
return parseInt(result, 10)
}
return result
}
transformResults(transactions) {
return transactions.map(transaction => ({...transaction, importId: cuid()}))
}
onDrop = files => {
if (files.length !== 1) {
this.setState({errors: ['Please provide exactly one CSV file']})
}
this.setState({loading: true}, () => {
Papa.parse(head(files), {
header: true,
skipEmptyLines: true,
transform: this.transformValue,
complete: results => {
if (results.errors.length > 0) {
this.setState({loading: false, errors: results.errors})
return
}
this.setState({loading: false})
this.props.setImportTransactions(this.transformResults(results.data))
},
})
})
}
render() {
const {account, clearImportAccountUuid} = this.props
const {loading, errors} = this.state
if (loading) {
return <CenteredSpinner />
}
return (
<div className="columns">
<div className="column">
<Box>
<div className="content">
{errors && (
<div className="notification is-danger">
<ul>
{errors.map((error, i) => (
<li key={i}>{error.message}</li>
))}
</ul>
</div>
)}
<p>
Importing transactions for account: <b>{account.name}</b>
<button
className="delete button is-text"
onClick={clearImportAccountUuid}
>
Clear account
</button>
</p>
<ul>
<li>One CSV file</li>
<li>Must be UTF-8</li>
<li>First line must be a header row</li>
<li>
One line needs to be <b>amount</b>
</li>
<li>
One line needs to be <b>date</b>
</li>
<li>
You can have a <b>payee_uuid</b> line
</li>
<li>
You can have a <b>payee</b> line that will be used to match
payees by name
</li>
</ul>
</div>
</Box>
</div>
<div className="column">
<Box>
<DropzoneContainer>
<DropzoneInside onDrop={this.onDrop}>
<FontAwesome name="upload" />
</DropzoneInside>
</DropzoneContainer>
</Box>
</div>
</div>
)
}
}
|
scripts/components/pages/testPage/testPage.js | SwordSoul/testpage | import React from 'react';
import {branch} from 'baobab-react/decorators';
@branch({
cursors: {
salesForceAdded: ['user', 1, 'salesForce', 'salesForceAdded']
}
})
class |
src/components/Header/Header.js | Rockyluoqi/map_realtime_render | /**
* React Starter Kit (https://www.reactstarterkit.com/)
*
* Copyright © 2014-2016 Kriasoft, LLC. All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE.txt file in the root directory of this source tree.
*/
import React, { Component } from 'react';
import withStyles from 'isomorphic-style-loader/lib/withStyles';
import s from './Header.scss';
import Link from '../Link';
import Navigation from '../Navigation';
class Header extends Component {
render() {
return (
<div className={s.root}>
<div className={s.container}>
<Navigation className={s.nav} />
<Link className={s.brand} to="/">
<img src={require('./logo-small.png')} width="38" height="38" alt="React" />
<span className={s.brandTxt}>Your Company</span>
</Link>
<div className={s.banner}>
<h1 className={s.bannerTitle}>React</h1>
<p className={s.bannerDesc}>Complex web apps made easy</p>
</div>
</div>
</div>
);
}
}
export default withStyles(Header, s);
|
src/containers/DevToolsWindow.js | Anomen/universal-react-redux-starter-kit | import React from 'react';
import { createDevTools } from 'redux-devtools';
import LogMonitor from 'redux-devtools-log-monitor';
export default createDevTools(
<LogMonitor />
);
|
src/App.js | WilliamHolmes/Apollo_Client_Test | import React from 'react';
import { connect } from 'react-apollo';
export class MyName extends React.Component {
constructor(props) {
super(props);
}
render() {
console.log('Props', this.props);
return (
<div>Hello World</div>
);
}
}
const mapQueriesToProps = ({ ownProps, state }) => {
console.log('mapQueriesToProps', ownProps, state);
return {
myDisplayName: {
query: `{
viewer {
me {
displayName
}
}
}`
}
};
};
export default connect({ mapQueriesToProps })(MyName);
|
packages/material-ui-icons/src/Motorcycle.js | cherniavskii/material-ui | import React from 'react';
import createSvgIcon from './utils/createSvgIcon';
export default createSvgIcon(
<g><path d="M19.44 9.03L15.41 5H11v2h3.59l2 2H5c-2.8 0-5 2.2-5 5s2.2 5 5 5c2.46 0 4.45-1.69 4.9-4h1.65l2.77-2.77c-.21.54-.32 1.14-.32 1.77 0 2.8 2.2 5 5 5s5-2.2 5-5c0-2.65-1.97-4.77-4.56-4.97zM7.82 15C7.4 16.15 6.28 17 5 17c-1.63 0-3-1.37-3-3s1.37-3 3-3c1.28 0 2.4.85 2.82 2H5v2h2.82zM19 17c-1.66 0-3-1.34-3-3s1.34-3 3-3 3 1.34 3 3-1.34 3-3 3z" /></g>
, 'Motorcycle');
|
generators/presentation-component/templates/_Component.js | rjhilgefort/generator-react-modules | // @flow
import React from 'react';
import styled from 'styled-components';
const Container = styled.div`
`;
const <%= componentName %> = () => (
<Container>
</Container>
);
export default <%= componentName %>;
|
examples/cra-kitchen-sink/src/stories/App.stories.js | storybooks/storybook | // FIXME: svgr issue @igor-dv
import React from 'react';
import App from '../App';
export default {
title: 'App',
parameters: {
layout: 'fullscreen',
},
};
export const FullApp = () => <App />;
FullApp.storyName = 'full app';
|
examples/index.js | chentsulin/react-scrolla | import React from 'react';
import ReactDom from 'react-dom';
import App from './app/App';
ReactDom.render(
<App />,
document.getElementById('react-root')
);
|
app/components/LoaderComponent.js | tjinauyeung/customization-requests-app | import React from 'react';
class LoaderComponent extends React.Component {
render() {
return (
<div className="loader__container">
<div className="loader"></div>
</div>
)
}
};
export default LoaderComponent;
|
fields/types/datearray/DateArrayField.js | everisARQ/keystone | import ArrayFieldMixin from '../../mixins/ArrayField';
import DateInput from '../../components/DateInput';
import Field from '../Field';
import React from 'react';
import moment from 'moment';
const DEFAULT_INPUT_FORMAT = 'YYYY-MM-DD';
const DEFAULT_FORMAT_STRING = 'Do MMM YYYY';
module.exports = Field.create({
displayName: 'DateArrayField',
mixins: [ArrayFieldMixin],
propTypes: {
formatString: React.PropTypes.string,
inputFormat: React.PropTypes.string,
},
getDefaultProps () {
return {
formatString: DEFAULT_FORMAT_STRING,
inputFormat: DEFAULT_INPUT_FORMAT,
};
},
processInputValue (value) {
if (!value) return;
const m = moment(value);
return m.isValid() ? m.format(this.props.inputFormat) : value;
},
formatValue (value) {
return value ? moment(value).format(this.props.formatString) : '';
},
getInputComponent () {
return DateInput;
},
});
|
client/views/admin/apps/AppSettingsAssembler.js | VoiSmart/Rocket.Chat | import { Box } from '@rocket.chat/fuselage';
import { capitalize } from '@rocket.chat/string-helpers';
import React from 'react';
import AppSetting from './AppSetting';
const AppSettingsAssembler = ({ settings, values, handlers }) => (
<Box>
{Object.values(settings).map((current) => {
const { id } = current;
return (
<AppSetting
key={id}
appSetting={current}
value={values[id]}
onChange={handlers[`handle${capitalize(id)}`]}
/>
);
})}
</Box>
);
export default AppSettingsAssembler;
|
packages/vx-hierarchy/src/hierarchies/Tree.js | Flaque/vx | import React from 'react';
import cx from 'classnames';
import { Group } from '@vx/group';
import { tree as d3tree } from 'd3-hierarchy';
export default function Tree({
top,
left,
className,
root,
size,
nodeSize,
separation,
linkComponent,
nodeComponent,
...restProps
}) {
const tree = d3tree();
if (size) tree.size(size);
if (nodeSize) tree.nodeSize(nodeSize);
if (separation) tree.separation(separation);
const data = tree(root);
const links = data.links();
const descendants = root.descendants();
return (
<Group top={top} left={left}>
{linkComponent && links.map((link, i) => {
return (
<Group key={`tree-link-${i}`}>
{React.createElement(linkComponent, { link })}
</Group>
);
})}
{nodeComponent && descendants.map((node, i) => {
return (
<Group key={`tree-node-${i}`}>
{React.createElement(nodeComponent, { node })}
</Group>
);
})}
</Group>
);
} |
public/js/components/LivingHabits.js | Vabrins/CadernetaDoIdoso | import React from 'react';
import $ from 'jquery';
import { Link } from 'react-router-dom';
const initialState = {
do_you_go_to_day_centers_clubs_or_social_groups_2_11:'', do_you_do_any_volunteer_work_2_11:'', do_you_have_any_leisure_activities_2_11:'', do_you_engage_type_ph_act_least_three_tm_week_2_11:'', would_you_like_start_some_phy_activity_program_2_11:'', do_you_make_at_least_three_meals_a_day_2_11:'', do_you_eat_fruits_veg_your_meals_thro_the_day_2_11:'', in_at_least_one_meal_day_you_eat_meat_fish_eggs_2_11:'', you_have_custom_consuming_sug_dr_cak_bis_stuf_dess_2_11:'', in_the_prep_your_meals_great_qt_oils_used_fats_su_salt_2_11:'', do_you_include_water_intake_in_your_daily_routine_2_11:'', do_you_currently_smoke_any_tobacco_products_2_11:'', would_you_like_to_quit_smoking_2_11:'', are_you_a_former_smoker_2_11:'', do_you_drink_alcohol_2_11:'', have_you_ever_felt_the_need_to_reduce_or_of_alcohol_2_11:'', has_anyone_ever_criticized_you_for_drinking_2_11:'', feel_guilty_for_drinking_2_11:'', do_you_usually_drink_in_the_morning_2_11:''
};
class LivingHabits extends React.Component {
constructor (props) {
super(props);
this.state = initialState;
this.sendForm = this.sendForm.bind(this);
this.setAttendClubs211 = this.setAttendClubs211.bind(this);
this.setVolunteerWork211 = this.setVolunteerWork211.bind(this);
this.setLeiSureActivity211 = this.setLeiSureActivity211.bind(this);
this.setPhysicalActivity211 = this.setPhysicalActivity211.bind(this);
this.setActivityProgram211 = this.setActivityProgram211.bind(this);
this.setThreeMeals211 = this.setThreeMeals211.bind(this);
this.setFruitsvegeTables211 = this.setFruitsvegeTables211.bind(this);
this.setMeatFish211 = this.setMeatFish211.bind(this);
this.setSugaryDrinks211 = this.setSugaryDrinks211.bind(this);
this.setGreaseOils211 = this.setGreaseOils211.bind(this);
this.setWater211 = this.setWater211.bind(this);
this.setTobacco211 = this.setTobacco211.bind(this);
this.setStopSmoking211 = this.setStopSmoking211.bind(this);
this.setExSmoker211 = this.setExSmoker211.bind(this);
this.setAlcoholicBeverage211 = this.setAlcoholicBeverage211.bind(this);
this.setSuspendAlcohol211 = this.setSuspendAlcohol211.bind(this);
this.setDrink211 = this.setDrink211.bind(this);
this.setGuiltyforDrinking211 = this.setGuiltyforDrinking211.bind(this);
this.setDrinkMorning211 = this.setDrinkMorning211.bind(this);
}
componentWillMount() {
$.ajax({
url: "/api/v1/livinghabits",
dataType: "json",
method: "GET",
success:function(response){
console.log(response);
}.bind(this)
});
}
reset() {
this.setState(initialState);
}
sendForm(evt) {
let that = this;
$.ajax({
url: "/api/v1/livinghabits",
contentType: 'application/json',
dataType: 'json',
method: "POST",
data: JSON.stringify({ test: this.state }),
success: function(response){
console.log(response);
that.reset();
alert("Cadastrado com sucesso!");
},
error: function(response){
console.log("erro");
console.log(response);
}.bind(this)
});
}
render () {
return (
<div className="container" >
<form id="livinghabits" method="post">
<div className="row">
<div className="col">
<fieldset>
<h2>HÁBITOS DE VIDA </h2>
<h2> Identificação de hábitos de vida </h2>
<h2> Interesse social e lazer </h2>
<label>Você frequenta centros-dia, clubes ou grupos de convivência? </label><br/>
<input type="radio" checked={this.state.do_you_go_to_day_centers_clubs_or_social_groups_2_11 === "1"} onChange={this.setAttendClubs211} className="answers-110" id="2.11-attendclubs-y" name="answers[2.11[attendclubs]]" value="1" />Sim
<input type="radio" checked={this.state.do_you_go_to_day_centers_clubs_or_social_groups_2_11 === "0"} onChange={this.setAttendClubs211} className="answers-110" id="2.11-attendclubs-n" name="answers[2.11[attendclubs]]" value="0" />Não
<br/><br/>
<label>Você realiza algum trabalho voluntário? </label><br/>
<input type="radio" checked={this.state.do_you_do_any_volunteer_work_2_11 === "1"} onChange={this.setVolunteerWork211} className="answers-111" id="2.11-volunteerwork-y" name="answers[2.11[volunteerwork]]" value="1" />Sim
<input type="radio" checked={this.state.do_you_do_any_volunteer_work_2_11 === "0"} onChange={this.setVolunteerWork211} className="answers-111" id="2.11-volunteerwork-n" name="answers[2.11[volunteerwork]]" value="0" />Não
<br/><br/>
<label>Você tem alguma atividade de lazer? </label><br/>
<input type="radio" checked={this.state.do_you_have_any_leisure_activities_2_11 === "1"} onChange={this.setLeiSureActivity211} className="answers-112" id="2.11-leisureactivity-y" name="answers[2.11[leisureactivity]]" value="1" />Sim
<input type="radio" checked={this.state.do_you_have_any_leisure_activities_2_11 === "0"} onChange={this.setLeiSureActivity211} className="answers-112" id="2.11-leisureactivity-n" name="answers[2.11[leisureactivity]]" value="0" />Não
<br/><br/>
<h2> ATIVIDADE FÍSICA </h2>
<label>Você pratica algum tipo de atividade física (como caminhadas, natação, dança, ginástica etc.) pelo menos três vezes por semana? </label><br/>
<input type="radio" checked={this.state.do_you_engage_type_ph_act_least_three_tm_week_2_11 === "1"} onChange={this.setPhysicalActivity211} className="answers-113" id="2.11-physicalactivity-y" name="answers[2.11[physicalactivity]]" value="1" />Sim
<input type="radio" checked={this.state.do_you_engage_type_ph_act_least_three_tm_week_2_11 === "0"} onChange={this.setPhysicalActivity211} className="answers-113" id="2.11-physicalactivity-n" name="answers[2.11[physicalactivity]]" value="0" />Não
<br/><br/>
<label>Você gostaria de começar algum programa de atividade física? </label><br/>
<input type="radio" checked={this.state.would_you_like_start_some_phy_activity_program_2_11 === "1"} onChange={this.setActivityProgram211} className="answers-114" id="2.11-activityprogram-y" name="answers[2.11[activityprogram]]" value="1" />Sim
<input type="radio" checked={this.state.would_you_like_start_some_phy_activity_program_2_11 === "0"} onChange={this.setActivityProgram211} className="answers-114" id="2.11-activityprogram-n" name="answers[2.11[activityprogram]]" value="0" />Não
<br/><br/>
<h2> ALIMENTAÇÃO </h2>
<label>Você faz pelo menos três refeições por dia?</label><br/>
<input type="radio" checked={this.state.do_you_make_at_least_three_meals_a_day_2_11 === "1"} onChange={this.setThreeMeals211} className="answers-115" id="2.11-threemeals-y" name="answers[2.11[threemeals]]" value="1" />Sim
<input type="radio" checked={this.state.do_you_make_at_least_three_meals_a_day_2_11 === "0"} onChange={this.setThreeMeals211} className="answers-115" id="2.11-threemeals-n" name="answers[2.11[threemeals]]" value="0" />Não
<br/><br/>
<label>Você come frutas, legumes e verduras nas suas refeições ao longo do dia? </label><br/>
<input type="radio" checked={this.state.do_you_eat_fruits_veg_your_meals_thro_the_day_2_11 === "1"} onChange={this.setFruitsvegeTables211} className="answers-116" id="2.11-fruitsvegetables-y" name="answers[2.11[fruitsvegetables]]" value="1" />Sim
<input type="radio" checked={this.state.do_you_eat_fruits_veg_your_meals_thro_the_day_2_11 === "0"} onChange={this.setFruitsvegeTables211} className="answers-116" id="2.11-fruitsvegetables-n" name="answers[2.11[fruitsvegetables]]" value="0" />Não
<br/><br/>
<label>Em pelo menos uma refeição diária, você come carnes, peixes ou ovos?</label><br/>
<input type="radio" checked={this.state.in_at_least_one_meal_day_you_eat_meat_fish_eggs_2_11 === "1"} onChange={this.setMeatFish211} className="answers-117" id="2.11-meatfish-y" name="answers[2.11[meatfish]]" value="1" />Sim
<input type="radio" checked={this.state.in_at_least_one_meal_day_you_eat_meat_fish_eggs_2_11 === "0"} onChange={this.setMeatFish211} className="answers-117" id="2.11-meatfish-n" name="answers[2.11[meatfish]]" value="0" />Não
<br/><br/>
<label>Você tem o costume de consumir bebidas açucaradas, bolos, biscoitos recheados e sobremesas? </label><br/>
<input type="radio" checked={this.state.you_have_custom_consuming_sug_dr_cak_bis_stuf_dess_2_11 === "1"} onChange={this.setSugaryDrinks211} className="answers-118" id="2.11-sugarydrinks-y" name="answers[2.11[sugarydrinks]]" value="1" />Sim
<input type="radio" checked={this.state.you_have_custom_consuming_sug_dr_cak_bis_stuf_dess_2_11 === "0"} onChange={this.setSugaryDrinks211} className="answers-118" id="2.11-sugarydrinks-n" name="answers[2.11[sugarydrinks]]" value="0" />Não
<br/><br/>
<label>No preparo das suas refeições, é utilizada grande quantidade de óleos, gorduras, açúcar e sal?</label><br/>
<input type="radio" checked={this.state.in_the_prep_your_meals_great_qt_oils_used_fats_su_salt_2_11 === "1"} onChange={this.setGreaseOils211} className="answers-119" id="2.11-greaseoils-y" name="answers[2.11[greaseoils]]" value="1" />Sim
<input type="radio" checked={this.state.in_the_prep_your_meals_great_qt_oils_used_fats_su_salt_2_11 === "0"} onChange={this.setGreaseOils211} className="answers-119" id="2.11-greaseoils-n" name="answers[2.11[greaseoils]]" value="0" />Não
<br/><br/>
<label>Você inclui a ingestão de água na sua rotina diária? </label><br/>
<input type="radio" checked={this.state.do_you_include_water_intake_in_your_daily_routine_2_11 === "1"} onChange={this.setWater211} className="answers-120" id="2.11-water-y" name="answers[2.11[water]]" value="1" />Sim
<input type="radio" checked={this.state.do_you_include_water_intake_in_your_daily_routine_2_11 === "0"} onChange={this.setWater211} className="answers-120" id="2.11-water-n" name="answers[2.11[water]]" value="0" />Não
<br/><br/>
<h2> TABAGISMO </h2>
<label>Atualmente, você fuma algum produto do tabaco?</label><br/>
<input type="radio" checked={this.state.do_you_currently_smoke_any_tobacco_products_2_11 === "1"} onChange={this.setTobacco211} className="answers-121" id="2.11-tobacco-y" name="answers[2.11[tobacco]]" value="1" />Sim
<input type="radio" checked={this.state.do_you_currently_smoke_any_tobacco_products_2_11 === "0"} onChange={this.setTobacco211} className="answers-121" id="2.11-tobacco-n" name="answers[2.11[tobacco]]" value="0" />Não
<br/><br/>
<label>Você gostaria de parar de fumar? </label><br/>
<input type="radio" checked={this.state.would_you_like_to_quit_smoking_2_11 === "1"} onChange={this.setStopSmoking211} className="answers-122" id="2.11-stopsmoking-y" name="answers[2.11[stopsmoking]]" value="1" />Sim
<input type="radio" checked={this.state.would_you_like_to_quit_smoking_2_11 === "0"} onChange={this.setStopSmoking211} className="answers-122" id="2.11-stopsmoking-n" name="answers[2.11[stopsmoking]]" value="0" />Não
<br/><br/>
<label>Você é ex-fumante? </label><br/>
<input type="radio" checked={this.state.are_you_a_former_smoker_2_11 === "1"} onChange={this.setExSmoker211} className="answers-123" id="2.11-exsmoker-y" name="answers[2.11[exsmoker]]" value="1" />Sim
<input type="radio" checked={this.state.are_you_a_former_smoker_2_11 === "0"} onChange={this.setExSmoker211} className="answers-123" id="2.11-exsmoker-n" name="answers[2.11[exsmoker]]" value="0" />Não
<br/><br/>
<h2> ÁLCOOL </h2>
<label>Você consome bebida alcoólica? </label><br/>
<input type="radio" checked={this.state.do_you_drink_alcohol_2_11 === "1"} onChange={this.setAlcoholicBeverage211} className="answers-124" id="2.11-alcoholicbeverage-y" name="answers[2.11[alcoholicbeverage]]" value="1" />Sim
<input type="radio" checked={this.state.do_you_drink_alcohol_2_11 === "0"} onChange={this.setAlcoholicBeverage211} className="answers-124" id="2.11-alcoholicbeverage-n" name="answers[2.11[alcoholicbeverage]]" value="0" />Não
<br/><br/>
<label>Você já sentiu a necessidade de reduzir ou suspender o consumo de álcool? </label><br/>
<input type="radio" checked={this.state.have_you_ever_felt_the_need_to_reduce_or_of_alcohol_2_11 === "1"} onChange={this.setSuspendAlcohol211} className="answers-125" id="2.11-suspendalcohol-y" name="answers[2.11[suspendalcohol]]" value="1" />Sim
<input type="radio" checked={this.state.have_you_ever_felt_the_need_to_reduce_or_of_alcohol_2_11 === "0"} onChange={this.setSuspendAlcohol211} className="answers-125" id="2.11-suspendalcohol-n" name="answers[2.11[suspendalcohol]]" value="0" />Não
<br/><br/>
<label>Alguém já lhe criticou por você beber? </label><br/>
<input type="radio" checked={this.state.has_anyone_ever_criticized_you_for_drinking_2_11 === "1"} onChange={this.setDrink211} className="answers-126" id="2.11-drink-y" name="answers[2.11[drink]]" value="1" />Sim
<input type="radio" checked={this.state.has_anyone_ever_criticized_you_for_drinking_2_11 === "0"} onChange={this.setDrink211} className="answers-126" id="2.11-drink-n" name="answers[2.11[drink]]" value="0" />Não
<br/><br/>
<label>Sente-se culpado(a) por beber? </label><br/>
<input type="radio" checked={this.state.feel_guilty_for_drinking_2_11 === "1"} onChange={this.setGuiltyforDrinking211} className="answers-127" id="2.11-guiltyfordrinking-y" name="answers[2.11[guiltyfordrinking]]" value="1" />Sim
<input type="radio" checked={this.state.feel_guilty_for_drinking_2_11 === "0"} onChange={this.setGuiltyforDrinking211} className="answers-127" id="2.11-guiltyfordrinking-n" name="answers[2.11[guiltyfordrinking]]" value="0" />Não
<br/><br/>
<label>Costuma beber logo pela manhã?</label><br/>
<input type="radio" checked={this.state.do_you_usually_drink_in_the_morning_2_11 === "1"} onChange={this.setDrinkMorning211} className="answers-128" id="2.11-drinkmorning-y" name="answers[2.11[drinkmorning]]" value="1" />Sim
<input type="radio" checked={this.state.do_you_usually_drink_in_the_morning_2_11 === "0"} onChange={this.setDrinkMorning211} className="answers-128" id="2.11-drinkmorning-n" name="answers[2.11[drinkmorning]]" value="0" />Não
<br/><br/>
</fieldset>
</div>
</div>
</form>
<nav aria-label="Avaliação de saúde bucal">
<ul className="pagination justify-content-center">
<li className="page-item">
<Link className="page-link" to="/identificationchronicpainb" tabIndex="-1"><i className="fa fa-arrow-left" aria-hidden="true"></i></Link>
</li>
<li className="page-item">
<a className="page-link" onClick={this.sendForm}><i className="fa fa-floppy-o" aria-hidden="true"></i></a>
</li>
<li className="page-item">
<Link className="page-link" to="/pressurecontrol"><i className="fa fa-arrow-right" aria-hidden="true"></i></Link>
</li>
</ul>
</nav>
</div>
)
}
setAttendClubs211(evt) {
this.setState({do_you_go_to_day_centers_clubs_or_social_groups_2_11: evt.target.value});
}
setVolunteerWork211(evt) {
this.setState({do_you_do_any_volunteer_work_2_11: evt.target.value});
}
setLeiSureActivity211(evt) {
this.setState({do_you_have_any_leisure_activities_2_11: evt.target.value});
}
setPhysicalActivity211(evt) {
this.setState({do_you_engage_type_ph_act_least_three_tm_week_2_11: evt.target.value});
}
setActivityProgram211(evt) {
this.setState({would_you_like_start_some_phy_activity_program_2_11: evt.target.value});
}
setThreeMeals211(evt) {
this.setState({do_you_make_at_least_three_meals_a_day_2_11: evt.target.value});
}
setFruitsvegeTables211(evt) {
this.setState({do_you_eat_fruits_veg_your_meals_thro_the_day_2_11: evt.target.value});
}
setMeatFish211(evt) {
this.setState({in_at_least_one_meal_day_you_eat_meat_fish_eggs_2_11: evt.target.value});
}
setSugaryDrinks211(evt) {
this.setState({you_have_custom_consuming_sug_dr_cak_bis_stuf_dess_2_11: evt.target.value});
}
setGreaseOils211(evt) {
this.setState({in_the_prep_your_meals_great_qt_oils_used_fats_su_salt_2_11: evt.target.value});
}
setWater211(evt) {
this.setState({do_you_include_water_intake_in_your_daily_routine_2_11: evt.target.value});
}
setTobacco211(evt) {
this.setState({do_you_currently_smoke_any_tobacco_products_2_11: evt.target.value});
}
setStopSmoking211(evt) {
this.setState({would_you_like_to_quit_smoking_2_11: evt.target.value});
}
setExSmoker211(evt) {
this.setState({are_you_a_former_smoker_2_11: evt.target.value});
}
setAlcoholicBeverage211(evt) {
this.setState({do_you_drink_alcohol_2_11: evt.target.value});
}
setDentalSpecialTies211d(evt) {
this.setState({have_you_ever_felt_the_need_to_reduce_or_of_alcohol_2_11: evt.target.value});
}
setDrink211(evt) {
this.setState({has_anyone_ever_criticized_you_for_drinking_2_11: evt.target.value});
}
setGuiltyforDrinking211(evt) {
this.setState({feel_guilty_for_drinking_2_11: evt.target.value});
}
setDrinkMorning211(evt) {
this.setState({do_you_usually_drink_in_the_morning_2_11: evt.target.value});
}
setSuspendAlcohol211(evt) {
this.setState({have_you_ever_felt_the_need_to_reduce_or_of_alcohol_2_11: evt.target.value});
}
}
export default LivingHabits |
app/javascript/mastodon/features/blocks/index.js | yukimochi/mastodon | import React from 'react';
import { connect } from 'react-redux';
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
import ImmutablePureComponent from 'react-immutable-pure-component';
import ImmutablePropTypes from 'react-immutable-proptypes';
import { debounce } from 'lodash';
import PropTypes from 'prop-types';
import LoadingIndicator from '../../components/loading_indicator';
import Column from '../ui/components/column';
import ColumnBackButtonSlim from '../../components/column_back_button_slim';
import AccountContainer from '../../containers/account_container';
import { fetchBlocks, expandBlocks } from '../../actions/blocks';
import ScrollableList from '../../components/scrollable_list';
const messages = defineMessages({
heading: { id: 'column.blocks', defaultMessage: 'Blocked users' },
});
const mapStateToProps = state => ({
accountIds: state.getIn(['user_lists', 'blocks', 'items']),
hasMore: !!state.getIn(['user_lists', 'blocks', 'next']),
isLoading: state.getIn(['user_lists', 'blocks', 'isLoading'], true),
});
export default @connect(mapStateToProps)
@injectIntl
class Blocks extends ImmutablePureComponent {
static propTypes = {
params: PropTypes.object.isRequired,
dispatch: PropTypes.func.isRequired,
accountIds: ImmutablePropTypes.list,
hasMore: PropTypes.bool,
isLoading: PropTypes.bool,
intl: PropTypes.object.isRequired,
multiColumn: PropTypes.bool,
};
componentWillMount () {
this.props.dispatch(fetchBlocks());
}
handleLoadMore = debounce(() => {
this.props.dispatch(expandBlocks());
}, 300, { leading: true });
render () {
const { intl, accountIds, hasMore, multiColumn, isLoading } = this.props;
if (!accountIds) {
return (
<Column>
<LoadingIndicator />
</Column>
);
}
const emptyMessage = <FormattedMessage id='empty_column.blocks' defaultMessage="You haven't blocked any users yet." />;
return (
<Column bindToDocument={!multiColumn} icon='ban' heading={intl.formatMessage(messages.heading)}>
<ColumnBackButtonSlim />
<ScrollableList
scrollKey='blocks'
onLoadMore={this.handleLoadMore}
hasMore={hasMore}
isLoading={isLoading}
emptyMessage={emptyMessage}
bindToDocument={!multiColumn}
>
{accountIds.map(id =>
<AccountContainer key={id} id={id} />,
)}
</ScrollableList>
</Column>
);
}
}
|
spec/javascripts/jsx/gradebook/default_gradebook/GradebookGrid/editors/AssignmentGradeInput/CompleteIncompleteGradeInputSpec.js | djbender/canvas-lms | /*
* Copyright (C) 2018 - present Instructure, Inc.
*
* This file is part of Canvas.
*
* Canvas is free software: you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License as published by the Free
* Software Foundation, version 3 of the License.
*
* Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import React from 'react'
import {mount} from 'enzyme'
import AssignmentGradeInput from 'jsx/gradebook/default_gradebook/GradebookGrid/editors/AssignmentGradeInput'
QUnit.module('GradebookGrid CompleteIncompleteGradeInput', suiteHooks => {
let $container
let props
let $menuContent
let resolveClose
let wrapper
suiteHooks.beforeEach(() => {
const assignment = {
pointsPossible: 10
}
const submission = {
enteredGrade: null,
enteredScore: null,
excused: false,
id: '2501'
}
props = {
assignment,
enterGradesAs: 'passFail',
menuContentRef(ref) {
$menuContent = ref
},
onMenuDismiss() {
resolveClose()
},
submission
}
$menuContent = null
$container = document.createElement('div')
document.body.appendChild($container)
})
suiteHooks.afterEach(() => {
wrapper.unmount()
$container.remove()
})
function mountComponent() {
wrapper = mount(<AssignmentGradeInput {...props} />, {attachTo: $container})
}
function clickToOpen() {
return new Promise(resolve => {
const waitForMenuReady = () => {
setTimeout(() => {
if ($menuContent) {
resolve()
} else {
waitForMenuReady()
}
})
}
wrapper.find('button').simulate('click')
waitForMenuReady()
})
}
function getRenderedOptions() {
return [...$menuContent.querySelectorAll('[role="menuitem"]')]
}
function clickMenuItem(optionText) {
return new Promise(resolve => {
resolveClose = resolve
getRenderedOptions()
.find($option => $option.textContent === optionText)
.click()
})
}
function openAndClick(optionText) {
return clickToOpen().then(() => clickMenuItem(optionText))
}
function getTextValue() {
const text = wrapper.find('.Grid__GradeCell__CompleteIncompleteValue').at(0)
return text.getDOMNode().textContent
}
test('adds the CompleteIncompleteInput-suffix class to the container', () => {
mountComponent()
const classList = wrapper.getDOMNode().classList
strictEqual(classList.contains('Grid__GradeCell__CompleteIncompleteInput'), true)
})
test('renders a text container', () => {
mountComponent()
const container = wrapper.find('.Grid__GradeCell__CompleteIncompleteValue')
strictEqual(container.length, 1)
})
test('optionally disables the menu button', () => {
props.disabled = true
mountComponent()
const button = wrapper
.find('button')
.at(0)
.getDOMNode()
strictEqual(button.disabled, true)
})
test('sets the value to "Complete" when the grade is "complete"', () => {
props.submission = {...props.submission, enteredScore: 10, enteredGrade: 'complete'}
mountComponent()
equal(getTextValue(), 'Complete')
})
test('sets the value to "Incomplete" when the grade is "incomplete"', () => {
props.submission = {...props.submission, enteredScore: 0, enteredGrade: 'incomplete'}
mountComponent()
equal(getTextValue(), 'Incomplete')
})
test('sets the value to "–" when the grade is null', () => {
props.submission = {...props.submission, enteredScore: null, enteredGrade: null}
mountComponent()
equal(getTextValue(), '–')
})
test('sets the value to "Excused" when the submission is excused', () => {
props.submission = {
...props.submission,
enteredScore: null,
enteredGrade: null,
excused: true
}
mountComponent()
equal(getTextValue(), 'Excused')
})
test('sets the value to the pending grade when present', () => {
props.pendingGradeInfo = {excused: false, grade: 'complete', valid: true}
mountComponent()
equal(getTextValue(), 'Complete')
})
QUnit.module('#gradeInfo', () => {
function getGradeInfo() {
return wrapper.instance().gradeInfo
}
QUnit.module('when the submission is ungraded', hooks => {
hooks.beforeEach(() => {
mountComponent()
})
test('sets grade to null', () => {
strictEqual(getGradeInfo().grade, null)
})
test('sets score to null', () => {
strictEqual(getGradeInfo().score, null)
})
test('sets enteredAs to null', () => {
strictEqual(getGradeInfo().enteredAs, null)
})
test('sets excused to false', () => {
strictEqual(getGradeInfo().excused, false)
})
})
QUnit.module('when the submission is graded', hooks => {
hooks.beforeEach(() => {
props.submission = {...props.submission, enteredGrade: 'complete', enteredScore: 10}
mountComponent()
})
test('sets grade to the letter grade form of the entered grade', () => {
equal(getGradeInfo().grade, 'complete')
})
test('sets score to the score form of the entered grade', () => {
strictEqual(getGradeInfo().score, 10)
})
test('sets enteredAs to "passFail"', () => {
equal(getGradeInfo().enteredAs, 'passFail')
})
test('sets excused to false', () => {
strictEqual(getGradeInfo().excused, false)
})
})
QUnit.module('when the submission is excused', hooks => {
hooks.beforeEach(() => {
props.submission = {...props.submission, excused: true}
mountComponent()
})
test('sets grade to null', () => {
strictEqual(getGradeInfo().grade, null)
})
test('sets score to null', () => {
strictEqual(getGradeInfo().score, null)
})
test('sets enteredAs to "excused"', () => {
equal(getGradeInfo().enteredAs, 'excused')
})
test('sets excused to true', () => {
strictEqual(getGradeInfo().excused, true)
})
})
QUnit.module('when the submission has a pending grade', hooks => {
hooks.beforeEach(() => {
props.pendingGradeInfo = {
enteredAs: 'passFail',
excused: false,
grade: 'incomplete',
score: 0,
valid: true
}
mountComponent()
})
test('sets grade to the grade of the pending grade', () => {
equal(getGradeInfo().grade, 'incomplete')
})
test('sets score to the score of the pending grade', () => {
strictEqual(getGradeInfo().score, 0)
})
test('sets enteredAs to the value of the pending grade', () => {
equal(getGradeInfo().enteredAs, 'passFail')
})
test('sets excused to false', () => {
strictEqual(getGradeInfo().excused, false)
})
})
QUnit.module('when an option in the menu is clicked', hooks => {
hooks.beforeEach(() => {
mountComponent()
})
test('sets enteredAs to "passFail"', () =>
openAndClick('Complete').then(() => {
equal(getGradeInfo().enteredAs, 'passFail')
}))
test('sets grade to "complete" when "Complete" is clicked', () =>
openAndClick('Complete').then(() => {
equal(getGradeInfo().grade, 'complete')
}))
test('sets score to points possible when "Complete" is clicked', () =>
openAndClick('Complete').then(() => {
equal(getGradeInfo().score, 10)
}))
test('sets excused to false when "Complete" is clicked', () =>
openAndClick('Complete').then(() => {
equal(getGradeInfo().excused, false)
}))
test('sets grade to "incomplete" when "Incomplete" is clicked', () =>
openAndClick('Incomplete').then(() => {
equal(getGradeInfo().grade, 'incomplete')
}))
test('sets score to 0 when "Incomplete" is clicked', () =>
openAndClick('Incomplete').then(() => {
equal(getGradeInfo().score, 0)
}))
test('sets excused to false when "Incomplete" is clicked', () =>
openAndClick('Incomplete').then(() => {
equal(getGradeInfo().excused, false)
}))
test('sets grade to null when "Ungraded" is clicked', () =>
openAndClick('Ungraded').then(() => {
equal(getGradeInfo().grade, null)
}))
test('sets score to null when "Ungraded" is clicked', () =>
openAndClick('Ungraded').then(() => {
equal(getGradeInfo().score, null)
}))
test('sets excused to false when "Ungraded" is clicked', () =>
openAndClick('Ungraded').then(() => {
equal(getGradeInfo().excused, false)
}))
test('sets grade to null when "Excused" is clicked', () =>
openAndClick('Excused').then(() => {
equal(getGradeInfo().grade, null)
}))
test('sets score to null when "Excused" is clicked', () =>
openAndClick('Excused').then(() => {
equal(getGradeInfo().score, null)
}))
test('sets excused to true when "Excused" is clicked', () =>
openAndClick('Excused').then(() => {
equal(getGradeInfo().excused, true)
}))
})
})
QUnit.module('#focus()', () => {
test('sets focus on the button', () => {
mountComponent()
wrapper.instance().focus()
strictEqual(
document.activeElement,
wrapper
.find('button')
.at(0)
.getDOMNode()
)
})
})
QUnit.module('#handleKeyDown()', () => {
const ENTER = {shiftKey: false, which: 13}
test('returns false when pressing enter on the menu button', () => {
mountComponent()
const handleKeyDown = action => wrapper.instance().handleKeyDown({...action})
// return false to allow the popover menu to open
wrapper
.find('button')
.at(0)
.getDOMNode()
.focus()
strictEqual(handleKeyDown(ENTER), false)
})
})
QUnit.module('#hasGradeChanged()', () => {
function hasGradeChanged() {
return wrapper.instance().hasGradeChanged()
}
test('returns false when a null grade is unchanged', () => {
mountComponent()
strictEqual(hasGradeChanged(), false)
})
test('returns true when a different grade is clicked', () => {
props.submission = {...props.submission, enteredGrade: 'complete', enteredScore: 10}
mountComponent()
return openAndClick('Incomplete').then(() => {
strictEqual(hasGradeChanged(), true)
})
})
test('returns true when the submission becomes excused', () => {
props.submission = {...props.submission, enteredGrade: 'complete', enteredScore: 10}
mountComponent()
return openAndClick('Excused').then(() => {
strictEqual(hasGradeChanged(), true)
})
})
test('returns false when the same grade is clicked', () => {
props.submission = {...props.submission, enteredGrade: 'complete', enteredScore: 10}
mountComponent()
return openAndClick('Complete').then(() => {
strictEqual(hasGradeChanged(), false)
})
})
})
QUnit.module('Complete/Incomplete Menu Items', () => {
test('includes "Complete", "Incomplete", "Ungraded", and "Excused"', () => {
const expectedLabels = ['Complete', 'Incomplete', 'Ungraded', 'Excused']
mountComponent()
return clickToOpen().then(() => {
const optionsText = getRenderedOptions().map($option => $option.textContent)
deepEqual(optionsText, expectedLabels)
})
})
test('sets the value to the selected option when clicked', () => {
mountComponent()
return openAndClick('Incomplete').then(() => {
equal(getTextValue(), 'Incomplete')
})
})
test('set the value to "Excused" when clicked', () => {
mountComponent()
return openAndClick('Excused').then(() => {
equal(getTextValue(), 'Excused')
})
})
})
})
|
src/renderer/components/MapFilter/ObservationDialog/DateField.js | digidem/ecuador-map-editor | // @flow
import React from 'react'
import { DatePicker } from '@material-ui/pickers'
import { getDateString } from '../utils/helpers'
type Props = {
value: Date | void,
onChange: (string | void) => any,
placeholder?: string
}
const DateField = ({ value, onChange, placeholder, ...otherProps }: Props) => {
return (
<DatePicker
fullWidth
variant='inline'
inputVariant='outlined'
margin='normal'
format='dd/MM/yyyy'
autoOk
value={
// DatePicker shows the current date if value is undefined. To show it
// as empty, value needs to be null
value === undefined ? null : value
}
placeholder={placeholder}
onChange={date => onChange(getDateString(date))}
{...otherProps}
InputLabelProps={{
shrink: true
}}
/>
)
}
export default DateField
|
docs/js/index.js | osartun/react-carousel-scroller | import React from 'react';
import ReactDOM from 'react-dom';
import Showcase from './showcase';
ReactDOM.render(
<Showcase />,
document.getElementById('showcase-container')
)
|
src/svg-icons/image/looks-4.js | verdan/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let ImageLooks4 = (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 14h-2v-4H9V7h2v4h2V7h2v10z"/>
</SvgIcon>
);
ImageLooks4 = pure(ImageLooks4);
ImageLooks4.displayName = 'ImageLooks4';
ImageLooks4.muiName = 'SvgIcon';
export default ImageLooks4;
|
src/components/common/icons/Question.js | chejen/GoodJobShare | import React from 'react';
/* eslint-disable max-len */
const Question = props => (
<svg {...props} width="148" height="148">
<g fillRule="evenodd">
<path d="M41 0C18.392 0 0 18.392 0 41s18.392 41 41 41 41-18.392 41-41S63.608 0 41 0zm0 76.875C21.219 76.875 5.125 60.781 5.125 41S21.219 5.125 41 5.125 76.875 21.219 76.875 41 60.781 76.875 41 76.875z" />
<path d="M41.693 13.369c-10.122 0-18.355 8.233-18.355 18.352a2.563 2.563 0 0 0 5.125 0c0-7.293 5.936-13.227 13.23-13.227 7.292 0 13.225 5.934 13.225 13.227S48.985 44.95 41.693 44.95a2.563 2.563 0 0 0-2.562 2.562v9.906a2.563 2.563 0 0 0 5.125 0v-7.523c8.908-1.25 15.787-8.923 15.787-18.174 0-10.12-8.232-18.351-18.35-18.351z" />
<ellipse cx="41.691" cy="67.143" rx="2.805" ry="2.805" />
</g>
</svg>
);
export default Question;
|
src/containers/Home/Home.js | DelvarWorld/some-game | import React, { Component } from 'react';
import { Link } from 'react-router';
import config from '../../config';
import Helmet from 'react-helmet';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import { submitSplashEmail, } from 'redux/modules/users';
import gameStyles from '../Game/Game.scss';
import styles from './Home.scss';
import classNames from 'classnames/bind';
const cx = classNames.bind( styles );
@connect(
state => ({
loading: state.splashSubmit.loading,
success: state.splashSubmit.success,
failure: state.splashSubmit.failure,
}),
dispatch => bindActionCreators({ submitSplashEmail }, dispatch )
)
export default class Home extends Component {
constructor( props, context ) {
super( props, context );
this.state = {};
this.onSubmit = this.onSubmit.bind( this );
this.onChangeEmail = this.onChangeEmail.bind( this );
}
onChangeEmail( event ) {
this.setState({ email: event.target.value });
}
onSubmit( event ) {
event.preventDefault();
this.props.submitSplashEmail( this.state.email );
}
render() {
const { loading, failure, success, } = this.props;
return <div className={ styles.colWrap }>
<Helmet title="Charisma The Chameleon" />
<div className={ styles.col }>
<div className={ gameStyles.viewportContainer }>
<div className={ gameStyles.viewPort }>
<img
title="Charisma The (Space) Chameleon Logo"
alt="Charisma The (Space) Chameleon Logo"
src={ require( '../../../assets/images/splash-logo.jpg' ) }
className={ styles.imgAuto }
/>
</div>
<h2>
<center>Gameplay Video</center>
</h2>
<div
className={ styles.splashImage }
>
<img
src={ require( '../../../assets/images/charismas-world.gif' ) }
alt="Charisma The Chameleon Gameplay Video"
title="Charisma The Chameleon Gameplay Video"
className={ styles.imgAuto }
/>
</div>
</div>
</div><div className={ styles.col }>
<div className={ styles.colContentWrap }>
<div
className={ styles.cols }
>
<div className={ styles.coll }>
<i className={ cx({ fa: true, 'fa-facebook': true, icon: true }) } />
<a href="https://www.facebook.com/charismachameleon" target="_blank">
<u>Like Charisma</u>
</a> on Facebook!
</div><div className={ styles.coll }>
Follow{' '}
<i className={ cx({ fa: true, 'fa-twitter': true, icon: true, tweet: true }) } />
<a href="https://twitter.com/andrewray" target="_blank">
@<u>andrewray</u>
</a> for updates!
</div>
</div>
{ !success ? <form
onSubmit={ this.onSubmit }
className={ styles.form }
>
<h2>
Be the first to know!
</h2>
<p>
Sign up to receive a <b>one-time only email when the game is ready to play!</b>
</p>
<input
disabled={ loading }
type="email"
placeholder="Your email address"
onChange={ this.onChangeEmail }
value={ this.state.email }
/>
<input
disabled={ loading }
type="submit"
value="submit"
/>
{ !success && failure ? <div className={ styles.failure }>
{ failure}
</div> : null }
<p style={{ fontStyle: 'italic', fontSize: '12px', opacity: 0.6 }}>
After the announcement email is sent you won't be emailed again. Your email won't be shared with any third parties, ever.
</p>
</form> : null }
{ success ? <div
className={ styles.success }
>
<i className={ cx({ fa: true, 'fa-heart': true, red: true }) } />
YOU DID IT!
</div> : null }
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<p
>
"Charisma The Chameleon" is a browser game where Charisma shrinks infinitely to solve smaller and smaller mazes. Inspired by the quality of Nintendo 64 games, I aim to achieve a well crafted, complete browser game experience.
</p>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<p>
created by <a href="https://twitter.com/andrewray" target="_blank" className={ styles.not }>Andrew Ray</a>
<br />
shaders by <a href="http://shaderfrog.com/app" target="_blank" className={ styles.not }>ShaderFrog</a>
</p>
</div>
</div>
</div>;
}
}
|
src/examples/Form/LanguageForm.js | steos/elmar.js | import React from 'react'
const languages = ['Clojure', 'Haskell', 'Elm', 'PureScript', 'Pixie', 'Agda', 'Idris']
export const init = (langs = []) => langs
export const update = (action, model) => action(model)
const Toggle = lang => model => model.indexOf(lang) === -1
? model.concat(lang)
: model.filter(elem => elem !== lang)
export const isValid = model => model.length > 0
const viewLang = (signal, model) => (lang, index) => (
<div key={index}>
<input type="checkbox"
checked={model.indexOf(lang) !== -1}
onChange={signal(Toggle(lang))}/>
<label>{lang}</label>
</div>
)
const viewError = model =>
!isValid(model)
? <p style={{color:'red'}}>Choose at least one.</p>
: null
export const view = (signal, model) => (
<div>
{languages.map(viewLang(signal, model))}
{viewError(model)}
</div>
)
export default {init, update, view, isValid}
|
example/src/index.js | salmanm/react-keydown | import React from 'react';
import ReactDOM from 'react-dom';
import App from './app';
ReactDOM.render( <App />, document.getElementById( 'example' ) );
|
serverRender.js | jsize8/learn-fullstack-javascript | import React from 'react';
import ReactDOMServer from 'react-dom/server';
import App from './src/components/App';
import config from './config';
import axios from 'axios';
const getApiUrl = contestId => {
if (contestId) {
return `${config.serverUrl}/api/contests/${contestId}`;
}
return `${config.serverUrl}/api/contests`;
};
const getInitialData = (contestId, apiData) => {
if (contestId) {
return {
currentContestId: apiData.id,
contests: {
[apiData.id]: apiData
}
};
}
return {
contests: apiData.contests
};
};
const serverRender = (contestId) =>
axios.get(getApiUrl(contestId))
.then(resp => {
const initialData = getInitialData(contestId, resp.data);
return {
initialMarkup: ReactDOMServer.renderToString(
<App initialData={initialData} />
),
initialData
};
});
export default serverRender;
|
app/components/candidate/CandidateApp.js | wp-wilsonperez/votos | import React from 'react';
import CandidateTable from './CandidateTable';
class CandidateApp extends React.Component {
constructor(props) {
super(props);
this.state = {candidates: [], candidateState: false, share: false};
}
componentWillMount() {
if(!this.state.candidateState) {
$.get('/candidates', (candidates) => {
console.log(candidates);
this.setState({candidates: candidates, candidateState: true});
});
}
}
render() {
console.log(this.state.candidates);
if(this.state.candidates.length) {
return <div className="gallery row">
<CandidateTable candidates={this.state.candidates}/>
</div>
} else {
return <p> Cargando... </p>
}
}
}
export default CandidateApp
|
node_modules/browser-sync/node_modules/bs-recipes/recipes/webpack.react-hot-loader/app/js/main.js | jefdewitt/jekyll_portfolio | import React from 'react';
import { render } from 'react-dom';
// It's important to not define HelloWorld component right in this file
// because in that case it will do full page reload on change
import HelloWorld from './HelloWorld.jsx';
render(<HelloWorld />, document.getElementById('react-root'));
|
src/PhotoLayoutEditor/Container/Side/Navigation/index.js | RedgooseDev/react-photo-layout-editor | import React from 'react';
class SideNavigation extends React.Component {
constructor(props) {
super(props);
this.comps = {
inputFile: null,
};
this.state = {
timestamp : Date.now(),
};
}
/**
* Upload images
*
* @param {Event} e
*/
upload(e) {
this.props.onUpload(e.target.files);
this.setState({
timestamp : Date.now()
});
}
render() {
const { props, state, comps } = this;
return (
<nav className="ple-sideNavigation ple-side__navigation">
<div className="ple-sideNavigation__wrap">
<button type="button" title="attach images" onClick={props.onAttach}>
<i className="ple-sp-ico ple-ico-reply ple-abs">Moving the image to grid block</i>
</button>
<button type="button" title="toggle select" onClick={props.onToggleSelect}>
<i className="ple-sp-ico ple-ico-select ple-abs">Toggle all select</i>
</button>
<span title="upload images" key={state.timestamp}>
<input
ref={(r) => { comps.inputFile = r; }}
type="file"
onChange={(e) => this.upload(e)} multiple />
<i className="ple-sp-ico ple-ico-upload ple-abs">upload images</i>
</span>
<button type="button" title="remove images" onClick={props.onRemove}>
<i className="ple-sp-ico ple-ico-trash ple-abs">remove images</i>
</button>
</div>
</nav>
);
}
}
SideNavigation.displayName = 'Navigation';
SideNavigation.defaultProps = {
onRemove: function() {},
onToggleSelect: function() {},
onAttach: function() {},
onUpload: function() {},
};
export default SideNavigation; |
src/client/components/FacebookLoginWidget/FacebookLoginWidget.js | vidaaudrey/trippian | import log from '../../log'
import React from 'react'
const FacebookLoginWidget = ({
name = 'FacebookLoginWidget'
}) => {
return (
<div>
<h3>Widget</h3>
{name}
</div>
)
}
FacebookLoginWidget.displayName = 'FacebookLoginWidget'
export default FacebookLoginWidget
// import log from '../../log'
// import React from 'react'
// import FacebookLogin from '../helpers/FacebookLogin'
// import CircleImageLinkWidget from './CircleImageLinkWidget'
// import config from '../config/config.js'
// function renderLoggedoutHTML(callback) {
// return <FacebookLogin
// appId={config.FB_APP_ID}
// autoLoad={true}
// size="small"
// textButton='FB Login'
// callback={callback} />
// }
// function renderLoggedInHTML(userId, avatar) {
// return <CircleImageLinkWidget
// link={`${config.FB_BASE}${userId}`}
// src={avatar}
// alt="facebook avatar" />
// }
// export default ({
// callback, isLoggedIn = false, userId = null, avatar = config.FB_DEFAULT_AVARTAR_URL
// }) => {
// return isLoggedIn ? renderLoggedInHTML(userId, avatar) : renderLoggedoutHTML(callback)
// }
|
src/routes/error/ErrorPage.js | binyuace/vote | /**
* React Starter Kit (https://www.reactstarterkit.com/)
*
* Copyright © 2014-present Kriasoft, LLC. All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE.txt file in the root directory of this source tree.
*/
import React from 'react';
import PropTypes from 'prop-types';
import withStyles from 'isomorphic-style-loader/lib/withStyles';
import s from './ErrorPage.css';
class ErrorPage extends React.Component {
static propTypes = {
error: PropTypes.shape({
name: PropTypes.string.isRequired,
message: PropTypes.string.isRequired,
stack: PropTypes.string.isRequired,
}),
};
static defaultProps = {
error: null,
};
render() {
if (__DEV__ && this.props.error) {
return (
<div>
<h1>
{this.props.error.name}
</h1>
<pre>
{this.props.error.stack}
</pre>
</div>
);
}
return (
<div>
<h1>Error</h1>
<p>Sorry, a critical error occurred on this page.</p>
</div>
);
}
}
export { ErrorPage as ErrorPageWithoutStyle };
export default withStyles(s)(ErrorPage);
|
src/frontend/components/AdminDashboard.js | al3x/ground-control | import React from 'react';
import Relay from 'react-relay';
import {Styles} from 'material-ui';
import TopNav from './TopNav';
import {BernieTheme} from './styles/bernie-theme';
import {BernieColors} from './styles/bernie-css';
@Styles.ThemeDecorator(Styles.ThemeManager.getMuiTheme(BernieTheme))
class AdminDashboard extends React.Component {
tabs = [
{
value: '/admin/call-assignments',
label: 'Call Assignments'
},
{
value: '/admin/events',
label: 'Events'
}
];
render() {
return (
<div>
<TopNav
barColor={BernieColors.blue}
tabColor={BernieColors.lightBlue}
selectedTabColor={Styles.Colors.white}
title="Ground Control Admin"
logoColors={{
primary: Styles.Colors.white,
swoosh: BernieColors.gray
}}
tabs={this.tabs}
history={this.props.history}
location={this.props.location}
/>
{this.props.children}
</div>
)
}
}
// We only do this to auth protect this component. Otherwise it is unnecessary.
export default Relay.createContainer(AdminDashboard, {
fragments: {
listContainer: () => Relay.QL`
fragment on ListContainer {
id
}
`
}
}) |
githubApp/js/pages/my/CustomKeyPage.js | anchoretics/ztf-work-app | /**
* Created by lingfengliang on 2017/3/17.
*/
import React, { Component } from 'react';
import {
StyleSheet,
TextInput,
View,
ScrollView,
Image,
TouchableOpacity,
ListView,
RefreshControl
} from 'react-native';
import NavigationBar from '../../Components/NavigationBar';
import { ListItem, Left, Body, Right, Switch, Radio, Text, Icon, Badge, CheckBox } from 'native-base'
import LanguageDao, {FLAG_LANGUAGE} from '../../expand/dao/LanguageDao'
import ViewUtils from '../../ViewUtils';
import _ from 'lodash'
export default class CustomKeyPage extends Component{
constructor(props){
super(props);
this.originArray = [];
this.isRemoveKey=this.props.isRemoveKey?true:false;
this.state = {
data: []
}
}
componentDidMount(){
this.languageDao = new LanguageDao(this.props.flag);
this.languageDao.fetch().then((data)=> {
this.originArray = _.cloneDeep(data);
if(this.isRemoveKey){
for(let i=0;i<data.length;i++){
data[i].checked = false;
}
}
this.setState({
data: data
})
}).catch((error)=> {
console.log(error);
});
}
_save(){
let _saveArray = this.state.data;
if(this.isRemoveKey){
let _removedArray = _.remove(_saveArray, n => {
return n.checked;
});
for(let i=0;i<_removedArray.length;i++){
this.originArray.splice(_.findIndex(this.originArray,{name: _removedArray[i].name}),1);
}
_saveArray = this.originArray;
}
this.languageDao.save(_saveArray);
}
_renderScrollViews(){
if(this.state.data && this.state.data.length>0){
var views = [];
for(var i=0;i<this.state.data.length;i++){
let index = 0+i;
let _onPress = function(id){
this.state.data[id].checked = !this.state.data[id].checked;
this.forceUpdate();
};
let view = <View key={i}>
<ListItem key={index} onPress={_onPress.bind(this,index)}>
<CheckBox checked={this.state.data[index].checked} onPress={_onPress.bind(this,index)} />
<Body>
<Text>{this.state.data[index].name}</Text>
</Body>
</ListItem>
</View>;
views.push(view);
}
return views;
}else{
return null;
}
}
render(){
let title = this.isRemoveKey?'标签移除':'自定义标签';
let rightButtonTitle = this.isRemoveKey?'移除':'保存';
return (
<View style={styles.container}>
<NavigationBar
title={title}
statusBar={{ backgroundColor: '#B8F4FF',}}
style={{backgroundColor: '#B8F4FF'}}
leftButton={ViewUtils.getLeftButton(()=>{this._save();this.props.navigator.pop();})}
rightButton={ViewUtils.getRightButton(rightButtonTitle, ()=>{this._save();this.props.navigator.pop();})}
/>
<View style={styles.container}>
<ScrollView>
{/*{this.state.views}*/}
{this._renderScrollViews()}
</ScrollView>
</View>
</View>
)
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#f8f8f8',
}
}) |
node_modules/react-bootstrap/es/SafeAnchor.js | firdiansyah/crud-req | import _extends from 'babel-runtime/helpers/extends';
import _objectWithoutProperties from 'babel-runtime/helpers/objectWithoutProperties';
import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn';
import _inherits from 'babel-runtime/helpers/inherits';
import React from 'react';
import PropTypes from 'prop-types';
import elementType from 'react-prop-types/lib/elementType';
var propTypes = {
href: PropTypes.string,
onClick: PropTypes.func,
disabled: PropTypes.bool,
role: PropTypes.string,
tabIndex: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
/**
* this is sort of silly but needed for Button
*/
componentClass: elementType
};
var defaultProps = {
componentClass: 'a'
};
function isTrivialHref(href) {
return !href || href.trim() === '#';
}
/**
* There are situations due to browser quirks or Bootstrap CSS where
* an anchor tag is needed, when semantically a button tag is the
* better choice. SafeAnchor ensures that when an anchor is used like a
* button its accessible. It also emulates input `disabled` behavior for
* links, which is usually desirable for Buttons, NavItems, MenuItems, etc.
*/
var SafeAnchor = function (_React$Component) {
_inherits(SafeAnchor, _React$Component);
function SafeAnchor(props, context) {
_classCallCheck(this, SafeAnchor);
var _this = _possibleConstructorReturn(this, _React$Component.call(this, props, context));
_this.handleClick = _this.handleClick.bind(_this);
return _this;
}
SafeAnchor.prototype.handleClick = function handleClick(event) {
var _props = this.props,
disabled = _props.disabled,
href = _props.href,
onClick = _props.onClick;
if (disabled || isTrivialHref(href)) {
event.preventDefault();
}
if (disabled) {
event.stopPropagation();
return;
}
if (onClick) {
onClick(event);
}
};
SafeAnchor.prototype.render = function render() {
var _props2 = this.props,
Component = _props2.componentClass,
disabled = _props2.disabled,
props = _objectWithoutProperties(_props2, ['componentClass', 'disabled']);
if (isTrivialHref(props.href)) {
props.role = props.role || 'button';
// we want to make sure there is a href attribute on the node
// otherwise, the cursor incorrectly styled (except with role='button')
props.href = props.href || '#';
}
if (disabled) {
props.tabIndex = -1;
props.style = _extends({ pointerEvents: 'none' }, props.style);
}
return React.createElement(Component, _extends({}, props, {
onClick: this.handleClick
}));
};
return SafeAnchor;
}(React.Component);
SafeAnchor.propTypes = propTypes;
SafeAnchor.defaultProps = defaultProps;
export default SafeAnchor; |
node_modules/browser-sync/node_modules/bs-recipes/recipes/webpack.react-hot-loader/app/js/main.js | glancyea/wastepermitcontent | import React from 'react';
// It's important to not define HelloWorld component right in this file
// because in that case it will do full page reload on change
import HelloWorld from './HelloWorld.jsx';
React.render(<HelloWorld />, document.getElementById('react-root'));
|
examples/App.js | djesmond/agileField | import React, { Component } from 'react';
import './App.css';
import { AgileTextField, PasswordField, NumberField, Checkbox } from '../src/index';
function customValidator(input) {
if (input.length > 6) {
return {
isValid: false,
message: 'Must be less than 6 characters',
state: 'invalid',
};
} else if (input.length > 0 && input.length < 6) {
return {
isValid: true,
message: '',
state: 'valid',
};
} else {
return {
isValid: false,
message: 'That\'s too boring!',
state: 'invalid',
};
}
}
const customStyle = {
fieldHintText: {
color: '#00bf13',
},
fieldInput: {
base: {
color: '#df01c9',
},
},
};
const CustomFeedbackStyle = {
fieldFeedback: {
base: {
margin: '4px 0px 4px 0px',
fontSize: '12px',
color: '#7a7a7a',
},
valid: {
color: '#009c19',
},
invalid: {
color: '#c70000',
},
},
};
function CustomFeedbackElement(state) {
return (
<p style={[CustomFeedbackStyle.fieldFeedback.base, CustomFeedbackStyle.fieldFeedback[state.state]]} >
Message is: {state.message}
</p>
);
}
class App extends Component {
constructor(props) {
super(props);
this.state = { value: '' };
this.handleValueChange = this.handleValueChange.bind(this);
}
handleValueChange(state) {
this.setState({ value: state.value });
}
render() {
return (
<div className="App">
<h1>Agile Fields</h1>
<div className="text">
<h2>Text</h2>
<p>A simple input with a label and hintText</p>
<AgileTextField
label="Name"
hintText="Enter your full name"
/>
<p>Without hint text</p>
<AgileTextField
label="Name"
/>
<p>Marked as optional</p>
<AgileTextField
label="Location"
optional
/>
<p>One with validation</p>
<AgileTextField
label="Name"
hintText="Enter your full name"
validateInput
/>
<p>One with custom validation</p>
<AgileTextField
label="Text"
hintText="Explain your life with less than 6 characters"
validateInput
validator={customValidator}
/>
<p>One with validation and value return when value changes</p>
<p>Value of input is: {this.state.value}</p>
<AgileTextField
label="Name"
hintText="Enter your full name"
validateInput
onValueChange={this.handleValueChange}
/>
<p>One with custom style</p>
<AgileTextField
label="Developer doing design"
hintText="Please don't tell the designers"
style={customStyle}
/>
<p>One with custom feedback element</p>
<AgileTextField
label="Just a label"
hintText="Hello"
validateInput
feedbackElement={CustomFeedbackElement}
/>
<p>Disabled</p>
<AgileTextField
label="Add to account"
hintText="How much money do you want?"
disabled
/>
<p>One with custom initial state</p>
<AgileTextField
label="Election"
hintText="Enter the name of the president"
initialState={{
state: 'invalid',
value: 'Hillary Clinton',
isValid: false,
message: 'Sorry, the orange won...',
}}
/>
</div>
<div className="password">
<h2>Password</h2>
<p>Password creation with strength indicator</p>
<PasswordField
label="Password"
hintText="Create a password"
/>
</div>
<div className="number">
<h2>Number</h2>
<p>Simple number input</p>
<NumberField
label="Number"
/>
<p>One with min and max value</p>
<NumberField
label="Range"
hintText="Must be between 0 and 10"
minValue={0}
maxValue={10}
/>
</div>
<div className="checkbox">
<h2>Checkbox</h2>
<p>Simple checkbox</p>
<Checkbox />
</div>
</div>
);
}
}
export default App;
|
src/svg-icons/action/euro-symbol.js | rscnt/material-ui | import React from 'react';
import pure from 'recompose/pure';
import SvgIcon from '../../SvgIcon';
let ActionEuroSymbol = (props) => (
<SvgIcon {...props}>
<path d="M15 18.5c-2.51 0-4.68-1.42-5.76-3.5H15v-2H8.58c-.05-.33-.08-.66-.08-1s.03-.67.08-1H15V9H9.24C10.32 6.92 12.5 5.5 15 5.5c1.61 0 3.09.59 4.23 1.57L21 5.3C19.41 3.87 17.3 3 15 3c-3.92 0-7.24 2.51-8.48 6H3v2h3.06c-.04.33-.06.66-.06 1 0 .34.02.67.06 1H3v2h3.52c1.24 3.49 4.56 6 8.48 6 2.31 0 4.41-.87 6-2.3l-1.78-1.77c-1.13.98-2.6 1.57-4.22 1.57z"/>
</SvgIcon>
);
ActionEuroSymbol = pure(ActionEuroSymbol);
ActionEuroSymbol.displayName = 'ActionEuroSymbol';
export default ActionEuroSymbol;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.