commit
stringlengths 40
40
| old_file
stringlengths 4
150
| new_file
stringlengths 4
150
| old_contents
stringlengths 0
3.26k
| new_contents
stringlengths 1
4.43k
| subject
stringlengths 15
501
| message
stringlengths 15
4.06k
| lang
stringclasses 4
values | license
stringclasses 13
values | repos
stringlengths 5
91.5k
| diff
stringlengths 0
4.35k
|
---|---|---|---|---|---|---|---|---|---|---|
00bc833223ba155b5bab23e38a5f202cc6de9f5b | src/framework/dropdown/DropdownGroup.spec.jsx | src/framework/dropdown/DropdownGroup.spec.jsx |
import { TestCaseFactory } from 'react-test-kit';
import BaseDropdown from '../base/dropdown/BaseDropdown.jsx';
import DropdownGroup from './DropdownGroup.jsx';
import DropdownDot from './dropdownDot/DropdownDot.jsx';
describe('DropdownGroup', () => {
const requiredProps = {
onSelect: () => undefined,
labelProvider: () => undefined,
optionLabelProvider: () => undefined,
};
describe('DOM structure', () => {
it('is a BaseDropdown', () => {
const props = Object.assign({}, requiredProps);
const testCase = TestCaseFactory.create(DropdownGroup, props);
expect(testCase.findComponents(BaseDropdown)).toBeDefined();
});
});
describe('props', () => {
describe('dotColor', () => {
it('renders a DropdownDot', () => {
const props = Object.assign({}, requiredProps, {
dotColor: 'dotColor',
});
const testCase = TestCaseFactory.create(DropdownGroup, props);
expect(testCase.first('.dropdownDot')).toBeDefined();
});
it('DropdownDot.COLOR.BLUE applies the appropriate class', () => {
const props = Object.assign({}, requiredProps, {
dotColor: DropdownDot.COLOR.BLUE,
});
const testCase = TestCaseFactory.create(DropdownGroup, props);
expect(testCase.first('.dropdownLabel--blue')).toBeDefined();
});
it('DropdownDot.COLOR.GREEN applies the appropriate class', () => {
const props = Object.assign({}, requiredProps, {
dotColor: DropdownDot.COLOR.GREEN,
});
const testCase = TestCaseFactory.create(DropdownGroup, props);
expect(testCase.first('.dropdownLabel--green')).toBeDefined();
});
it('DropdownDot.COLOR.GREY applies the appropriate class', () => {
const props = Object.assign({}, requiredProps, {
dotColor: DropdownDot.COLOR.GREY,
});
const testCase = TestCaseFactory.create(DropdownGroup, props);
expect(testCase.first('.dropdownLabel--grey')).toBeDefined();
});
it('DropdownDot.COLOR.RED applies the appropriate class', () => {
const props = Object.assign({}, requiredProps, {
dotColor: DropdownDot.COLOR.RED,
});
const testCase = TestCaseFactory.create(DropdownGroup, props);
expect(testCase.first('.dropdownLabel--red')).toBeDefined();
});
});
describe('isBorderless', () => {
it('applies the appropriate class', () => {
const props = Object.assign({}, requiredProps, {
isBorderless: true,
});
const testCase = TestCaseFactory.create(DropdownGroup, props);
expect(
testCase.first('.dropdownLabel').className
).toContain('dropdownLabel--borderless');
});
});
});
});
| Create Action dropdown: - tests for dropdowngroup | [SDX-1419] Create Action dropdown:
- tests for dropdowngroup
| JSX | mit | smaato/ui-framework | ---
+++
@@ -0,0 +1,78 @@
+
+import { TestCaseFactory } from 'react-test-kit';
+
+import BaseDropdown from '../base/dropdown/BaseDropdown.jsx';
+import DropdownGroup from './DropdownGroup.jsx';
+import DropdownDot from './dropdownDot/DropdownDot.jsx';
+
+describe('DropdownGroup', () => {
+ const requiredProps = {
+ onSelect: () => undefined,
+ labelProvider: () => undefined,
+ optionLabelProvider: () => undefined,
+ };
+
+ describe('DOM structure', () => {
+ it('is a BaseDropdown', () => {
+ const props = Object.assign({}, requiredProps);
+ const testCase = TestCaseFactory.create(DropdownGroup, props);
+ expect(testCase.findComponents(BaseDropdown)).toBeDefined();
+ });
+ });
+
+ describe('props', () => {
+ describe('dotColor', () => {
+ it('renders a DropdownDot', () => {
+ const props = Object.assign({}, requiredProps, {
+ dotColor: 'dotColor',
+ });
+ const testCase = TestCaseFactory.create(DropdownGroup, props);
+ expect(testCase.first('.dropdownDot')).toBeDefined();
+ });
+
+ it('DropdownDot.COLOR.BLUE applies the appropriate class', () => {
+ const props = Object.assign({}, requiredProps, {
+ dotColor: DropdownDot.COLOR.BLUE,
+ });
+ const testCase = TestCaseFactory.create(DropdownGroup, props);
+ expect(testCase.first('.dropdownLabel--blue')).toBeDefined();
+ });
+
+ it('DropdownDot.COLOR.GREEN applies the appropriate class', () => {
+ const props = Object.assign({}, requiredProps, {
+ dotColor: DropdownDot.COLOR.GREEN,
+ });
+ const testCase = TestCaseFactory.create(DropdownGroup, props);
+ expect(testCase.first('.dropdownLabel--green')).toBeDefined();
+ });
+
+ it('DropdownDot.COLOR.GREY applies the appropriate class', () => {
+ const props = Object.assign({}, requiredProps, {
+ dotColor: DropdownDot.COLOR.GREY,
+ });
+ const testCase = TestCaseFactory.create(DropdownGroup, props);
+ expect(testCase.first('.dropdownLabel--grey')).toBeDefined();
+ });
+
+ it('DropdownDot.COLOR.RED applies the appropriate class', () => {
+ const props = Object.assign({}, requiredProps, {
+ dotColor: DropdownDot.COLOR.RED,
+ });
+ const testCase = TestCaseFactory.create(DropdownGroup, props);
+ expect(testCase.first('.dropdownLabel--red')).toBeDefined();
+ });
+ });
+
+ describe('isBorderless', () => {
+ it('applies the appropriate class', () => {
+ const props = Object.assign({}, requiredProps, {
+ isBorderless: true,
+ });
+ const testCase = TestCaseFactory.create(DropdownGroup, props);
+ expect(
+ testCase.first('.dropdownLabel').className
+ ).toContain('dropdownLabel--borderless');
+ });
+ });
+ });
+}); |
|
35879c90d3f0f1b183845d7ffaf657ea96a8ba4c | lib/client/components/whatsnew/emailSelector.jsx | lib/client/components/whatsnew/emailSelector.jsx | import React from 'react';
class EmailSelector extends React.Component {
constructor(props) {
super(props);
this.state = {
premailer: false,
};
this.onPremailerChange = this.onPremailerChange.bind(this);
this.onSeeEmail = this.onSeeEmail.bind(this);
}
onPremailerChange(event) {
this.setState({ premailer: !!event.target.checked });
}
onSeeEmail(event) {
event.preventDefault();
window.open(`/email?period=${this.props.period}&premailer=${this.state.premailer}`);
}
render() {
return (
<form className="form-inline mt10">
<div className="form-group">
<button
className="btn btn-default form-control"
onClick={this.onSeeEmail}
>See daily email</button>
</div>
<div className="checkbox">
<label>
<input
type="checkbox"
value="1"
onChange={this.onPremailerChange}
/>
{' '}
w/ premailer
</label>
</div>
</form>
);
}
}
EmailSelector.propTypes = {
period: React.PropTypes.number.isRequired,
};
export default EmailSelector;
| Implement react-router and factorize whatsnew page | Implement react-router and factorize whatsnew page
| JSX | mit | dbrugne/ftp-nanny,dbrugne/ftp-nanny | ---
+++
@@ -0,0 +1,48 @@
+import React from 'react';
+
+class EmailSelector extends React.Component {
+ constructor(props) {
+ super(props);
+ this.state = {
+ premailer: false,
+ };
+ this.onPremailerChange = this.onPremailerChange.bind(this);
+ this.onSeeEmail = this.onSeeEmail.bind(this);
+ }
+ onPremailerChange(event) {
+ this.setState({ premailer: !!event.target.checked });
+ }
+ onSeeEmail(event) {
+ event.preventDefault();
+ window.open(`/email?period=${this.props.period}&premailer=${this.state.premailer}`);
+ }
+ render() {
+ return (
+ <form className="form-inline mt10">
+ <div className="form-group">
+ <button
+ className="btn btn-default form-control"
+ onClick={this.onSeeEmail}
+ >See daily email</button>
+ </div>
+ <div className="checkbox">
+ <label>
+ <input
+ type="checkbox"
+ value="1"
+ onChange={this.onPremailerChange}
+ />
+ {' '}
+ w/ premailer
+ </label>
+ </div>
+ </form>
+ );
+ }
+}
+
+EmailSelector.propTypes = {
+ period: React.PropTypes.number.isRequired,
+};
+
+export default EmailSelector; |
|
2e66e0149a3ecfb8a8a9a4f7e81ed7271f6f1e23 | bin/rtlib/defaultTheme/routelink.jsx | bin/rtlib/defaultTheme/routelink.jsx | // routelink.jsx
const ARCCORE = require('arccore');
const React = require('react');
const RouteHashLink = require('./routehashlink.jsx');
var RouteLink = React.createClass({
render: function() {
var pagesGraph = this.props.pagesGraph;
var route = this.props.route;
var errorStyles = {
backgroundColor: '#FFCC99',
fontWeight: 'bold'
};
if (route === undefined) {
return (<span style={errorStyles}><strong>Missing route! No link produced.</strong></span>);
}
var routeHash = this.props.lookup.routeToRouteHashMap[route];
if (routeHash === undefined) {
return (<span style={errorStyles}><strong>Route '{route}' is not defined! No link produced.</strong></span>);
}
if (!pagesGraph.isVertex(routeHash)) {
return (<span style={errorStyles}><strong>Route '{route}' is not associated with React JS subsystem! No link produced.</strong></span>);
}
return (<RouteHashLink {...this.props} routeHash={routeHash} />);
}
});
module.exports = RouteLink;
| Add a React JS component <RouteLink> to the default theme... ... Quickly render an <A> link tag to a another page in your snapsite by providing it's route (not route hash but the actual route path that's simpler for humans to remember). | Add a React JS component <RouteLink> to the default theme...
... Quickly render an <A> link tag to a another page in your snapsite by providing it's route (not route hash but the actual route path that's simpler for humans to remember).
| JSX | mit | Encapsule/snapsite,Encapsule/snapsite | ---
+++
@@ -0,0 +1,41 @@
+// routelink.jsx
+
+const ARCCORE = require('arccore');
+const React = require('react');
+
+const RouteHashLink = require('./routehashlink.jsx');
+
+var RouteLink = React.createClass({
+
+ render: function() {
+
+ var pagesGraph = this.props.pagesGraph;
+ var route = this.props.route;
+
+ var errorStyles = {
+ backgroundColor: '#FFCC99',
+ fontWeight: 'bold'
+ };
+
+ if (route === undefined) {
+ return (<span style={errorStyles}><strong>Missing route! No link produced.</strong></span>);
+ }
+
+ var routeHash = this.props.lookup.routeToRouteHashMap[route];
+ if (routeHash === undefined) {
+ return (<span style={errorStyles}><strong>Route '{route}' is not defined! No link produced.</strong></span>);
+ }
+
+ if (!pagesGraph.isVertex(routeHash)) {
+ return (<span style={errorStyles}><strong>Route '{route}' is not associated with React JS subsystem! No link produced.</strong></span>);
+ }
+
+ return (<RouteHashLink {...this.props} routeHash={routeHash} />);
+
+ }
+
+});
+
+module.exports = RouteLink;
+
+ |
|
246482a6a43aa9b5e36f27d166be8d54f482d90a | features/apimgt/org.wso2.carbon.apimgt.publisher.feature/src/main/resources/publisher-new/source/Tests/Utils/IntlHelper.jsx | features/apimgt/org.wso2.carbon.apimgt.publisher.feature/src/main/resources/publisher-new/source/Tests/Utils/IntlHelper.jsx | /*
* Copyright (c) 2019, 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.
*/
/**
* Components using the react-intl module require access to the intl context.
* This is not available when mounting single components in Enzyme.
* These helper functions aim to address that and wrap a valid,
* English-locale intl context around them.
*/
/**
* WSO2 Addition : This pice of code is adapted from the suggested approach for enzyme mount
* and shallow testing in official react-intl docs
* For more info refer: https://github.com/formatjs/react-intl/blob/master/docs/Testing-with-React-Intl.md#enzyme
*/
import React from 'react';
import { IntlProvider, intlShape, useIntl } from 'react-intl';
import { mount, shallow } from 'enzyme';
// You can pass your messages to the IntlProvider. Optional: remove if unneeded.
const messages = require('../../../site/public/locales/en.json'); // en.json
// Create the IntlProvider to retrieve context for wrapping around.
const IntlProviderWithMessages = new IntlProvider({ locale: 'en', messages }, {});
// const { intl } = intlProvider.getChildContext();
/**
* When using React-Intl `injectIntl` on components, props.intl is required.
*/
function nodeWithIntlProp(node) {
return React.cloneElement(node, { intl });
}
/**
*
*
* @export Shallow render method with injected Intl context
* @param {*} node
* @param {*} [{ context, ...additionalOptions }={}]
* @returns
*/
export function shallowWithIntl(node, { context, ...additionalOptions } = {}) {
return shallow(nodeWithIntlProp(node), {
context: Object.assign({}, context, { intl }),
...additionalOptions,
});
}
/**
*
*
* @export Mount method with injected Intl context
* @param {*} node
* @param {*} [{ context, childContextTypes, ...additionalOptions }={}]
* @returns
*/
export function mountWithIntl(node) {
const Wrapper = () => {
return (
<IntlProvider locale='en' messages={messages}>
{node}
</IntlProvider>
);
};
return mount(<Wrapper />);
}
| Update intl test helper util | Update intl test helper util
| JSX | apache-2.0 | tharikaGitHub/carbon-apimgt,Rajith90/carbon-apimgt,chamindias/carbon-apimgt,fazlan-nazeem/carbon-apimgt,chamilaadhi/carbon-apimgt,fazlan-nazeem/carbon-apimgt,isharac/carbon-apimgt,malinthaprasan/carbon-apimgt,pubudu538/carbon-apimgt,uvindra/carbon-apimgt,sanjeewa-malalgoda/carbon-apimgt,prasa7/carbon-apimgt,praminda/carbon-apimgt,wso2/carbon-apimgt,tharikaGitHub/carbon-apimgt,nuwand/carbon-apimgt,isharac/carbon-apimgt,sanjeewa-malalgoda/carbon-apimgt,prasa7/carbon-apimgt,nuwand/carbon-apimgt,prasa7/carbon-apimgt,malinthaprasan/carbon-apimgt,harsha89/carbon-apimgt,sanjeewa-malalgoda/carbon-apimgt,nuwand/carbon-apimgt,harsha89/carbon-apimgt,nuwand/carbon-apimgt,chamilaadhi/carbon-apimgt,wso2/carbon-apimgt,chamindias/carbon-apimgt,tharindu1st/carbon-apimgt,bhathiya/carbon-apimgt,tharindu1st/carbon-apimgt,ruks/carbon-apimgt,isharac/carbon-apimgt,tharikaGitHub/carbon-apimgt,fazlan-nazeem/carbon-apimgt,uvindra/carbon-apimgt,pubudu538/carbon-apimgt,uvindra/carbon-apimgt,praminda/carbon-apimgt,chamindias/carbon-apimgt,Rajith90/carbon-apimgt,prasa7/carbon-apimgt,tharindu1st/carbon-apimgt,bhathiya/carbon-apimgt,ruks/carbon-apimgt,pubudu538/carbon-apimgt,wso2/carbon-apimgt,uvindra/carbon-apimgt,bhathiya/carbon-apimgt,jaadds/carbon-apimgt,wso2/carbon-apimgt,ruks/carbon-apimgt,harsha89/carbon-apimgt,bhathiya/carbon-apimgt,chamindias/carbon-apimgt,jaadds/carbon-apimgt,pubudu538/carbon-apimgt,praminda/carbon-apimgt,ruks/carbon-apimgt,jaadds/carbon-apimgt,harsha89/carbon-apimgt,chamilaadhi/carbon-apimgt,malinthaprasan/carbon-apimgt,malinthaprasan/carbon-apimgt,jaadds/carbon-apimgt,fazlan-nazeem/carbon-apimgt,tharikaGitHub/carbon-apimgt,isharac/carbon-apimgt,Rajith90/carbon-apimgt,tharindu1st/carbon-apimgt,chamilaadhi/carbon-apimgt,Rajith90/carbon-apimgt,sanjeewa-malalgoda/carbon-apimgt | ---
+++
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2019, 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.
+ */
+
+/**
+ * Components using the react-intl module require access to the intl context.
+ * This is not available when mounting single components in Enzyme.
+ * These helper functions aim to address that and wrap a valid,
+ * English-locale intl context around them.
+ */
+
+/**
+ * WSO2 Addition : This pice of code is adapted from the suggested approach for enzyme mount
+ * and shallow testing in official react-intl docs
+ * For more info refer: https://github.com/formatjs/react-intl/blob/master/docs/Testing-with-React-Intl.md#enzyme
+ */
+
+import React from 'react';
+import { IntlProvider, intlShape, useIntl } from 'react-intl';
+import { mount, shallow } from 'enzyme';
+
+// You can pass your messages to the IntlProvider. Optional: remove if unneeded.
+const messages = require('../../../site/public/locales/en.json'); // en.json
+
+// Create the IntlProvider to retrieve context for wrapping around.
+const IntlProviderWithMessages = new IntlProvider({ locale: 'en', messages }, {});
+// const { intl } = intlProvider.getChildContext();
+
+/**
+ * When using React-Intl `injectIntl` on components, props.intl is required.
+ */
+function nodeWithIntlProp(node) {
+ return React.cloneElement(node, { intl });
+}
+
+/**
+ *
+ *
+ * @export Shallow render method with injected Intl context
+ * @param {*} node
+ * @param {*} [{ context, ...additionalOptions }={}]
+ * @returns
+ */
+export function shallowWithIntl(node, { context, ...additionalOptions } = {}) {
+ return shallow(nodeWithIntlProp(node), {
+ context: Object.assign({}, context, { intl }),
+ ...additionalOptions,
+ });
+}
+
+/**
+ *
+ *
+ * @export Mount method with injected Intl context
+ * @param {*} node
+ * @param {*} [{ context, childContextTypes, ...additionalOptions }={}]
+ * @returns
+ */
+export function mountWithIntl(node) {
+ const Wrapper = () => {
+ return (
+ <IntlProvider locale='en' messages={messages}>
+ {node}
+ </IntlProvider>
+ );
+ };
+ return mount(<Wrapper />);
+} |
|
169a0529863cbbb0568db5b470ef2d79fdaecac0 | index.jsx | index.jsx | 'use strict';
import React, {PropTypes} from 'react';
function radio(name, selectedValue, onChange) {
return React.createClass({
render: function() {
return (
<input
{...this.props}
type="radio"
name={name}
checked={this.props.value === selectedValue}
onChange={onChange.bind(null, this.props.value)} />
);
}
});
}
export default React.createClass({
propTypes: {
name: PropTypes.string,
selectedValue: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
onChange: PropTypes.func,
children: PropTypes.func,
},
render: function() {
let {name, selectedValue, onChange, children} = this.props;
return (
<div>
{children && children(radio(name, selectedValue, onChange))}
</div>
);
}
});
| import React, {PropTypes} from 'react';
function radio(name, selectedValue, onChange) {
return React.createClass({
render: function() {
return (
<input
{...this.props}
type="radio"
name={name}
checked={this.props.value === selectedValue}
onChange={onChange.bind(null, this.props.value)} />
);
}
});
}
export default React.createClass({
propTypes: {
name: PropTypes.string,
selectedValue: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
onChange: PropTypes.func,
children: PropTypes.func,
},
render: function() {
let {name, selectedValue, onChange, children} = this.props;
return (
<div>
{children && children(radio(name, selectedValue, onChange))}
</div>
);
}
});
| Remove use strict (babel already puts that) | Remove use strict (babel already puts that)
| JSX | mit | beni55/react-radio-group,beni55/react-radio-group,chenglou/react-radio-group,chenglou/react-radio-group | ---
+++
@@ -1,5 +1,3 @@
-'use strict';
-
import React, {PropTypes} from 'react';
function radio(name, selectedValue, onChange) { |
6e37f5332d6866ce9182b2c043d2dfe895dce9fa | src/components/dl-container.jsx | src/components/dl-container.jsx | import React from 'react';
import Dl from './dl.jsx';
export default class DlContainer extends React.Component {
constructor(props) {
super(props);
}
render() {
let { data, hl } = this.props;
let terms = [];
data.forEach((d) => {
terms.push(d.name);
terms.push(d.desc);
});
return (
<Dl data={terms} hl={hl} />
);
}
}
DlContainer.PropTypes = {
data: React.PropTypes.arrayOf(React.PropTypes.object)
};
| Add container for handling data as provided | Add container for handling data as provided
| JSX | mit | jkrayer/summoner,jkrayer/summoner | ---
+++
@@ -0,0 +1,25 @@
+import React from 'react';
+import Dl from './dl.jsx';
+
+export default class DlContainer extends React.Component {
+ constructor(props) {
+ super(props);
+ }
+ render() {
+ let { data, hl } = this.props;
+ let terms = [];
+
+ data.forEach((d) => {
+ terms.push(d.name);
+ terms.push(d.desc);
+ });
+
+ return (
+ <Dl data={terms} hl={hl} />
+ );
+ }
+}
+
+DlContainer.PropTypes = {
+ data: React.PropTypes.arrayOf(React.PropTypes.object)
+}; |
|
98e23760012060eea0c22d29ddb797b330fe711d | client/app/bundles/comments/startup/clientRegistration.jsx | client/app/bundles/comments/startup/clientRegistration.jsx | import App from './ClientApp';
import RouterApp from './ClientRouterApp';
import SimpleCommentScreen from '../components/SimpleCommentScreen/SimpleCommentScreen';
import ReactOnRails from 'react-on-rails';
ReactOnRails.setOptions({
traceTurbolinks: TRACE_TURBOLINKS,
});
ReactOnRails.register(
{
App,
RouterApp,
SimpleCommentScreen,
}
);
| import App from './ClientApp';
import RouterApp from './ClientRouterApp';
import SimpleCommentScreen from '../components/SimpleCommentScreen/SimpleCommentScreen';
import ReactOnRails from 'react-on-rails';
ReactOnRails.setOptions({
traceTurbolinks: TRACE_TURBOLINKS, // eslint-disable-line no-undef
});
ReactOnRails.register(
{
App,
RouterApp,
SimpleCommentScreen,
}
);
| Fix linting issue with Webpack defined var | Fix linting issue with Webpack defined var
| JSX | mit | thiagoc7/react-webpack-rails-tutorial,suzukaze/react-webpack-rails-tutorial,szyablitsky/react-webpack-rails-tutorial,suzukaze/react-webpack-rails-tutorial,suzukaze/react-webpack-rails-tutorial,jeffthemaximum/jeffline,szyablitsky/react-webpack-rails-tutorial,phosphene/react-on-rails-cherrypick,thiagoc7/react-webpack-rails-tutorial,justin808/react-webpack-rails-tutorial,shunwen/react-webpack-rails-tutorial,phosphene/react-on-rails-cherrypick,shunwen/react-webpack-rails-tutorial,shunwen/react-webpack-rails-tutorial,phosphene/react-on-rails-cherrypick,jeffthemaximum/jeffline,justin808/react-webpack-rails-tutorial,shakacode/react-webpack-rails-tutorial,shakacode/react-webpack-rails-tutorial,roxolan/react-webpack-rails-tutorial,phosphene/react-on-rails-cherrypick,jeffthemaximum/Teachers-Dont-Pay-Jeff,roxolan/react-webpack-rails-tutorial,jeffthemaximum/Teachers-Dont-Pay-Jeff,jeffthemaximum/jeffline,thiagoc7/react-webpack-rails-tutorial,shunwen/react-webpack-rails-tutorial,jeffthemaximum/Teachers-Dont-Pay-Jeff,roxolan/react-webpack-rails-tutorial,shakacode/react-webpack-rails-tutorial,szyablitsky/react-webpack-rails-tutorial,roxolan/react-webpack-rails-tutorial,thiagoc7/react-webpack-rails-tutorial,jeffthemaximum/Teachers-Dont-Pay-Jeff,jeffthemaximum/jeffline,justin808/react-webpack-rails-tutorial,jeffthemaximum/jeffline,suzukaze/react-webpack-rails-tutorial,justin808/react-webpack-rails-tutorial,jeffthemaximum/Teachers-Dont-Pay-Jeff,shakacode/react-webpack-rails-tutorial,szyablitsky/react-webpack-rails-tutorial | ---
+++
@@ -4,7 +4,7 @@
import ReactOnRails from 'react-on-rails';
ReactOnRails.setOptions({
- traceTurbolinks: TRACE_TURBOLINKS,
+ traceTurbolinks: TRACE_TURBOLINKS, // eslint-disable-line no-undef
});
ReactOnRails.register( |
927c3731559c99f550d3448768135913797fe710 | src/jipt-paragraphs.jsx | src/jipt-paragraphs.jsx | /**
* Paragraph parsing/splitting for article jipt i18n
*/
const SimpleMarkdown = require("simple-markdown");
const arrayRules = {
paragraph: {
match: SimpleMarkdown.defaultRules.paragraph.match,
order: 1,
parse: (capture, state, parse) => capture[1],
},
};
const builtArrayParser = SimpleMarkdown.parserFor(arrayRules);
// This should just return an array of strings! magick!
const parseToArray = (source) => {
// Remove any leading newlines to avoid splitting weirdness
// (simple-markdown has the `newline` rule for this, and i have
// no idea how this will handle leading newlines without that rule),
// and add \n\n to let it parse at a block/paragraph level
const paragraphedSource = source.replace(/^\n\s*\n/, '') + "\n\n";
return builtArrayParser(paragraphedSource, { inline: false });
};
const joinFromArray = (paragraphs) => paragraphs.join("\n\n");
module.exports = {
parseToArray: parseToArray,
joinFromArray: joinFromArray,
};
| Add a small paragraph-splitting parser. | JIPT: Add a small paragraph-splitting parser.
Summary:
Uses simple-markdown to add a function to split a string into its
constituent paragraphs, and a function to join those paragraphs back
into a source string.
Depends on D21241
Test Plan: none
Reviewers: emily
Reviewed By: emily
Subscribers: jlfwong, kevinb
Differential Revision: https://phabricator.khanacademy.org/D21242
| JSX | mit | learningequality/perseus,alexristich/perseus,iamchenxin/perseus,ariabuckles/perseus,ariabuckles/perseus,sachgits/perseus,iamchenxin/perseus,sachgits/perseus,alexristich/perseus,ariabuckles/perseus,learningequality/perseus,ariabuckles/perseus | ---
+++
@@ -0,0 +1,32 @@
+/**
+ * Paragraph parsing/splitting for article jipt i18n
+ */
+
+const SimpleMarkdown = require("simple-markdown");
+
+const arrayRules = {
+ paragraph: {
+ match: SimpleMarkdown.defaultRules.paragraph.match,
+ order: 1,
+ parse: (capture, state, parse) => capture[1],
+ },
+};
+
+const builtArrayParser = SimpleMarkdown.parserFor(arrayRules);
+
+// This should just return an array of strings! magick!
+const parseToArray = (source) => {
+ // Remove any leading newlines to avoid splitting weirdness
+ // (simple-markdown has the `newline` rule for this, and i have
+ // no idea how this will handle leading newlines without that rule),
+ // and add \n\n to let it parse at a block/paragraph level
+ const paragraphedSource = source.replace(/^\n\s*\n/, '') + "\n\n";
+ return builtArrayParser(paragraphedSource, { inline: false });
+};
+
+const joinFromArray = (paragraphs) => paragraphs.join("\n\n");
+
+module.exports = {
+ parseToArray: parseToArray,
+ joinFromArray: joinFromArray,
+}; |
|
dff5473d43a53cf099d5c4f259961624ffe6ac10 | src/js/Components/Modal.jsx | src/js/Components/Modal.jsx | import React from 'react';
import ImportedModal from 'react-responsive-modal';
export default class Modal extends React.Component {
constructor(props) {
super(props);
this.state = {
show: this.props.show
};
}
close() {
this.props.onHide();
this.setState({
show: false
});
}
render() {
const overlayStyle = {
zIndex: 10000,
backgroundColor: 'rgba(0,0,0,0.5)'
};
const modalStyle = {
marginTop: '150px',
marginLeft: '10px',
marginRight: '10px',
borderRadius: '5px',
padding: '40px',
minWidth: '300px',
paddingBottom: '10px'
};
return (
<ImportedModal {...this.props}
open={this.state.show}
onClose={this.close.bind(this)}
overlayStyle={overlayStyle}
modalStyle={modalStyle}>
{this.props.children}
</ImportedModal>
);
}
} | Move modal to own component file | Move modal to own component file
| JSX | agpl-3.0 | BreakOutEvent/breakout-frontend | ---
+++
@@ -0,0 +1,45 @@
+import React from 'react';
+import ImportedModal from 'react-responsive-modal';
+export default class Modal extends React.Component {
+
+ constructor(props) {
+ super(props);
+ this.state = {
+ show: this.props.show
+ };
+ }
+
+ close() {
+ this.props.onHide();
+ this.setState({
+ show: false
+ });
+ }
+
+ render() {
+ const overlayStyle = {
+ zIndex: 10000,
+ backgroundColor: 'rgba(0,0,0,0.5)'
+ };
+
+ const modalStyle = {
+ marginTop: '150px',
+ marginLeft: '10px',
+ marginRight: '10px',
+ borderRadius: '5px',
+ padding: '40px',
+ minWidth: '300px',
+ paddingBottom: '10px'
+ };
+
+ return (
+ <ImportedModal {...this.props}
+ open={this.state.show}
+ onClose={this.close.bind(this)}
+ overlayStyle={overlayStyle}
+ modalStyle={modalStyle}>
+ {this.props.children}
+ </ImportedModal>
+ );
+ }
+} |
|
f3b1296a9ac67abc7b97fd0647acc1d891a620db | demo/app/client/js/patterns/index.jsx | demo/app/client/js/patterns/index.jsx |
export * from './client';
export * from './server';
export * from './braintree';
export * from './billing';
export * from './experience';
export * from './styles';
export * from './mark';
export * from './confirm';
|
export * from './client';
export * from './server';
// export * from './braintree';
// export * from './billing';
export * from './experience';
export * from './styles';
export * from './mark';
export * from './confirm';
| Comment out agreements and braintree demo | Comment out agreements and braintree demo
| JSX | apache-2.0 | vishakha94/paypal-checkout,paypal/paypal-checkout,mstuart/paypal-checkout,bluepnume/paypal-checkout,andreabondi/paypal-checkout,bluepnume/paypal-checkout,trainerbill/paypal-checkout,mstuart/paypal-checkout,paypal/paypal-checkout,bluepnume/paypal-checkout,andreabondi/paypal-checkout,vishakha94/paypal-checkout,andreabondi/paypal-checkout,paypal/paypal-checkout,trainerbill/paypal-checkout,vishakha94/paypal-checkout,mstuart/paypal-checkout,trainerbill/paypal-checkout | ---
+++
@@ -1,8 +1,8 @@
export * from './client';
export * from './server';
-export * from './braintree';
-export * from './billing';
+// export * from './braintree';
+// export * from './billing';
export * from './experience';
export * from './styles';
export * from './mark'; |
760e74f11c4f15b80545f21739962d3461a355a4 | features/apimgt/org.wso2.carbon.apimgt.store.feature/src/main/resources/admin_new/source/src/app/components/APICategories/DeleteAPICategory.jsx | features/apimgt/org.wso2.carbon.apimgt.store.feature/src/main/resources/admin_new/source/src/app/components/APICategories/DeleteAPICategory.jsx | /*
* Copyright (c) 2020, 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 API from 'AppData/api';
import PropTypes from 'prop-types';
import DialogContentText from '@material-ui/core/DialogContentText';
import DeleteForeverIcon from '@material-ui/icons/DeleteForever';
import FormDialogBase from 'AppComponents/AdminPages/Addons/FormDialogBase';
/**
* API call to delete api category with uuid: id
* @param {number} id uuid of the api category to delete.
* @returns {Promise}.
*/
function apiCall(id) {
const restApi = new API();
return restApi.deleteAPICategory(id);
}
/**
* Render delete dialog box.
* @param {JSON} props component props.
* @returns {JSX} Loading animation.
*/
function Delete({ updateList, dataRow }) {
const { id } = dataRow;
const formSaveCallback = () => {
const promiseAPICall = apiCall(id);
promiseAPICall
.then((data) => {
updateList();
return data;
})
.catch((e) => {
return e;
});
return promiseAPICall;
};
return (
<FormDialogBase
title='Delete API category?'
saveButtonText='Delete'
icon={<DeleteForeverIcon />}
formSaveCallback={formSaveCallback}
>
<DialogContentText>
Are you sure you want to delete this API Category?
</DialogContentText>
</FormDialogBase>
);
}
Delete.propTypes = {
updateList: PropTypes.number.isRequired,
dataRow: PropTypes.shape({
id: PropTypes.number.isRequired,
}).isRequired,
};
export default Delete;
| Apply new theme for API Category delete | Apply new theme for API Category delete
| JSX | apache-2.0 | jaadds/carbon-apimgt,Rajith90/carbon-apimgt,bhathiya/carbon-apimgt,tharindu1st/carbon-apimgt,tharindu1st/carbon-apimgt,Rajith90/carbon-apimgt,sanjeewa-malalgoda/carbon-apimgt,malinthaprasan/carbon-apimgt,nuwand/carbon-apimgt,chamindias/carbon-apimgt,isharac/carbon-apimgt,chamilaadhi/carbon-apimgt,praminda/carbon-apimgt,Rajith90/carbon-apimgt,jaadds/carbon-apimgt,sanjeewa-malalgoda/carbon-apimgt,tharikaGitHub/carbon-apimgt,uvindra/carbon-apimgt,nuwand/carbon-apimgt,isharac/carbon-apimgt,jaadds/carbon-apimgt,tharikaGitHub/carbon-apimgt,wso2/carbon-apimgt,sanjeewa-malalgoda/carbon-apimgt,bhathiya/carbon-apimgt,fazlan-nazeem/carbon-apimgt,praminda/carbon-apimgt,ruks/carbon-apimgt,chamindias/carbon-apimgt,tharikaGitHub/carbon-apimgt,fazlan-nazeem/carbon-apimgt,fazlan-nazeem/carbon-apimgt,isharac/carbon-apimgt,bhathiya/carbon-apimgt,bhathiya/carbon-apimgt,uvindra/carbon-apimgt,wso2/carbon-apimgt,prasa7/carbon-apimgt,Rajith90/carbon-apimgt,prasa7/carbon-apimgt,chamindias/carbon-apimgt,uvindra/carbon-apimgt,wso2/carbon-apimgt,praminda/carbon-apimgt,isharac/carbon-apimgt,fazlan-nazeem/carbon-apimgt,chamilaadhi/carbon-apimgt,sanjeewa-malalgoda/carbon-apimgt,malinthaprasan/carbon-apimgt,chamilaadhi/carbon-apimgt,jaadds/carbon-apimgt,nuwand/carbon-apimgt,ruks/carbon-apimgt,tharindu1st/carbon-apimgt,uvindra/carbon-apimgt,tharindu1st/carbon-apimgt,wso2/carbon-apimgt,tharikaGitHub/carbon-apimgt,ruks/carbon-apimgt,prasa7/carbon-apimgt,chamindias/carbon-apimgt,prasa7/carbon-apimgt,malinthaprasan/carbon-apimgt,ruks/carbon-apimgt,malinthaprasan/carbon-apimgt,chamilaadhi/carbon-apimgt,nuwand/carbon-apimgt | ---
+++
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2020, 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 API from 'AppData/api';
+import PropTypes from 'prop-types';
+import DialogContentText from '@material-ui/core/DialogContentText';
+import DeleteForeverIcon from '@material-ui/icons/DeleteForever';
+import FormDialogBase from 'AppComponents/AdminPages/Addons/FormDialogBase';
+
+/**
+ * API call to delete api category with uuid: id
+ * @param {number} id uuid of the api category to delete.
+ * @returns {Promise}.
+ */
+function apiCall(id) {
+ const restApi = new API();
+ return restApi.deleteAPICategory(id);
+}
+
+/**
+ * Render delete dialog box.
+ * @param {JSON} props component props.
+ * @returns {JSX} Loading animation.
+ */
+function Delete({ updateList, dataRow }) {
+ const { id } = dataRow;
+
+ const formSaveCallback = () => {
+ const promiseAPICall = apiCall(id);
+
+ promiseAPICall
+ .then((data) => {
+ updateList();
+ return data;
+ })
+ .catch((e) => {
+ return e;
+ });
+ return promiseAPICall;
+ };
+
+ return (
+ <FormDialogBase
+ title='Delete API category?'
+ saveButtonText='Delete'
+ icon={<DeleteForeverIcon />}
+ formSaveCallback={formSaveCallback}
+ >
+ <DialogContentText>
+ Are you sure you want to delete this API Category?
+ </DialogContentText>
+ </FormDialogBase>
+ );
+}
+Delete.propTypes = {
+ updateList: PropTypes.number.isRequired,
+ dataRow: PropTypes.shape({
+ id: PropTypes.number.isRequired,
+ }).isRequired,
+};
+export default Delete; |
|
5f085bc2906bd7c791f6e8ab7d2b6437d45b37b0 | src/components/Breadcrumb.jsx | src/components/Breadcrumb.jsx | import styles from '../styles/breadcrumb'
import React from 'react'
import { translate } from '../plugins/preact-polyglot'
import { withRouter } from 'react-router'
const Breadcrumb = ({ t, router }) => {
// extract elements from the pathNames
let path = router.location.pathname.match(/\/([^/]*)(.*)/)
// rootName is the first element before file path
const rootName = path[1]
// the remain is the file path
const filePath = path[2]
return (
<h2 class={styles['fil-content-title']}>
{ t(`breadcrumb.title_${rootName}`) }
</h2>
)
}
export default translate()(withRouter(Breadcrumb))
| import styles from '../styles/breadcrumb'
import React from 'react'
import { translate } from '../plugins/preact-polyglot'
import { withRouter } from 'react-router'
const Breadcrumb = ({ t, router }) => {
// extract elements from the pathNames
let path = router.location.pathname.match(/\/([^/]*)(.*)/)
// rootName is the first element before file path
const rootName = path[1]
// the remainder is the file path
const filePath = path[2]
const filePathElements = path[2].replace(/\/([^/]*)/, '$1').split('/')
return (
<h2 class={styles['fil-content-title']}>
{ t(`breadcrumb.title_${rootName}`) }
</h2>
)
}
export default translate()(withRouter(Breadcrumb))
| Add file path elements computing in breadcrumb component (for later use) | [feat] Add file path elements computing in breadcrumb component (for later use)
| JSX | agpl-3.0 | cozy/cozy-files-v3,cozy/cozy-files-v3,enguerran/cozy-drive,enguerran/cozy-files-v3,nono/cozy-files-v3,nono/cozy-files-v3,enguerran/cozy-drive,goldoraf/cozy-drive,cozy/cozy-files-v3,enguerran/cozy-files-v3,cozy/cozy-files-v3,goldoraf/cozy-drive,y-lohse/cozy-drive,goldoraf/cozy-drive,y-lohse/cozy-files-v3,enguerran/cozy-files-v3,y-lohse/cozy-drive,nono/cozy-files-v3,enguerran/cozy-files-v3,y-lohse/cozy-files-v3,enguerran/cozy-drive,y-lohse/cozy-drive,y-lohse/cozy-drive,y-lohse/cozy-files-v3,goldoraf/cozy-drive,nono/cozy-files-v3,enguerran/cozy-drive | ---
+++
@@ -11,8 +11,9 @@
// rootName is the first element before file path
const rootName = path[1]
- // the remain is the file path
+ // the remainder is the file path
const filePath = path[2]
+ const filePathElements = path[2].replace(/\/([^/]*)/, '$1').split('/')
return (
<h2 class={styles['fil-content-title']}> |
9d027219e3a3e54baeda3ea0d49188d5bae8caf9 | src/sentry/static/sentry/app/views/groupDetails/seenBy.jsx | src/sentry/static/sentry/app/views/groupDetails/seenBy.jsx | /*** @jsx React.DOM */
var React = require("react");
var GroupSeenBy = React.createClass({
render() {
return (
<div className="seen-by">
<ul>
<li>Seen by:</li>
</ul>
</div>
);
}
});
module.exports = GroupSeenBy;
| /*** @jsx React.DOM */
var React = require("react");
var Gravatar = require("../../components/gravatar");
var GroupState = require("../../mixins/groupState");
var GroupSeenBy = React.createClass({
mixins: [GroupState],
render() {
var group = this.getGroup();
var seenByNodes = group.seenBy.map((user, userIdx) => {
return (
<li key={userIdx}>
<Gravatar size={24} email={user.email} />
</li>
);
});
if (!seenByNodes) {
return <div />;
}
return (
<div className="seen-by">
<ul>
<li>Seen by:</li>
{seenByNodes}
</ul>
</div>
);
}
});
module.exports = GroupSeenBy;
| Use real data for seen by | Use real data for seen by
| JSX | bsd-3-clause | gencer/sentry,JackDanger/sentry,felixbuenemann/sentry,Natim/sentry,korealerts1/sentry,ifduyue/sentry,kevinlondon/sentry,BuildingLink/sentry,jean/sentry,Kryz/sentry,ifduyue/sentry,beeftornado/sentry,daevaorn/sentry,mvaled/sentry,BuildingLink/sentry,Kryz/sentry,beeftornado/sentry,nicholasserra/sentry,looker/sentry,gencer/sentry,fotinakis/sentry,JackDanger/sentry,mvaled/sentry,ngonzalvez/sentry,korealerts1/sentry,JamesMura/sentry,gencer/sentry,JamesMura/sentry,kevinlondon/sentry,korealerts1/sentry,zenefits/sentry,kevinlondon/sentry,songyi199111/sentry,mitsuhiko/sentry,songyi199111/sentry,jean/sentry,ifduyue/sentry,beeftornado/sentry,BayanGroup/sentry,alexm92/sentry,nicholasserra/sentry,JamesMura/sentry,JackDanger/sentry,mvaled/sentry,zenefits/sentry,looker/sentry,fuziontech/sentry,daevaorn/sentry,mitsuhiko/sentry,looker/sentry,BuildingLink/sentry,ngonzalvez/sentry,zenefits/sentry,BayanGroup/sentry,gencer/sentry,nicholasserra/sentry,BayanGroup/sentry,ngonzalvez/sentry,fotinakis/sentry,imankulov/sentry,BuildingLink/sentry,felixbuenemann/sentry,imankulov/sentry,felixbuenemann/sentry,imankulov/sentry,mvaled/sentry,wong2/sentry,daevaorn/sentry,fotinakis/sentry,zenefits/sentry,looker/sentry,jean/sentry,fotinakis/sentry,alexm92/sentry,alexm92/sentry,wong2/sentry,BuildingLink/sentry,gencer/sentry,hongliang5623/sentry,looker/sentry,mvaled/sentry,ifduyue/sentry,mvaled/sentry,Natim/sentry,jean/sentry,zenefits/sentry,hongliang5623/sentry,songyi199111/sentry,jean/sentry,fuziontech/sentry,JamesMura/sentry,Natim/sentry,fuziontech/sentry,JamesMura/sentry,hongliang5623/sentry,Kryz/sentry,daevaorn/sentry,ifduyue/sentry,wong2/sentry | ---
+++
@@ -2,12 +2,32 @@
var React = require("react");
+var Gravatar = require("../../components/gravatar");
+var GroupState = require("../../mixins/groupState");
+
var GroupSeenBy = React.createClass({
+ mixins: [GroupState],
+
render() {
+ var group = this.getGroup();
+
+ var seenByNodes = group.seenBy.map((user, userIdx) => {
+ return (
+ <li key={userIdx}>
+ <Gravatar size={24} email={user.email} />
+ </li>
+ );
+ });
+
+ if (!seenByNodes) {
+ return <div />;
+ }
+
return (
<div className="seen-by">
<ul>
<li>Seen by:</li>
+ {seenByNodes}
</ul>
</div>
); |
9ce5c896f80075bd43f89de4ef6ec92e82f0ba9d | web/app/components/Utility/AccountName.jsx | web/app/components/Utility/AccountName.jsx | import React from "react";
import ChainTypes from "./ChainTypes";
import BindToChainState from "./BindToChainState";
/**
* Given an account id, displays the name of that account
*
* Expects one property, 'account' which should be a account id
*/
class AccountName extends React.Component {
static propTypes = {
account: ChainTypes.ChainObject.isRequired
}
render() {
if (!this.props.account) return null;
return <span>{this.props.account.get("name")}</span>;
}
}
export default BindToChainState(AccountName);
| Add utility component to display account name from id | Add utility component to display account name from id
| JSX | mit | bitshares/bitshares-2-ui,BitSharesEurope/testnet.bitshares.eu,bitshares/bitshares-2-ui,BitSharesEurope/wallet.bitshares.eu,openledger/graphene-ui,BitSharesEurope/testnet.bitshares.eu,trendever/bitshares-ui,BitSharesEurope/graphene-ui-testnet,BitSharesEurope/wallet.bitshares.eu,openledger/graphene-ui,BitSharesEurope/graphene-ui-testnet,bitshares/bitshares-ui,bitshares/bitshares-2-ui,trendever/bitshares-ui,bitshares/bitshares-ui,BitSharesEurope/testnet.bitshares.eu,BitSharesEurope/graphene-ui-testnet,BitSharesEurope/wallet.bitshares.eu,trendever/bitshares-ui,trendever/bitshares-ui,BitSharesEurope/wallet.bitshares.eu,bitshares/bitshares-ui,BitSharesEurope/graphene-ui-testnet,BitSharesEurope/testnet.bitshares.eu,openledger/graphene-ui,bitshares/bitshares-ui | ---
+++
@@ -0,0 +1,23 @@
+import React from "react";
+import ChainTypes from "./ChainTypes";
+import BindToChainState from "./BindToChainState";
+
+/**
+ * Given an account id, displays the name of that account
+ *
+ * Expects one property, 'account' which should be a account id
+ */
+
+class AccountName extends React.Component {
+
+ static propTypes = {
+ account: ChainTypes.ChainObject.isRequired
+ }
+
+ render() {
+ if (!this.props.account) return null;
+ return <span>{this.props.account.get("name")}</span>;
+ }
+}
+
+export default BindToChainState(AccountName); |
|
a93103ebd8bccf3449083551eaf5ee8b3d280c23 | test/helpers/clockette-utils.jsx | test/helpers/clockette-utils.jsx | 'use strict';
import React from 'react/addons';
const ReactTestUtils = React.addons.TestUtils;
class RenderedComponent {
constructor(component) {
this.component = component;
this.renderedComponent = ReactTestUtils.renderIntoDocument(component);
}
/*
* Finds a node in component's children
*/
find(selector) {
let findClassName = selector.match(/\.([a-zA-Z0-9_-]+)/);
let results;
// Find by className
if (findClassName !== null) {
results = ReactTestUtils.scryRenderedDOMComponentsWithClass(
this.renderedComponent,
findClassName[1]
).map(this.getDOMNode);
}
// Else find by tagName
else {
results = ReactTestUtils.scryRenderedDOMComponentsWithTag(
this.renderedComponent,
selector
).map(this.getDOMNode);
}
return results.length === 1 ? results[0] : results;
}
getDOMNode(reactElement) {
return reactElement.getDOMNode();
}
}
const ClocketteUtils = (component) => {
return new RenderedComponent(component);
};
export default ClocketteUtils;
| Create a test utility class to make testing easier | Create a test utility class to make testing easier
| JSX | mit | rhumlover/clockette,rhumlover/clockette | ---
+++
@@ -0,0 +1,47 @@
+'use strict';
+
+import React from 'react/addons';
+const ReactTestUtils = React.addons.TestUtils;
+
+
+class RenderedComponent {
+ constructor(component) {
+ this.component = component;
+ this.renderedComponent = ReactTestUtils.renderIntoDocument(component);
+ }
+
+ /*
+ * Finds a node in component's children
+ */
+ find(selector) {
+ let findClassName = selector.match(/\.([a-zA-Z0-9_-]+)/);
+ let results;
+
+ // Find by className
+ if (findClassName !== null) {
+ results = ReactTestUtils.scryRenderedDOMComponentsWithClass(
+ this.renderedComponent,
+ findClassName[1]
+ ).map(this.getDOMNode);
+ }
+ // Else find by tagName
+ else {
+ results = ReactTestUtils.scryRenderedDOMComponentsWithTag(
+ this.renderedComponent,
+ selector
+ ).map(this.getDOMNode);
+ }
+
+ return results.length === 1 ? results[0] : results;
+ }
+
+ getDOMNode(reactElement) {
+ return reactElement.getDOMNode();
+ }
+}
+
+const ClocketteUtils = (component) => {
+ return new RenderedComponent(component);
+};
+
+export default ClocketteUtils; |
|
d3d71c9f4561094fe13a76107eaf224aa6ad5414 | src/web/components/Information/index.jsx | src/web/components/Information/index.jsx | import React from 'react'
import {
Panel
} from 'react-bootstrap'
import classnames from 'classnames'
import { connect } from 'nuclear-js-react-addons'
import getters from '~/stores/getters'
import actions from '~/actions'
import axios from 'axios'
const style = require('./style.scss')
@connect(props => ({ botInformation: getters.botInformation }))
class InformationComponent extends React.Component {
static contextTypes = {
router: React.PropTypes.object.isRequired
}
constructor(props, context) {
super(props, context)
this.state = { loading: true }
}
componentDidMount() {
this.setState({
loading: false
})
}
openLicenseComponent() {
actions.toggleLicenseModal()
}
render() {
if (this.state.loading) {
return null
}
return <Panel className={classnames(style.information, 'bp-info')}>
<h3 className={classnames(style.informationName, 'bp-name')}>
{this.props.botInformation.get('name')}
</h3>
<p className={classnames(style.informationDescription, 'bp-description')}>
{this.props.botInformation.get('description')}
</p>
<p className={classnames(style.informationAuthor, 'bp-author')}>
Created by <strong>{this.props.botInformation.get('author')}</strong>
</p>
<p className={classnames(style.informationVersion, 'bp-version')}>
Version {this.props.botInformation.get('version')}
</p>
<p className={classnames(style.informationLicense, 'bp-license')}>
Licensed under {this.props.botInformation.get('license')} (
<a href='#' onClick={this.openLicenseComponent}>Change</a>)
</p>
<div className={classnames(style.whereFrom, 'bp-where-from')}>Info extracted from package.json</div>
</Panel>
}
}
export default InformationComponent
| Create a new component for information | Create a new component for information
| JSX | agpl-3.0 | botpress/botpress,botpress/botpress,botpress/botpress,botpress/botpress | ---
+++
@@ -0,0 +1,66 @@
+import React from 'react'
+import {
+ Panel
+} from 'react-bootstrap'
+
+import classnames from 'classnames'
+
+import { connect } from 'nuclear-js-react-addons'
+import getters from '~/stores/getters'
+import actions from '~/actions'
+
+import axios from 'axios'
+
+const style = require('./style.scss')
+
+@connect(props => ({ botInformation: getters.botInformation }))
+class InformationComponent extends React.Component {
+
+ static contextTypes = {
+ router: React.PropTypes.object.isRequired
+ }
+
+ constructor(props, context) {
+ super(props, context)
+
+ this.state = { loading: true }
+ }
+
+ componentDidMount() {
+ this.setState({
+ loading: false
+ })
+ }
+
+ openLicenseComponent() {
+ actions.toggleLicenseModal()
+ }
+
+ render() {
+ if (this.state.loading) {
+ return null
+ }
+
+ return <Panel className={classnames(style.information, 'bp-info')}>
+ <h3 className={classnames(style.informationName, 'bp-name')}>
+ {this.props.botInformation.get('name')}
+ </h3>
+ <p className={classnames(style.informationDescription, 'bp-description')}>
+ {this.props.botInformation.get('description')}
+ </p>
+ <p className={classnames(style.informationAuthor, 'bp-author')}>
+ Created by <strong>{this.props.botInformation.get('author')}</strong>
+ </p>
+ <p className={classnames(style.informationVersion, 'bp-version')}>
+ Version {this.props.botInformation.get('version')}
+ </p>
+ <p className={classnames(style.informationLicense, 'bp-license')}>
+ Licensed under {this.props.botInformation.get('license')} (
+ <a href='#' onClick={this.openLicenseComponent}>Change</a>)
+ </p>
+ <div className={classnames(style.whereFrom, 'bp-where-from')}>Info extracted from package.json</div>
+ </Panel>
+ }
+}
+
+export default InformationComponent |
|
58b4f8ef105768b039be53a2c5350e5b605505d5 | webapp/components/ArtifactsList.jsx | webapp/components/ArtifactsList.jsx | import React, {Component} from 'react';
import PropTypes from 'prop-types';
import {Flex, Box} from 'grid-styled';
import Collapsable from './Collapsable';
import Panel from './Panel';
import ResultGridHeader from './ResultGridHeader';
import ResultGridRow from './ResultGridRow';
export default class ArtifactsList extends Component {
static propTypes = {
artifacts: PropTypes.arrayOf(PropTypes.object).isRequired,
collapsable: PropTypes.bool,
maxVisible: PropTypes.number
};
static defaultProps = {
collapsable: false
};
constructor(props, context) {
super(props, context);
this.state = {collapsable: props.collapsable};
}
getTypeName(type) {
if (!type) {
return '';
}
return type
.toLowerCase()
.replace(/^.|_+[^_]/g, txt => ' ' + txt.slice(-1).toUpperCase())
.replace(/_/g, '');
}
render() {
return (
<Panel>
<ResultGridHeader>
<Flex align="center">
<Box flex="1" width={1} pr={15}>
File
</Box>
</Flex>
</ResultGridHeader>
<Collapsable
collapsable={this.props.collapsable}
maxVisible={this.props.maxVisible}>
{this.props.artifacts.map(artifact => {
return (
<ResultGridRow key={artifact.id}>
<Flex align="center">
<Box flex="1" width={1} pr={15}>
<div>{artifact.name}</div>
<div>
<small>{this.getTypeName(artifact.type)}</small>
</div>
</Box>
</Flex>
</ResultGridRow>
);
})}
</Collapsable>
</Panel>
);
}
}
| Implement a build artifacts component | feat(artifacts): Implement a build artifacts component
| JSX | apache-2.0 | getsentry/zeus,getsentry/zeus,getsentry/zeus,getsentry/zeus | ---
+++
@@ -0,0 +1,68 @@
+import React, {Component} from 'react';
+import PropTypes from 'prop-types';
+import {Flex, Box} from 'grid-styled';
+
+import Collapsable from './Collapsable';
+import Panel from './Panel';
+import ResultGridHeader from './ResultGridHeader';
+import ResultGridRow from './ResultGridRow';
+
+export default class ArtifactsList extends Component {
+ static propTypes = {
+ artifacts: PropTypes.arrayOf(PropTypes.object).isRequired,
+ collapsable: PropTypes.bool,
+ maxVisible: PropTypes.number
+ };
+
+ static defaultProps = {
+ collapsable: false
+ };
+
+ constructor(props, context) {
+ super(props, context);
+ this.state = {collapsable: props.collapsable};
+ }
+
+ getTypeName(type) {
+ if (!type) {
+ return '';
+ }
+
+ return type
+ .toLowerCase()
+ .replace(/^.|_+[^_]/g, txt => ' ' + txt.slice(-1).toUpperCase())
+ .replace(/_/g, '');
+ }
+
+ render() {
+ return (
+ <Panel>
+ <ResultGridHeader>
+ <Flex align="center">
+ <Box flex="1" width={1} pr={15}>
+ File
+ </Box>
+ </Flex>
+ </ResultGridHeader>
+ <Collapsable
+ collapsable={this.props.collapsable}
+ maxVisible={this.props.maxVisible}>
+ {this.props.artifacts.map(artifact => {
+ return (
+ <ResultGridRow key={artifact.id}>
+ <Flex align="center">
+ <Box flex="1" width={1} pr={15}>
+ <div>{artifact.name}</div>
+ <div>
+ <small>{this.getTypeName(artifact.type)}</small>
+ </div>
+ </Box>
+ </Flex>
+ </ResultGridRow>
+ );
+ })}
+ </Collapsable>
+ </Panel>
+ );
+ }
+} |
|
8e0c229b4c19739868faaa5493e87e4c20945456 | src/js/components/TaskFileLinkComponent.jsx | src/js/components/TaskFileLinkComponent.jsx | var React = require("react/addons");
var classNames = require("classnames");
var MesosActions = require("../actions/MesosActions");
var MesosEvents = require("../events/MesosEvents");
var MesosStore = require("../stores/MesosStore");
function matchFileName(name) {
return (file) => file.name === name;
}
var TaskFileLinkComponent = React.createClass({
displayName: "TaskFileLinkComponent",
propTypes: {
children: React.PropTypes.node,
classNames: React.PropTypes.string,
name: React.PropTypes.string.isRequired,
task: React.PropTypes.object.isRequired
},
getInitialState: function () {
return {
file: null,
requested: false
};
},
componentWillMount: function () {
MesosStore.on(MesosEvents.CHANGE, this.onMesosChange);
},
componentWillUnmount: function () {
MesosStore.removeListener(MesosEvents.CHANGE, this.onMesosChange);
},
onMesosChange: function () {
var props = this.props;
var task = props.task;
var taskId = task.id || task.taskId;
var files = MesosStore.getTaskFiles(taskId);
if (files) {
var file = files.filter(matchFileName(props.name))[0];
// Download link if file was requested by the user
if (this.state.requested) {
window.open(file.download);
}
this.setState({
file: file,
requested: false
});
}
},
handleClick: function () {
var file = this.state.file;
if (file == null) {
var task = this.props.task;
var agentId = task.slaveId;
var taskId = task.id || task.taskId;
MesosActions.requestTaskFiles(agentId, taskId);
this.setState({
requested: true
});
return;
}
window.open(file.download);
},
render: function () {
var className = classNames(this.props.classNames, {
"loading": this.state.requested
});
return (<a className={className} onClick={this.handleClick}>
{this.props.children}
</a>);
}
});
module.exports = TaskFileLinkComponent;
| Add task file link component | Add task file link component
| JSX | apache-2.0 | mesosphere/marathon-ui,cribalik/marathon-ui,cribalik/marathon-ui,mesosphere/marathon-ui | ---
+++
@@ -0,0 +1,79 @@
+var React = require("react/addons");
+var classNames = require("classnames");
+
+var MesosActions = require("../actions/MesosActions");
+var MesosEvents = require("../events/MesosEvents");
+var MesosStore = require("../stores/MesosStore");
+
+function matchFileName(name) {
+ return (file) => file.name === name;
+}
+
+var TaskFileLinkComponent = React.createClass({
+ displayName: "TaskFileLinkComponent",
+ propTypes: {
+ children: React.PropTypes.node,
+ classNames: React.PropTypes.string,
+ name: React.PropTypes.string.isRequired,
+ task: React.PropTypes.object.isRequired
+ },
+
+ getInitialState: function () {
+ return {
+ file: null,
+ requested: false
+ };
+ },
+
+ componentWillMount: function () {
+ MesosStore.on(MesosEvents.CHANGE, this.onMesosChange);
+ },
+
+ componentWillUnmount: function () {
+ MesosStore.removeListener(MesosEvents.CHANGE, this.onMesosChange);
+ },
+
+ onMesosChange: function () {
+ var props = this.props;
+ var task = props.task;
+ var taskId = task.id || task.taskId;
+ var files = MesosStore.getTaskFiles(taskId);
+ if (files) {
+ var file = files.filter(matchFileName(props.name))[0];
+ // Download link if file was requested by the user
+ if (this.state.requested) {
+ window.open(file.download);
+ }
+ this.setState({
+ file: file,
+ requested: false
+ });
+ }
+ },
+
+ handleClick: function () {
+ var file = this.state.file;
+ if (file == null) {
+ var task = this.props.task;
+ var agentId = task.slaveId;
+ var taskId = task.id || task.taskId;
+ MesosActions.requestTaskFiles(agentId, taskId);
+ this.setState({
+ requested: true
+ });
+ return;
+ }
+ window.open(file.download);
+ },
+
+ render: function () {
+ var className = classNames(this.props.classNames, {
+ "loading": this.state.requested
+ });
+ return (<a className={className} onClick={this.handleClick}>
+ {this.props.children}
+ </a>);
+ }
+});
+
+module.exports = TaskFileLinkComponent; |
|
80b13039a3697b3d0e8aabb57d7f0bdb066ea46f | client/views/app.jsx | client/views/app.jsx | /** @jsx React.DOM */
module("views/app", function(require) {
var Tracks = require("views/tracks").TrackList;
var Queue = require("views/queue").Queue;
var App = React.createClass({
getInitialState: function() {
return {currentPanel: 0, queueUpdated: false};
},
componentDidMount: function() {
this.props.queue.on("add" , this.onAddedTrack);
},
onAddedTrack: function() {
this.getDOMNode().querySelector("header a")
.addEventListener("animationend", this.onAnimationEnd);
this.setState({
currentPanel: this.state.currentPanel,
queueUpdated: true
});
},
onAnimationEnd: function() {
this.getDOMNode().querySelector("header a")
.removeEventListener("animationend", this.onAnimationEnd);
this.setState({
currentPanel: this.state.currentPanel,
queueUpdated: false
});
},
togglePanel: function(event) {
event.preventDefault();
this.setState({
currentPanel: (this.state.currentPanel + 1) % 2,
queueUpdated: this.state.queueUpdated
});
},
current: function() {
return this.state.currentPanel;
},
render: function() {
var player = this.props.player;
var queue = this.props.queue;
var tracks = this.props.tracks;
var className = React.addons.classSet({
'fa': true,
'fa-3x': true,
'fa-play': (this.state.currentPanel == 0),
'fa-list': (this.state.currentPanel == 1),
'animated': true,
'wobble': this.state.queueUpdated
});
var title = (this.state.currentPanel == 0) ? "Tracks" : "Queue";
return (
<section role="region">
<header className="fixed">
<menu type="toolbar">
<a href="#" className={className} onClick={this.togglePanel}>
</a>
</menu>
<h1>{title}</h1>
</header>
<Panels current={this.current}>
<Tracks queue={queue} tracks={tracks} player={player}/>
<Queue player={player} queue={queue}/>
</Panels>
</section>
);
}
});
var Panels = React.createClass({
render: function() {
return (
<article className="scrollable header">{
React.Children.map(this.props.children, function(panel, i) {
panel.props.active = (i === this.props.current());
return panel;
}.bind(this))
}</article>
);
}
});
return App;
});
| Implement the root App view | Implement the root App view
| JSX | agpl-3.0 | tOkeshu/GhettoBlaster,tOkeshu/GhettoBlaster | ---
+++
@@ -0,0 +1,92 @@
+/** @jsx React.DOM */
+
+module("views/app", function(require) {
+ var Tracks = require("views/tracks").TrackList;
+ var Queue = require("views/queue").Queue;
+
+ var App = React.createClass({
+ getInitialState: function() {
+ return {currentPanel: 0, queueUpdated: false};
+ },
+
+ componentDidMount: function() {
+ this.props.queue.on("add" , this.onAddedTrack);
+ },
+
+ onAddedTrack: function() {
+ this.getDOMNode().querySelector("header a")
+ .addEventListener("animationend", this.onAnimationEnd);
+ this.setState({
+ currentPanel: this.state.currentPanel,
+ queueUpdated: true
+ });
+ },
+
+ onAnimationEnd: function() {
+ this.getDOMNode().querySelector("header a")
+ .removeEventListener("animationend", this.onAnimationEnd);
+ this.setState({
+ currentPanel: this.state.currentPanel,
+ queueUpdated: false
+ });
+ },
+
+ togglePanel: function(event) {
+ event.preventDefault();
+ this.setState({
+ currentPanel: (this.state.currentPanel + 1) % 2,
+ queueUpdated: this.state.queueUpdated
+ });
+ },
+
+ current: function() {
+ return this.state.currentPanel;
+ },
+
+ render: function() {
+ var player = this.props.player;
+ var queue = this.props.queue;
+ var tracks = this.props.tracks;
+ var className = React.addons.classSet({
+ 'fa': true,
+ 'fa-3x': true,
+ 'fa-play': (this.state.currentPanel == 0),
+ 'fa-list': (this.state.currentPanel == 1),
+ 'animated': true,
+ 'wobble': this.state.queueUpdated
+ });
+ var title = (this.state.currentPanel == 0) ? "Tracks" : "Queue";
+
+ return (
+ <section role="region">
+ <header className="fixed">
+ <menu type="toolbar">
+ <a href="#" className={className} onClick={this.togglePanel}>
+ </a>
+ </menu>
+ <h1>{title}</h1>
+ </header>
+ <Panels current={this.current}>
+ <Tracks queue={queue} tracks={tracks} player={player}/>
+ <Queue player={player} queue={queue}/>
+ </Panels>
+ </section>
+ );
+ }
+ });
+
+ var Panels = React.createClass({
+ render: function() {
+ return (
+ <article className="scrollable header">{
+ React.Children.map(this.props.children, function(panel, i) {
+ panel.props.active = (i === this.props.current());
+ return panel;
+ }.bind(this))
+ }</article>
+ );
+ }
+ });
+
+ return App;
+}); |
|
f643f6e42d40fe05cd367b689c87f2551261de9e | src/components/register-in-contest/register-screenshots.jsx | src/components/register-in-contest/register-screenshots.jsx | "use strict";
import $ from "jquery";
import React from "react";
import _ from "lodash";
import DeepLinkedStateMixin from "react-deep-link-state";
import { ButtonInput, Input } from "react-bootstrap";
import FormMixin from "../../mixins/form"
require("blueimp-file-upload");
export default React.createClass({
displayName: "RegisterFinish",
componentDidMount() {
$('#fileupload').fileupload({
dataType: 'json',
headers: {
Authorization: this.props.access_token
},
add: function (e, data) {
data.context = $('<p/>').text('Uploading...').appendTo(document.body);
data.submit();
},
done: function (e, data) {
data.context.text('Upload finished.');
}
});
},
render() {
let url = window.config.API_URL + this.props.formEndpoint;
return <input id="fileupload" type="file" name="files[]" data-url={url} multiple />
}
});
| Add screenshot tentative implementation 2 | Add screenshot tentative implementation 2
| JSX | mit | palcu/infoeducatie-ui,infoeducatie/infoeducatie-ui,infoeducatie/infoeducatie-ui,palcu/infoeducatie-ui,infoeducatie/infoeducatie-ui,palcu/infoeducatie-ui | ---
+++
@@ -0,0 +1,36 @@
+"use strict";
+
+import $ from "jquery";
+import React from "react";
+import _ from "lodash";
+import DeepLinkedStateMixin from "react-deep-link-state";
+import { ButtonInput, Input } from "react-bootstrap";
+
+import FormMixin from "../../mixins/form"
+
+require("blueimp-file-upload");
+
+export default React.createClass({
+ displayName: "RegisterFinish",
+
+ componentDidMount() {
+ $('#fileupload').fileupload({
+ dataType: 'json',
+ headers: {
+ Authorization: this.props.access_token
+ },
+ add: function (e, data) {
+ data.context = $('<p/>').text('Uploading...').appendTo(document.body);
+ data.submit();
+ },
+ done: function (e, data) {
+ data.context.text('Upload finished.');
+ }
+ });
+ },
+
+ render() {
+ let url = window.config.API_URL + this.props.formEndpoint;
+ return <input id="fileupload" type="file" name="files[]" data-url={url} multiple />
+ }
+}); |
|
dd9c4c577ffbc258ada22a90d04be1a65198880c | photoshop.jsx | photoshop.jsx | #target photoshop
var PSLayerUtil = function() {
this._colorRef = new ActionReference();
this._colorRef.putEnumerated(charIDToTypeID('Lyr '), charIDToTypeID('Ordn'), charIDToTypeID('Trgt'));
}
PSLayerUtil.LayerColors = {
Red: 'Rd ',
Orange: 'Orng',
Yellow: 'Ylw ',
Green: 'Grn ',
Blue: 'Bl ',
Violet: 'Vlt ',
Gray: 'Gry ',
None: 'None',
};
PSLayerUtil.prototype = {
_colorRef: null,
setLayerColor: function(layerColor) {
var colorDescriptor = new ActionDescriptor();
colorDescriptor.putEnumerated(charIDToTypeID('Clr '), charIDToTypeID('Clr '), charIDToTypeID(layerColor));
var desc = new ActionDescriptor();
desc.putReference(charIDToTypeID('null'), this._colorRef);
desc.putObject(charIDToTypeID('T '), charIDToTypeID('Lyr '), colorDescriptor);
executeAction(charIDToTypeID('setd'), desc, DialogModes.NO);
return this.layerColor();
},
layerColor: function() {
var desc = executeActionGet(this._colorRef);
var charID = typeIDToCharID(desc.getEnumerationValue(charIDToTypeID('Clr ')));
for(var key in PSLayerUtil.LayerColors) {
var value = PSLayerUtil.LayerColors[key];
if(value === charID) return key;
}
return 'None';
},
}
| Create Photoshop layer util class. | Create Photoshop layer util class.
| JSX | mit | mazgi/Anice | ---
+++
@@ -0,0 +1,38 @@
+#target photoshop
+
+var PSLayerUtil = function() {
+ this._colorRef = new ActionReference();
+ this._colorRef.putEnumerated(charIDToTypeID('Lyr '), charIDToTypeID('Ordn'), charIDToTypeID('Trgt'));
+}
+PSLayerUtil.LayerColors = {
+ Red: 'Rd ',
+ Orange: 'Orng',
+ Yellow: 'Ylw ',
+ Green: 'Grn ',
+ Blue: 'Bl ',
+ Violet: 'Vlt ',
+ Gray: 'Gry ',
+ None: 'None',
+};
+PSLayerUtil.prototype = {
+ _colorRef: null,
+ setLayerColor: function(layerColor) {
+ var colorDescriptor = new ActionDescriptor();
+ colorDescriptor.putEnumerated(charIDToTypeID('Clr '), charIDToTypeID('Clr '), charIDToTypeID(layerColor));
+ var desc = new ActionDescriptor();
+ desc.putReference(charIDToTypeID('null'), this._colorRef);
+ desc.putObject(charIDToTypeID('T '), charIDToTypeID('Lyr '), colorDescriptor);
+ executeAction(charIDToTypeID('setd'), desc, DialogModes.NO);
+ return this.layerColor();
+ },
+ layerColor: function() {
+ var desc = executeActionGet(this._colorRef);
+ var charID = typeIDToCharID(desc.getEnumerationValue(charIDToTypeID('Clr ')));
+ for(var key in PSLayerUtil.LayerColors) {
+ var value = PSLayerUtil.LayerColors[key];
+ if(value === charID) return key;
+ }
+ return 'None';
+ },
+}
+ |
|
ed5695de6ff6a8e4e77346bdfddbaebd57d55c93 | assets/js/components/organisms/SurveyQuestion.jsx | assets/js/components/organisms/SurveyQuestion.jsx | import React, { Component, PropTypes } from 'react'
import {
Well,
Input
} from 'react-bootstrap'
import {
selectSurveyQuestionResponse
} from './../../redux/survey/survey-actions'
class SurveyQuestion extends Component {
makeSelection(questionId, answer, event) {
this.props.dispatch(selectSurveyQuestionResponse(questionId, answer))
}
getValue(answer) {
if (this.props.question.selectedAnswer === answer.id) {
return 'on'
}
}
render() {
return (
<section>
{
<Well>
<label>{this.props.question.questionText}</label>
{
this.props.question.answers.map(answer => {
return (
<Input
checked={this.getValue.call(this, answer)}
onClick={this.makeSelection.bind(this, this.props.question.id, answer)}
type="radio"
label={answer.answerLabel} />
)
})
}
</Well>
}
</section>
)
}
}
SurveyQuestion.propTypes = {
question: PropTypes.object,
dispatch: PropTypes.func
}
export default SurveyQuestion
| import React, { Component, PropTypes } from 'react'
import {
Well,
Input
} from 'react-bootstrap'
import {
selectSurveyQuestionResponse
} from './../../redux/survey/survey-actions'
class SurveyQuestion extends Component {
makeSelection(questionId, answer, event) {
this.props.dispatch(selectSurveyQuestionResponse(questionId, answer))
}
getChecked(answer) {
return this.props.question.selectedAnswer === answer.id
}
render() {
return (
<section>
{
<Well>
<label>{this.props.question.questionText}</label>
{
this.props.question.answers.map(answer => {
return (
<Input
checked={this.getChecked.call(this, answer)}
onClick={this.makeSelection.bind(this, this.props.question.id, answer)}
type="radio"
label={answer.answerLabel} />
)
})
}
</Well>
}
</section>
)
}
}
SurveyQuestion.propTypes = {
question: PropTypes.object,
dispatch: PropTypes.func
}
export default SurveyQuestion
| Simplify function that checks if the radio button is checked on. | Simplify function that checks if the radio button is checked on.
| JSX | mit | wbprice/okcandidate,kmcurry/okcandidate,Code4HR/okcandidate,stanzheng/okcandidate | ---
+++
@@ -15,10 +15,8 @@
this.props.dispatch(selectSurveyQuestionResponse(questionId, answer))
}
- getValue(answer) {
- if (this.props.question.selectedAnswer === answer.id) {
- return 'on'
- }
+ getChecked(answer) {
+ return this.props.question.selectedAnswer === answer.id
}
render() {
@@ -31,7 +29,7 @@
this.props.question.answers.map(answer => {
return (
<Input
- checked={this.getValue.call(this, answer)}
+ checked={this.getChecked.call(this, answer)}
onClick={this.makeSelection.bind(this, this.props.question.id, answer)}
type="radio"
label={answer.answerLabel} /> |
246eb0c7a5a70b4e1f4d688169d3f77a72dda968 | client/source/components/User/NotificationsListEntry.jsx | client/source/components/User/NotificationsListEntry.jsx | import React, {Component} from 'react';
import { Grid, Row, Col, Badge, Glyphicon, FormControl, Button } from 'react-bootstrap';
export default ({user, text, handleUserClick}) => {
return (
<Row height={50} style={{borderBottom: "1px solid rgba(128,128,128, 0.2)"}}>
<Col xs={2} md={2}>
<h2 > <Glyphicon glyph="certificate" bsSize="large"/> </h2>
</Col>
<Col xs={10} md={10} >
<h4 id={user} onClick={handleUserClick.bind(this)}> {`@${user} ${text}`} </h4>
</Col>
</Row>
)
}
| Implement new NotificationListEntry component to dispaly of new notification response parameter. | Implement new NotificationListEntry component to dispaly of new notification response parameter.
| JSX | mit | JAC-Labs/SkilletHub,JAC-Labs/SkilletHub | ---
+++
@@ -0,0 +1,16 @@
+import React, {Component} from 'react';
+import { Grid, Row, Col, Badge, Glyphicon, FormControl, Button } from 'react-bootstrap';
+
+export default ({user, text, handleUserClick}) => {
+
+ return (
+ <Row height={50} style={{borderBottom: "1px solid rgba(128,128,128, 0.2)"}}>
+ <Col xs={2} md={2}>
+ <h2 > <Glyphicon glyph="certificate" bsSize="large"/> </h2>
+ </Col>
+ <Col xs={10} md={10} >
+ <h4 id={user} onClick={handleUserClick.bind(this)}> {`@${user} ${text}`} </h4>
+ </Col>
+ </Row>
+ )
+} |
|
9ec9164b943e29971e4d5a886d1cc34808049db8 | packages/richtext/src/components/StyleButton.jsx | packages/richtext/src/components/StyleButton.jsx | import React from 'react'
import IconButton from 'material-ui/IconButton'
import compose from 'recompose/compose'
import mapProps from 'recompose/mapProps'
import { injectButtonStyles } from './EditorStyles'
const preventDefault = event => event.preventDefault()
const wrapPrevent = callback =>
(event) => {
event.preventDefault()
callback()
}
const StyleButton = ({
styles,
onTouchTap,
children,
...other
}) =>
<IconButton
iconStyle={styles.icon}
style={styles.button}
onTouchTap={onTouchTap}
onMouseDown={preventDefault}
{...other}
>
{React.cloneElement(children, {
color: styles.color,
hoverColor: styles.focusColor,
})}
</IconButton>
export default compose(
injectButtonStyles,
mapProps(({
toggleStyle,
inlineStyle,
children,
styles,
...other
}) => ({
styles,
onTouchTap: wrapPrevent(() => toggleStyle(inlineStyle)),
children,
...other,
}))
)(StyleButton)
| import React from 'react'
import IconButton from 'material-ui/IconButton'
import compose from 'recompose/compose'
import mapProps from 'recompose/mapProps'
import { injectButtonStyles } from './EditorStyles'
const preventDefault = event => event.preventDefault()
const wrapPrevent = callback =>
(event) => {
event.preventDefault()
callback()
}
const StyleButton = ({
styles,
onTouchTap,
children,
...other
}) =>
<IconButton
iconStyle={styles.icon}
style={styles.button}
onTouchTap={onTouchTap}
onMouseDown={preventDefault}
{...other}
>
{React.cloneElement(children, {
color: styles.color,
hoverColor: styles.focusColor,
})}
</IconButton>
export default compose(
injectButtonStyles,
mapProps(({
toggleStyle,
inlineStyle,
children,
styles,
focused, // eslint-disable-line no-unused-vars
theme, // eslint-disable-line no-unused-vars
prepareStyles, // eslint-disable-line no-unused-vars
...other
}) => ({
styles,
onTouchTap: wrapPrevent(() => toggleStyle(inlineStyle)),
children,
...other,
}))
)(StyleButton)
| Refactor DraftEditor to use JSS | Refactor DraftEditor to use JSS
| JSX | mit | mindhivenz/packages,mindhivenz/packages | ---
+++
@@ -39,6 +39,9 @@
inlineStyle,
children,
styles,
+ focused, // eslint-disable-line no-unused-vars
+ theme, // eslint-disable-line no-unused-vars
+ prepareStyles, // eslint-disable-line no-unused-vars
...other
}) => ({
styles, |
b3268abb70089615494ede43e293db865eb51e12 | t/compile_error/074.assign-to-const-member.todo.jsx | t/compile_error/074.assign-to-const-member.todo.jsx | class Test {
static const STATIC_VAR = "static";
const INSTANCE_VAR = "instance";
static function run() : void {
Test.STATIC_VAR = "new value";
(new Test()).INSTANCE_VAR + "new value";
}
}
| Add a TODO test to prevent to set values to const properties | Add a TODO test to prevent to set values to const properties
| JSX | mit | jsx/JSX,mattn/JSX,jsx/JSX,mattn/JSX,dj31416/JSX,dj31416/JSX,jsx/JSX,dj31416/JSX,jsx/JSX,dj31416/JSX,jsx/JSX,dj31416/JSX | ---
+++
@@ -0,0 +1,10 @@
+class Test {
+ static const STATIC_VAR = "static";
+ const INSTANCE_VAR = "instance";
+
+ static function run() : void {
+ Test.STATIC_VAR = "new value";
+ (new Test()).INSTANCE_VAR + "new value";
+ }
+}
+ |
|
fcfae1331facd23095e007e3b3095c42a735b7c7 | src/app.jsx | src/app.jsx | /**
* @jsx React.DOM
*/
'use strict';
var React = require('react');
var {Routes, Route} = require('react-router');
React.renderComponent(
<Routes location="history">
<Route name="app" path="/" handler={require('./layouts/Default')}>
<Route name="home" path="/" handler={require('./pages/Home')} />
<Route name="privacy" handler={require('./pages/Privacy')} />
</Route>
</Routes>,
document.body
);
| /**
* @jsx React.DOM
*/
'use strict';
var React = require('react');
var {Routes, Route} = require('react-router');
// Export React so the devtools can find it
(window !== window.top ? window.top : window).React = React;
React.renderComponent(
<Routes location="history">
<Route name="app" path="/" handler={require('./layouts/Default')}>
<Route name="home" path="/" handler={require('./pages/Home')} />
<Route name="privacy" handler={require('./pages/Privacy')} />
</Route>
</Routes>,
document.body
);
| Add support of React Dev Tools | Add support of React Dev Tools
| JSX | mit | aaandrew/website,tlin108/chaf,schnerd/react-starter-kit,ZoeyYoung/react-starter-kit,alexmasselot/medlineGeoWebFrontend,sloppylopez/react-starter-kit,alexmasselot/react-starter-kit,f15gdsy/react-starter-kit,HoomanGriz/react-starter-kit,zbrukas/wwf-store,domenicosolazzo/react-starter-kit,piscis/react-starter-kit,cabouffard/MusicServer-Frontend,swhite24/react-starter-kit,jshultz/secret_project,jackinf/skynda.me,patrickkillalea/React1,sdiaz/react-starter-kit,arkeros/react-native-starter-kit,wanchopen/vida,johnrenko/React,lycandjava/react-starter-kit,dstirling/MyApp,LukevdPalen/react-starter-kit,quasicrial/quasicrial,nobesnickr/react-starter-kit,uiruson/chorongi,victoryancn/react-starter-kit,chytanya/microcredentials-client,bopeng87/reactfullstack,nicolasmoise/CMC-2,seriallos/react-starter-kit-minimal,jesperh/tuho2.0-react,danielxiaowxx/react-starter-kit,arolla/Arollydays,como-quesito/react-starter-kit,jeffreymoya/react-starter-kit,0xcdc/rfb-client-app,DanielHabib/HowManyBalloons,SillyKnight/react-starter-kit,SFDevLabs/react-starter-kit,FOUfashion/frontend,saadanerdetbare/react-starter-kit,HoomanGriz/react-starter-kit,maximhoffman/beginnertuts,garposmack/react-starter-kit,tcrosen/nhl-scores,petarslovic/bas-info,geoffreyfloyd/op,p-a/react-starter-kit,leeleo26/react-starter-kit,Hawt-Lava/Flare,louisukiri/react-starter-kit,devonzuegel/cosmocat,vanbujm/react-css-animation-practice,Malinin88/SaratovJS,TribeMedia/react-starter-kit,Nikhil22/trooper,mlem8/dev-challenge,srslafazan/react-profile-starter,TCotton/penny-books,rdanieldesign/MemoryApp-ReactStarter,bigwaterconsulting/to_dash_live,N4N0/resume,pandoraui/react-starter,quyetvv/react-starter-kit,epylinkn/monument,DanielHabib/react-starter-kit,jurgob/jurgo.me,davidascher/needinfo,dstirling/MyApp,ADourgarian/Syscoin-Payroll,Jose4gg/GSW-P2,sjackson212/A6DotCom,mDinner/musicansAssistant,neozhangthe1/react-starter-kit,kevinob11/react-test,nambawan/g-old,cmosguy/react-redux-auth0,grantgeorge/react-app,nextinnovation-corp/gacha,companyjuice/react-starter-kit,jeffreymoya/react-starter-kit,clickbuster/smite-calculator,Hawt-Lava/Flare,devinschulz/react-starter-kit,arkeros/react-native-starter-kit,luznlun/kkRoom,ryanherlihy/react-starter-kit,globalART19/OrderedOptions,emil-alexandrescu/react-starter-kit,SlexAxton/oddjobsf,johnrenko/React,zerkz/react-portfolio,teosz/test-problem-reproduce,zerkz/react-portfolio,taylorharwin/react-starter-kit,pvijeh/peter-vijeh-personal-site,phoenixbox/vesty-fe,SindreSvendby/beach-ranking-web,roskom/MyApp,zsu13579/pinterest-apollo,zsu13579/whatsgoinontonight,nithinpeter/nightpecker,alexbonine/react-starter-kit,ademuk/react-starter-kit,SlexAxton/oddjobsf,scele/coverigate,jbsouvestre/react-starter-kit,mDinner/musicansAssistant,sloppylopez/react-starter-kit,ronlobo/react-starter-kit,Shtian/dashboard,TCotton/penny-books,dirkliu/react-starter-kit,jacyzon/react-starter-kit,leeleo26/react-starter-kit,youprofit/react-starter-kit,tonikarttunen/tonikarttunen-com,patrickkillalea/react-starter-kit,pvijeh/isomorphic-react-local-discovery,HildoBijl/DondersHackathonTR,benbs/Office-Player,Jose4gg/GSW-P2,aaron-goshine/react-starter-kit,aos2006/tesDeploy,vbdoug/ISOReStack,SOCLE15/carpoule,epylinkn/monument,SFDevLabs/react-starter-kit,fsad/react-starter-kit,AlexKhymenko/ES6React,scele/coverigate,bez4pieci/React-Flux-Drag-n-Drop-Tree-structure,jackygrahamez/react-starter-kit,maysale01/react-starter-kit,ryanherlihy/react-starter-kit,nagyistoce/react-starter-kit,p-a/react-starter-kit,avaneeshd/spotnote-web,alexmasselot/react-starter-kit,solome/react-starter-kit,petarslovic/bas-info,sammccord/Rhetorizer,maysale01/react-starter-kit,fkn/ndo,cuitianze/demo,murphysierra/VinnyStoryPage,ziedAb/PVMourakiboun,neozhangthe1/react-starter-kit,eafelix/react-starter-kit,labreaks/ep-web-app,soniwgithub/react-starter-kit,epicallan/akilihub,zbrukas/wwf-store,langpavel/react-starter-kit,agiron123/react-starter-kit-TDDOList,mzgnr/react-starter-kit,tcrosen/nhl-scores,eafelix/react-starter-kit,MxMcG/tourlookup-react,alexmasselot/medlineGeoWebFrontend,Creatrixino/react-starter-kit,w01fgang/react-starter-kit,cheapsteak/react-starter-kit,tholapz/react-starter-kit,fustic/here-hackaton,jerrysdesign/pac,KantanGroup/zuzu-sites,epicallan/akilihub,erichardson30/react-starter,goatslacker/react-starter-kit,i3ringit/mdelc,kaushik94/react-starter,djfm/ps-translations-interface-mockup,jsDotCr/memory,loganfreeman/react-is-fun,cheapsteak/react-starter-kit,mortenryum/loanCalculator,solome/react-starter-kit,splashapp/starterkit,theopak/alright,mithundas79/react-starter-kit,chentaixu/react-starter-kit,jurgob/jurgo.me,jacyzon/react-starter-kit,kaynenh/ReactBudget,khankuan/asset-library-demo,arolla/Arollydays,sallen450/react-starter-kit,iteacat/cc_deals,shaunstanislaus/react-starter-kit,siddhant3s/crunchgraph,alexbonine/react-starter-kit,jerrysdesign/pac,sammccord/Rhetorizer,youprofit/react-starter-kit,Demesheo/react-starter-kit,tarkanlar/eskimo,samkguerrero/samkguerrero_react,gokberkisik/react-starter-kit,DanielHabib/onboarding,mikemunsie/react-starter-kit,DanielHabib/onboarding,skw/test-react-backbone,janusnic/react-starter-kit,syarul/react-starter-kit,prthrokz/portfolio,vanbujm/react-css-animation-practice,allfix53/react-starter-kit,DVLP/react-starter-kit,pppp22591558/ChinaPromotion,bpeters/nafcweb,vanessadyce/react-proto,aos2006/tesDeploy,emil-alexandrescu/react-starter-kit,seriflafont/react-starter-kit,sdiaz/react-starter-kit,juliocanares/react-starter-kit,sonbui00/react-starter-kit,yjzzcao/react-starter-kit,jbsouvestre/react-starter-kit,vishwanatharondekar/resume,dkmin/react-starter-kit,jshultz/secret_project,jsivakumaran/map-app,DenisIzmaylov/react-starter-kit,avaneeshd/spotnote-web,lycandjava/react-starter-kit,dbkbali/react-starter-kit,rameshrr/dicomviewer,shaialon/react-starter-kit,jsDotCr/memory,uptive/react-starter-kit,LukevdPalen/react-starter-kit,nlipsyc/reactbot3,aries-auto/ariesautomotive,splashapp/starterkit,dongtong/react-starter-kit,emil-alexandrescu/react-starter-kit,fkn/ndo,soniwgithub/react-starter-kit,teosz/test-problem-reproduce,pppp22591558/ChinaPromotion,DVLP/react-starter-kit,BlakeRxxk/react-starter-kit,pawsong/react-starter-kit,ubien/react-starter-kit,daviferreira/react-starter-kit,sherlock221/react-starter-kit,pvijeh/isomorphic-react-local-discovery,amyalichkin/react-starter-kit,chytanya/microcredentials-client,carlosCeron/react-starter-kit,brian-kilpatrick/react-starter-kit,soma06-2/soma06-2-web-client,juliocanares/react-starter-kit,nicolasmoise/CMC-2,suttonj/topshelf-flux,soma06-2/soma06-2-web-client,victoryancn/react-starter-kit,mlem8/dev-challenge,domenicosolazzo/react-starter-kit,cineindustria/site,daviferreira/react-starter-kit,clickbuster/smite-calculator,BrettHoyer/fatwithfriends,aalluri-navaratan/react-starter-kit,artemkaint/react-starter-kit,chen844033231/react-starter-kit,dirkliu/react-starter-kit,eugeneross/react-starter-kit,jsivakumaran/map-app,pandoraui/react-starter,Skoli-Code/DerangeonsLaChambre,jessamynsmith/MintWebApp,Fedulab/FeduLab,Lanciv/reporting-front,dervos/react-starter-kit,swhite24/react-starter-kit,waelio/react-starter-kit,jifeon/react-starter-kit,DaveyEdwards/myiworlds,Bogdaan/react-auth-kit,ben-miller/adddr.io,akfreas/ReactTest,rdanieldesign/MemoryApp-ReactStarter,saadanerdetbare/react-starter-kit,DanielHabib/react-starter-kit,albperezbermejo/react-starter-kit,takahashik/todo-app,pvijeh/stock-tracking-app-reactjs,devinschulz/react-starter-kit,carlosCeron/react-starter-kit,agiron123/react-starter-kit-TDDOList,pppp22591558/pa_course_lobby,bopeng87/reactfullstack,tcrosen/react-vehicle-builder,barretts/react-starter-kit,bez4pieci/React-Flux-Drag-n-Drop-Tree-structure,Fedulab/FeduLab,DanielHabib/HowManyBalloons,theopak/alright,concerned3rdparty/react-starter-kit,seriallos/react-starter-kit-minimal,monotonique/react-starter-kit,shaialon/react-starter-kit,N4N0/resume,ademuk/react-starter-kit,vbauerster/react-starter-kit,labzero/lunch,Shtian/dashboard,cthorne66/react-cards,vbdoug/ISOReStack,jessamynsmith/MintWebApp,mattroid/turboiep,barretts/react-starter-kit,mimiflynn/react-starter-kit,BrettHoyer/fatwithfriends,ynu/res-track-wxe,Frenzzy/react-starter-kit,rodolfo2488/react-starter-kit,Speak-Easy/web-app,bbonny/movie-matching,skw/test-react-backbone,fustic/here-hackaton,nicolasmoise/QH-code-exercize,Frenzzy/react-starter-kit,0xcdc/rfb-client-app,pawsong/react-starter-kit,aalluri-navaratan/react-starter-kit,jhabdas/lumpenradio-com,zhiyelee/react-starter-kit,koistya/react-starter-kit,zhiyelee/react-starter-kit,patrickkillalea/React1,rodolfo2488/react-starter-kit,yinaw/travelBook,Malinin88/SaratovJS,ajhsu/react-starter-kit,SillyKnight/react-starter-kit,nlipsyc/reactbot3,sallen450/react-starter-kit,prathamtandon/portfolio,royriojas/react-starter-kit,allfix53/react-starter-kit,jaruesink/ruesinkdds,iamfrontender/resume,shaunstanislaus/react-starter-kit,grantgeorge/react-app,miketamis/CaughtHere,bsy/react-starter-kit,pvijeh/sull-isom2,BrianGenisio/gobus,dkmin/react-starter-kit,larsvinter/react-starter-kit,piscis/react-starter-kit,seriflafont/react-starter-kit,pitLancer/pbdorb,keshavnandan/react-starter-kit,edgarallanglez/foxacademia_frontend,djfm/ps-translations-interface-mockup,BenRichter/app2,companyjuice/react-starter-kit,hang-up/react-whatever,taylorharwin/react-starter-kit,ZoeyYoung/react-starter-kit,0xcdc/rfb-client-app,4lbertoC/popularrepositories,kaushik94/react-starter,SindreSvendby/beach-ranking-web,eugeneross/react-starter-kit,seanlin816/react-starter-kit,w01fgang/react-starter-kit,nagyistoce/react-starter-kit,miketamis/locationPositioning,janusnic/react-starter-kit,Creatrixino/react-starter-kit,sherlock221/react-starter-kit,pppp22591558/pa_course_lobby,prthrokz/portfolio,arolla/Arollydays,BringJacket/www,dervos/react-starter-kit,schnerd/react-starter-kit,monotonique/react-starter-kit,frob/react-starter-kit-lite,Mobiletainment/react-starter-kit,gokberkisik/react-starter-kit,vanessadyce/react-proto,hang-up/react-whatever,kevinchau321/TReactr,kuao775/mandragora,larsvinter/react-starter-kit,nextinnovation-corp/gacha,aaron-goshine/react-starter-kit,ronlobo/react-starter-kit,Nexapp/react-starter-kit,mithundas79/react-starter-kit,loganfreeman/react-is-fun,ACPK/react-starter-kit,DanielHabib/HowManyBalloons,benbs/Office-Player,miketamis/locationPositioning,ashlynbaum/react-test,pvijeh/peter-vijeh-personal-site,artemkaint/react-starter-kit,geoffreyfloyd/op,mikemunsie/react-starter-kit,cthorne66/react-cards,patrickkillalea/react-starter-kit,concerned3rdparty/react-starter-kit,andmilj/vip-transfers,liangsenzhi/react-starter-kit,mortenryum/loanCalculator,vbauerster/react-starter-kit,tinwaisi/take-home,seanlin816/react-starter-kit,keshavnandan/react-starter-kit,nobesnickr/react-starter-kit,thesyllable/wom2,zmj1316/InfomationVisualizationCourseWork,servak/material-ui-sample,vishwanatharondekar/resume,yjzzcao/react-starter-kit,miketamis/CaughtHere,ajhsu/react-starter-kit,chentaixu/react-starter-kit,ashlynbaum/react-test,bpeters/nafcweb,Gabs00/react-starter-kit,tonikarttunen/tonikarttunen-com,jtiscione/redux-chess,stinkyfingers/IsoTest,elyseko/wereperson,f15gdsy/react-starter-kit,RenRenTeam/react-starter-kit,bogdosarov/link_share,tholapz/react-starter-kit,tstangenberg/apitest-editor,erichardson30/react-starter,mimiflynn/react-starter-kit,uiruson/chorongi,AlexKhymenko/ES6React,jesperh/tuho2.0-react,Shtian/hnmm,dbkbali/react-starter-kit,andmilj/vip-transfers,trus-sangwarn/react-starter,dabrowski-adam/react-isomorphic,BringJacket/www,cuitianze/demo,pvijeh/sull-isom2,maysale01/react-platform,TodoWishlist/TodoWishlist,kinshuk-jain/TB-Dfront,wseo88/react-starter-kit,srslafazan/react-profile-starter,cabouffard/MusicServer-Frontend,royriojas/react-starter-kit,jwhchambers/react-starter-kit,BlakeRxxk/react-starter-kit,TribeMedia/react-starter-kit,liangsenzhi/react-starter-kit,albperezbermejo/react-starter-kit,tomesposito/blog,danielxiaowxx/react-starter-kit,frob/react-starter-kit-lite,arkeros/react-native-starter-kit,dongtong/react-starter-kit,fsad/react-starter-kit,mattroid/turboiep,takahashik/todo-app,ubien/react-starter-kit,labreaks/ep-web-app,ynu/ecard-wxe,aaandrew/website,trus-sangwarn/react-starter,Gabs00/react-starter-kit,prathamtandon/portfolio,amyalichkin/react-starter-kit,thesyllable/wom2,wseo88/react-starter-kit,kutou/react-starter-kit,vlad06/react-starter-kit,onelink-translations/react-localization,roskom/MyApp,BrianGenisio/gobus,stinkyfingers/IsoTest,vladikoff/react-starter-kit,nlipsyc/reactbot3,como-quesito/react-starter-kit,tstangenberg/apitest-editor,waelio/react-starter-kit,yinaw/travelBook,jifeon/react-starter-kit,nicolascine/site,mzgnr/react-starter-kit,bsy/react-starter-kit,phoenixbox/vesty-fe,DenisIzmaylov/react-starter-kit,garposmack/react-starter-kit,buildbreakdo/react-starter-kit,poeschko/ask-refugeescode,maysale01/react-platform,akfreas/ReactTest,nithinpeter/nightpecker,zerubeus/voicifix,chen844033231/react-starter-kit,iteacat/cc_deals,Mobiletainment/react-starter-kit,maximhoffman/beginnertuts,iamfrontender/resume,vladikoff/react-starter-kit,binyuace/vote,RenRenTeam/react-starter-kit,servak/material-ui-sample,vlad06/react-starter-kit,4lbertoC/popularrepositories,Speak-Easy/web-app,loganfreeman/react-is-fun,suttonj/topshelf-flux,bogdosarov/link_share,RomanovRoman/react-starter-kit,tarkanlar/eskimo,nicolasmoise/QH-code-exercize,jhlav/mpn-web-app,pvijeh/stock-tracking-app-reactjs,nambawan/g-old,gdi2290/react-starter-kit,ACPK/react-starter-kit,egut/react-docker-demo,sonbui00/react-starter-kit,tcrosen/react-vehicle-builder,Demesheo/react-starter-kit,samdenicola/react-starter-kit,AntonyKwok/react-starter-kit,jhabdas/lumpenradio-com,tomesposito/blog,syarul/react-starter-kit | ---
+++
@@ -6,6 +6,9 @@
var React = require('react');
var {Routes, Route} = require('react-router');
+
+// Export React so the devtools can find it
+(window !== window.top ? window.top : window).React = React;
React.renderComponent(
<Routes location="history"> |
1372bb05de9d528806ef28bd4892d4e99af1a9dd | app/components/index.jsx | app/components/index.jsx | var React = require('react');
var ReactDom = require('react-dom');
var App = React.createClass({
render: function() {
return (
<div>
<h1>Hello from Shiver!</h1>
<a href="/auth/twitch">Login</a>
</div>
);
}
});
ReactDom.render(<App/>, document.getElementById('app'));
| Add a test React component. | Add a test React component.
| JSX | mit | bryanveloso/shiver-electron,bryanveloso/shiver-electron | ---
+++
@@ -0,0 +1,15 @@
+var React = require('react');
+var ReactDom = require('react-dom');
+
+var App = React.createClass({
+ render: function() {
+ return (
+ <div>
+ <h1>Hello from Shiver!</h1>
+ <a href="/auth/twitch">Login</a>
+ </div>
+ );
+ }
+});
+
+ReactDom.render(<App/>, document.getElementById('app')); |
|
694ef9bca95669e500bcb1af57c666ac79995fbd | components/org.wso2.carbon.business.rules.web/src/components/auth/Constants.jsx | components/org.wso2.carbon.business.rules.web/src/components/auth/Constants.jsx | /*
* Copyright (c) 2019, 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, { Component } from 'react';
export const Constants = {
AUTH_TYPE_UNKNOWN: 'unknown',
AUTH_TYPE_DEFAULT: 'default',
AUTH_TYPE_SSO: 'sso',
// Cookies
REFRESH_TOKEN_COOKIE: 'PRT',
ID_TOKEN_COOKIE: 'ORT',
USER_DTO_COOKIE: 'USER_DTO',
SESSION_USER_COOKIE: 'BR_USER',
REFERRER_KEY: 'referrer',
};
| Add constants related to sso login for BR's | Add constants related to sso login for BR's
| JSX | apache-2.0 | wso2/carbon-analytics,wso2/carbon-analytics,wso2/carbon-analytics,wso2/carbon-analytics,wso2/carbon-analytics | ---
+++
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2019, 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, { Component } from 'react';
+
+export const Constants = {
+ AUTH_TYPE_UNKNOWN: 'unknown',
+ AUTH_TYPE_DEFAULT: 'default',
+ AUTH_TYPE_SSO: 'sso',
+
+ // Cookies
+ REFRESH_TOKEN_COOKIE: 'PRT',
+ ID_TOKEN_COOKIE: 'ORT',
+ USER_DTO_COOKIE: 'USER_DTO',
+ SESSION_USER_COOKIE: 'BR_USER',
+
+ REFERRER_KEY: 'referrer',
+}; |
|
32d32f4120e6b2f6671a16c5d8599213e96086f6 | src/app/views/datasets-new/edit-metadata/DatasetReviewActions.jsx | src/app/views/datasets-new/edit-metadata/DatasetReviewActions.jsx | import React, { Component } from 'react';
import PropTypes from 'prop-types';
const propTypes = {
disabled: PropTypes.bool,
reviewState: PropTypes.string,
userEmail: PropTypes.string.isRequired,
lastEditedBy: PropTypes.string,
onSubmit: PropTypes.func,
onApprove: PropTypes.func,
notInCollectionYet: PropTypes.bool
};
class DatasetReviewActions extends Component {
constructor(props) {
super(props);
}
renderSubmit() {
return (
<button id="submit-for-review" type="button" onClick={this.props.onSubmit} disabled={this.props.disabled} className="btn btn--positive margin-right--1">
Save and submit for review
</button>
)
}
renderApprove() {
return (
<button id="mark-as-reviewed" type="button" onClick={this.props.onApprove} disabled={this.props.disabled} className="btn btn--positive margin-right--1">
Save and submit for approval
</button>
)
}
render() {
if (this.props.reviewState === "reviewed") {
return <span></span>;
}
if (this.props.notInCollectionYet || this.props.reviewState === "inProgress") {
return this.renderSubmit();
}
if (this.props.userEmail === this.props.lastEditedBy && this.props.reviewState === "complete") {
return this.renderSubmit();
}
if (this.props.userEmail !== this.props.lastEditedBy && this.props.reviewState === "complete") {
return this.renderApprove();
}
return <span></span>;
}
}
DatasetReviewActions.propTypes = propTypes;
export default DatasetReviewActions; | Add dataset review actions component | Add dataset review actions component
| JSX | mit | ONSdigital/florence,ONSdigital/florence,ONSdigital/florence,ONSdigital/florence | ---
+++
@@ -0,0 +1,59 @@
+import React, { Component } from 'react';
+import PropTypes from 'prop-types';
+
+const propTypes = {
+ disabled: PropTypes.bool,
+ reviewState: PropTypes.string,
+ userEmail: PropTypes.string.isRequired,
+ lastEditedBy: PropTypes.string,
+ onSubmit: PropTypes.func,
+ onApprove: PropTypes.func,
+ notInCollectionYet: PropTypes.bool
+};
+
+class DatasetReviewActions extends Component {
+ constructor(props) {
+ super(props);
+ }
+
+ renderSubmit() {
+ return (
+ <button id="submit-for-review" type="button" onClick={this.props.onSubmit} disabled={this.props.disabled} className="btn btn--positive margin-right--1">
+ Save and submit for review
+ </button>
+ )
+ }
+
+ renderApprove() {
+ return (
+ <button id="mark-as-reviewed" type="button" onClick={this.props.onApprove} disabled={this.props.disabled} className="btn btn--positive margin-right--1">
+ Save and submit for approval
+ </button>
+ )
+ }
+
+ render() {
+ if (this.props.reviewState === "reviewed") {
+ return <span></span>;
+ }
+
+ if (this.props.notInCollectionYet || this.props.reviewState === "inProgress") {
+ return this.renderSubmit();
+ }
+
+ if (this.props.userEmail === this.props.lastEditedBy && this.props.reviewState === "complete") {
+ return this.renderSubmit();
+ }
+
+ if (this.props.userEmail !== this.props.lastEditedBy && this.props.reviewState === "complete") {
+ return this.renderApprove();
+ }
+
+ return <span></span>;
+
+ }
+}
+
+DatasetReviewActions.propTypes = propTypes;
+
+export default DatasetReviewActions; |
|
8e385439aabb602b43f76d6d2735ddb94b9d0fcb | client/app/lib/helpers/railsNotificationBar.jsx | client/app/lib/helpers/railsNotificationBar.jsx | import React from 'react';
import { render } from 'react-dom';
import ProviderWrapper from 'lib/components/ProviderWrapper';
import NotificationBar from 'lib/components/NotificationBar';
import { getOrCreateNode } from 'lib/helpers/railsHelpers';
// Renders a react notification bar with the given message.
function renderNotificationBar(id, message) {
const mountNode = getOrCreateNode(id);
render(
<ProviderWrapper>
<NotificationBar
notification={{ message }}
/>
</ProviderWrapper>
, mountNode
);
}
export default renderNotificationBar;
| Implement a helper to render notification bar through normal javascript | Implement a helper to render notification bar through normal javascript
| JSX | mit | Coursemology/coursemology2,Coursemology/coursemology2,cysjonathan/coursemology2,Coursemology/coursemology2,Coursemology/coursemology2,cysjonathan/coursemology2,Coursemology/coursemology2,Coursemology/coursemology2,cysjonathan/coursemology2,Coursemology/coursemology2 | ---
+++
@@ -0,0 +1,20 @@
+import React from 'react';
+import { render } from 'react-dom';
+import ProviderWrapper from 'lib/components/ProviderWrapper';
+import NotificationBar from 'lib/components/NotificationBar';
+import { getOrCreateNode } from 'lib/helpers/railsHelpers';
+
+// Renders a react notification bar with the given message.
+function renderNotificationBar(id, message) {
+ const mountNode = getOrCreateNode(id);
+ render(
+ <ProviderWrapper>
+ <NotificationBar
+ notification={{ message }}
+ />
+ </ProviderWrapper>
+ , mountNode
+ );
+}
+
+export default renderNotificationBar; |
|
7f4bd8b33daab2faf910d488f82787d4c355a708 | src/js/components/DuplicableRowControls.jsx | src/js/components/DuplicableRowControls.jsx | var React = require("react/addons");
var DuplicableRowControls = React.createClass({
displayName: "DuplicableRowControls",
propTypes: {
handleAddRow: React.PropTypes.func.isRequired,
handleRemoveRow: React.PropTypes.func.isRequired
},
render: function () {
return (
<div className="controls">
<button className="btn btn-link remove"
onClick={this.props.handleRemoveRow}>
<i className="icon ion-ios-minus-outline"/>
<i className="icon icon-hover ion-ios-minus"/>
</button>
<button className="btn btn-link add" onClick={this.props.handleAddRow}>
<i className="icon ion-ios-plus-outline"/>
<i className="icon icon-hover ion-ios-plus"/>
</button>
</div>
);
}
});
module.exports = DuplicableRowControls;
| var classNames = require("classnames");
var React = require("react/addons");
var DuplicableRowControls = React.createClass({
displayName: "DuplicableRowControls",
propTypes: {
disableRemoveButton: React.PropTypes.bool,
handleAddRow: React.PropTypes.func.isRequired,
handleRemoveRow: React.PropTypes.func.isRequired
},
render: function () {
var props = this.props;
var removeButtonClassSet = classNames({
"btn btn-link remove": true,
"disabled": props.disableRemoveButton
});
return (
<div className="controls">
<button className={removeButtonClassSet}
onClick={this.props.handleRemoveRow}>
<i className="icon ion-ios-minus-outline"/>
<i className="icon icon-hover ion-ios-minus"/>
</button>
<button className="btn btn-link add" onClick={this.props.handleAddRow}>
<i className="icon ion-ios-plus-outline"/>
<i className="icon icon-hover ion-ios-plus"/>
</button>
</div>
);
}
});
module.exports = DuplicableRowControls;
| Allow setting disabled on remove button | Allow setting disabled on remove button | JSX | apache-2.0 | Raffo/marathon-ui,mesosphere/marathon-ui,mesosphere/marathon-ui,cribalik/marathon-ui,cribalik/marathon-ui,Raffo/marathon-ui | ---
+++
@@ -1,15 +1,24 @@
+var classNames = require("classnames");
var React = require("react/addons");
var DuplicableRowControls = React.createClass({
displayName: "DuplicableRowControls",
propTypes: {
+ disableRemoveButton: React.PropTypes.bool,
handleAddRow: React.PropTypes.func.isRequired,
handleRemoveRow: React.PropTypes.func.isRequired
},
render: function () {
+ var props = this.props;
+
+ var removeButtonClassSet = classNames({
+ "btn btn-link remove": true,
+ "disabled": props.disableRemoveButton
+ });
+
return (
<div className="controls">
- <button className="btn btn-link remove"
+ <button className={removeButtonClassSet}
onClick={this.props.handleRemoveRow}>
<i className="icon ion-ios-minus-outline"/>
<i className="icon icon-hover ion-ios-minus"/> |
00576f83fdd62c9398052c8c6de4fdb60edc1038 | src/react-chayns-gallery/component/Gallery.jsx | src/react-chayns-gallery/component/Gallery.jsx | import React from 'react';
import PropTypes from 'prop-types';
import MoreImages from './MoreImages';
import ImageContainer from './ImageContainer';
export default class Gallery extends React.Component {
static propTypes = {
urls: PropTypes.array.isRequired,
height: PropTypes.number,
width: PropTypes.number,
onlyIcon: PropTypes.bool,
onClick: PropTypes.func
};
static defaultProps = {
height: 0,
width: 0,
onlyIcon: false,
onClick: chayns.openImage
};
constructor(){
super();
this.openFirstImage = this.openGallery.bind(this, 0);
this.openSecondImage = this.openGallery.bind(this, 1);
this.openThirdImage = this.openGallery.bind(this, 2);
}
openGallery(start) {
this.props.onClick(this.props.urls, start);
}
render() {
const { urls, height, width, onlyIcon } = this.props;
const count = urls.length;
return (
<div className="chayns-gallery" style={{ height: height ? `${height}px` : '100%', width: width ? `${width}px` : '100%' }}>
<ImageContainer
className="image-container image-container--big"
url={urls[0]}
onClick={this.openFirstImage}
/>
{count === 2 ?
<ImageContainer
className="image-container image-container--big"
url={urls[1]}
onClick={this.openSecondImage}
/>
: ''
}
{count >= 3 ?
<div className="wrapper" >
{count >= 3 ?
<div >
<ImageContainer
className="image-container image-container--small"
url={urls[1]}
onClick={this.openSecondImage}
/>
<ImageContainer
className="image-container image-container--small"
url={urls[2]}
onClick={this.openThirdImage}
>
{count > 3 ?
<MoreImages
count={count - 3}
onlyIcon={onlyIcon}
/> : ''
}
</ImageContainer>
</div>
: ''
}
</div> : ''
}
</div>
);
}
}
| Create base component for gallery | Create base component for gallery
| JSX | mit | TobitSoftware/chayns-components,TobitSoftware/chayns-components,TobitSoftware/chayns-components | ---
+++
@@ -0,0 +1,82 @@
+import React from 'react';
+import PropTypes from 'prop-types';
+import MoreImages from './MoreImages';
+import ImageContainer from './ImageContainer';
+
+export default class Gallery extends React.Component {
+ static propTypes = {
+ urls: PropTypes.array.isRequired,
+ height: PropTypes.number,
+ width: PropTypes.number,
+ onlyIcon: PropTypes.bool,
+ onClick: PropTypes.func
+
+ };
+ static defaultProps = {
+ height: 0,
+ width: 0,
+ onlyIcon: false,
+ onClick: chayns.openImage
+ };
+
+ constructor(){
+ super();
+ this.openFirstImage = this.openGallery.bind(this, 0);
+ this.openSecondImage = this.openGallery.bind(this, 1);
+ this.openThirdImage = this.openGallery.bind(this, 2);
+
+ }
+
+ openGallery(start) {
+ this.props.onClick(this.props.urls, start);
+ }
+
+ render() {
+ const { urls, height, width, onlyIcon } = this.props;
+ const count = urls.length;
+
+ return (
+ <div className="chayns-gallery" style={{ height: height ? `${height}px` : '100%', width: width ? `${width}px` : '100%' }}>
+ <ImageContainer
+ className="image-container image-container--big"
+ url={urls[0]}
+ onClick={this.openFirstImage}
+ />
+ {count === 2 ?
+ <ImageContainer
+ className="image-container image-container--big"
+ url={urls[1]}
+ onClick={this.openSecondImage}
+ />
+ : ''
+ }
+ {count >= 3 ?
+ <div className="wrapper" >
+ {count >= 3 ?
+ <div >
+ <ImageContainer
+ className="image-container image-container--small"
+ url={urls[1]}
+ onClick={this.openSecondImage}
+ />
+ <ImageContainer
+ className="image-container image-container--small"
+ url={urls[2]}
+ onClick={this.openThirdImage}
+ >
+ {count > 3 ?
+ <MoreImages
+ count={count - 3}
+ onlyIcon={onlyIcon}
+ /> : ''
+ }
+ </ImageContainer>
+ </div>
+ : ''
+ }
+ </div> : ''
+ }
+ </div>
+ );
+ }
+} |
|
9f4619f0295af10e209b5a029fd813a60d862332 | SingularityUI/app/components/dashboard/MyStarredRequests.jsx | SingularityUI/app/components/dashboard/MyStarredRequests.jsx | import React, { PropTypes } from 'react';
import { connect } from 'react-redux';
import { Row, Col } from 'react-bootstrap';
import UITable from '../common/table/UITable';
import { Starred, RequestId, Type, LastDeploy, DeployUser, State } from '../requests/Columns';
import * as RequestsSelectors from '../../selectors/requests';
const MyStarredRequests = ({starredRequests}) => {
let starredRequestsSection = (
<div className="empty-table-message"><p>No starred requests</p></div>
);
if (starredRequests.length > 0) {
starredRequestsSection = (
<UITable
data={starredRequests}
keyGetter={(r) => r.request.id}
asyncSort={true}
paginated={true}
rowChunkSize={10}
>
{Starred}
{RequestId}
{Type}
{LastDeploy}
{DeployUser}
{State}
</UITable>
);
}
return (
<Row>
<Col md={12} className="table-staged">
<div className="page-header">
<h2>Starred requests</h2>
</div>
{starredRequestsSection}
</Col>
</Row>
);
};
MyStarredRequests.propTypes = {
starredRequests: PropTypes.arrayOf(PropTypes.object).isRequired,
};
const mapStateToProps = (state) => {
return {
starredRequests: RequestsSelectors.getStarredRequests(state)
};
};
export default connect(
mapStateToProps
)(MyStarredRequests);
| import React, { PropTypes } from 'react';
import { connect } from 'react-redux';
import { Row, Col } from 'react-bootstrap';
import UITable from '../common/table/UITable';
import { Starred, RequestId, Type, LastDeploy, State, DeployUser, Instances } from '../requests/Columns';
import * as RequestsSelectors from '../../selectors/requests';
const MyStarredRequests = ({starredRequests}) => {
let starredRequestsSection = (
<div className="empty-table-message"><p>No starred requests</p></div>
);
if (starredRequests.length > 0) {
starredRequestsSection = (
<UITable
data={starredRequests}
keyGetter={(r) => r.request.id}
asyncSort={true}
paginated={true}
rowChunkSize={10}
>
{Starred}
{RequestId}
{Type}
{LastDeploy}
{State}
{DeployUser}
{Instances}
</UITable>
);
}
return (
<Row>
<Col md={12} className="table-staged">
<div className="page-header">
<h2>Starred requests</h2>
</div>
{starredRequestsSection}
</Col>
</Row>
);
};
MyStarredRequests.propTypes = {
starredRequests: PropTypes.arrayOf(PropTypes.object).isRequired,
};
const mapStateToProps = (state) => {
return {
starredRequests: RequestsSelectors.getStarredRequests(state)
};
};
export default connect(
mapStateToProps
)(MyStarredRequests);
| Add instances back to the starred requests table, and revert order of Status and Deploy User | Add instances back to the starred requests table, and revert order of Status and Deploy User
| JSX | apache-2.0 | hs-jenkins-bot/Singularity,hs-jenkins-bot/Singularity,andrhamm/Singularity,HubSpot/Singularity,andrhamm/Singularity,hs-jenkins-bot/Singularity,hs-jenkins-bot/Singularity,andrhamm/Singularity,HubSpot/Singularity,HubSpot/Singularity,andrhamm/Singularity,hs-jenkins-bot/Singularity,HubSpot/Singularity,andrhamm/Singularity,HubSpot/Singularity | ---
+++
@@ -4,7 +4,7 @@
import { Row, Col } from 'react-bootstrap';
import UITable from '../common/table/UITable';
-import { Starred, RequestId, Type, LastDeploy, DeployUser, State } from '../requests/Columns';
+import { Starred, RequestId, Type, LastDeploy, State, DeployUser, Instances } from '../requests/Columns';
import * as RequestsSelectors from '../../selectors/requests';
@@ -26,8 +26,9 @@
{RequestId}
{Type}
{LastDeploy}
+ {State}
{DeployUser}
- {State}
+ {Instances}
</UITable>
);
} |
0c3505c1656946c89d6a01fecd1e36ec32e29e9a | src/js/components/__tests__/spinner.spec.jsx | src/js/components/__tests__/spinner.spec.jsx | import React from 'react';
import { shallow } from 'enzyme';
import { Spinner } from '../';
describe('Spinner', () => {
const shallowRender = () => shallow(<Spinner />);
it('should render without throwing an error', () => {
const component = shallowRender();
expect(component.find('.spinner').length).not.toEqual(0);
});
it('should call focus when componentDidMount is called', () => {
const
component = shallowRender(),
instance = component.instance(),
focusMock = jest.fn();
instance.spinner = { focus: focusMock };
instance.componentDidMount();
expect(focusMock).toHaveBeenCalled();
});
it('should set spinner to null', () => {
const component = shallowRender();
expect(component.instance().spinner).toEqual(null);
});
it('should set spinner to passed in element when refHandler is called', () => {
const
component = shallowRender(),
instance = component.instance(),
fakeElement = 'TEST';
instance.refHandler(fakeElement);
expect(instance.spinner).toEqual(fakeElement);
});
});
| Add test coverage to Spinner component | Add test coverage to Spinner component
| JSX | mit | CarlaCrandall/React-Calendar,CarlaCrandall/React-Calendar | ---
+++
@@ -0,0 +1,39 @@
+import React from 'react';
+import { shallow } from 'enzyme';
+import { Spinner } from '../';
+
+describe('Spinner', () => {
+ const shallowRender = () => shallow(<Spinner />);
+
+ it('should render without throwing an error', () => {
+ const component = shallowRender();
+ expect(component.find('.spinner').length).not.toEqual(0);
+ });
+
+ it('should call focus when componentDidMount is called', () => {
+ const
+ component = shallowRender(),
+ instance = component.instance(),
+ focusMock = jest.fn();
+
+ instance.spinner = { focus: focusMock };
+ instance.componentDidMount();
+
+ expect(focusMock).toHaveBeenCalled();
+ });
+
+ it('should set spinner to null', () => {
+ const component = shallowRender();
+ expect(component.instance().spinner).toEqual(null);
+ });
+
+ it('should set spinner to passed in element when refHandler is called', () => {
+ const
+ component = shallowRender(),
+ instance = component.instance(),
+ fakeElement = 'TEST';
+
+ instance.refHandler(fakeElement);
+ expect(instance.spinner).toEqual(fakeElement);
+ });
+}); |
|
c7a2b43d6ae423671d43334bc4c059f30d76abee | ditto/static/js/components/LeftRightAlign.jsx | ditto/static/js/components/LeftRightAlign.jsx | var React = require('react');
var LeftRightAlign = React.createClass({
render: function () {
var left = React.cloneElement(this.props.children[0], {style: {float: 'left'}});
var right = React.cloneElement(this.props.children[1], {style: {float: 'right'}});
return (
<div className="clearfix">
{left} {right}
</div>
);
}
});
module.exports = LeftRightAlign;
| Add component to left and right align some text | Add component to left and right align some text
| JSX | bsd-3-clause | Kvoti/ditto,Kvoti/ditto,Kvoti/ditto,Kvoti/ditto,Kvoti/ditto | ---
+++
@@ -0,0 +1,15 @@
+var React = require('react');
+
+var LeftRightAlign = React.createClass({
+ render: function () {
+ var left = React.cloneElement(this.props.children[0], {style: {float: 'left'}});
+ var right = React.cloneElement(this.props.children[1], {style: {float: 'right'}});
+ return (
+ <div className="clearfix">
+ {left} {right}
+ </div>
+ );
+ }
+});
+
+module.exports = LeftRightAlign; |
|
c47567dbef87e429bf41e918b4b8da773c6821de | imports/ui/components/appState.jsx | imports/ui/components/appState.jsx | import React, { Component } from 'react';
import { PropTypes } from 'prop-types';
class AppState extends Component {
constructor(props) {
super(props);
this.state = {
error: {},
};
this.setAppState = this.setAppState.bind(this);
}
setAppState(updater, callback) {
// newState can be object or function!
this.setState(updater, () => {
if (this.props.debug) {
console.log('setAppState', JSON.stringify(this.state));
}
if (callback) {
callback();
}
});
}
render() {
return (
<div className="AppState">
{React.Children.map(this.props.children, child =>
React.cloneElement(child, {
appState: this.state,
setAppState: this.setAppState,
}),
)}
</div>
);
}
}
AppState.defaultProps = {
debug: false,
};
AppState.propTypes = {
debug: PropTypes.bool,
children: PropTypes.element.isRequired,
};
export default AppState;
| Add new AppState component for global management states | Add new AppState component for global management states
| JSX | mit | ggallon/rock,ggallon/rock | ---
+++
@@ -0,0 +1,48 @@
+import React, { Component } from 'react';
+import { PropTypes } from 'prop-types';
+
+class AppState extends Component {
+ constructor(props) {
+ super(props);
+ this.state = {
+ error: {},
+ };
+ this.setAppState = this.setAppState.bind(this);
+ }
+
+ setAppState(updater, callback) {
+ // newState can be object or function!
+ this.setState(updater, () => {
+ if (this.props.debug) {
+ console.log('setAppState', JSON.stringify(this.state));
+ }
+ if (callback) {
+ callback();
+ }
+ });
+ }
+
+ render() {
+ return (
+ <div className="AppState">
+ {React.Children.map(this.props.children, child =>
+ React.cloneElement(child, {
+ appState: this.state,
+ setAppState: this.setAppState,
+ }),
+ )}
+ </div>
+ );
+ }
+}
+
+AppState.defaultProps = {
+ debug: false,
+};
+
+AppState.propTypes = {
+ debug: PropTypes.bool,
+ children: PropTypes.element.isRequired,
+};
+
+export default AppState; |
|
67253d3f6bb282cfe5c2354e04bc5ae82ee8cc1a | app/assets/javascripts/components/FixedMenuTemplate.js.jsx | app/assets/javascripts/components/FixedMenuTemplate.js.jsx | var FixedMenuTemplate = React.createClass({
render: function(){
return (
<div className="fixed-menu-template">
<p> <a href="/issues/new"> Submit a New Issue </a> </p>
<p> <a href="/dashboard"> Dashboard </a> </p>
<p> <a href="/discover"> Discover </a> </p>
<p> Log Out </p>
</div>
)
}
})
| Add Fix Menu Template component | Add Fix Menu Template component
| JSX | mit | TimCannady/fixstarter,TimCannady/fixstarter,ShadyLogic/fixstarter,ShadyLogic/fixstarter,TimCannady/fixstarter,ShadyLogic/fixstarter | ---
+++
@@ -0,0 +1,13 @@
+var FixedMenuTemplate = React.createClass({
+
+ render: function(){
+ return (
+ <div className="fixed-menu-template">
+ <p> <a href="/issues/new"> Submit a New Issue </a> </p>
+ <p> <a href="/dashboard"> Dashboard </a> </p>
+ <p> <a href="/discover"> Discover </a> </p>
+ <p> Log Out </p>
+ </div>
+ )
+ }
+}) |
|
0c6cc01ab990382f1fe6970b693c4d3fa0cb79b6 | src/components/link-preview/scroll-helpers/foldable-content.jsx | src/components/link-preview/scroll-helpers/foldable-content.jsx | import React from 'react';
import classnames from 'classnames';
import {ELEMENT_RESIZE_EVENT} from './events';
export default class FoldableContent extends React.Component {
static propTypes = {
maxUnfoldedHeight: React.PropTypes.number.isRequired,
foldedHeight: React.PropTypes.number.isRequired,
};
static defaultProps = {
maxUnfoldedHeight: 550,
foldedHeight: 400,
};
content = null;
state = {
contentHeight: 0,
expanded: false,
};
toggleFold = () => this.setState({expanded: !this.state.expanded});
updateHeight = () => {
const contentHeight = this.content.offsetHeight;
if (contentHeight !== this.state.contentHeight) {
this.setState({contentHeight});
}
}
setContent = (el) => {
if (el) {
el.addEventListener(ELEMENT_RESIZE_EVENT, this.updateHeight);
window.addEventListener('resize', this.updateHeight);
} else if (this.content) {
this.content.removeEventListener(ELEMENT_RESIZE_EVENT, this.updateHeight);
window.removeEventListener('resize', this.updateHeight);
}
this.content = el;
};
render() {
const foldNeeded = this.state.contentHeight > this.props.maxUnfoldedHeight;
const wrapperHeight = (foldNeeded && !this.state.expanded) ? this.props.foldedHeight : this.state.contentHeight;
return (
<div className="folder-container">
<div
className={classnames({'content-wrapper': true, folded: foldNeeded && !this.state.expanded})}
style={{height: wrapperHeight + 'px'}}
>
<div ref={this.setContent}>{this.props.children}</div>
</div>
{foldNeeded ? (
<div className="preview-expand">
<i className={`fa fa-${this.state.expanded ? 'minus' : 'plus'}-square-o`}/>
{' '}
<a onClick={this.toggleFold}>{this.state.expanded ? 'Fold' : 'Expand'} preview</a>
</div>
) : false}
</div>
);
}
}
| Add a component that hide tall content under the “Expand preview” link | Add a component that hide tall content under the “Expand preview” link
| JSX | mit | kadmil/freefeed-react-client,kadmil/freefeed-react-client,FreeFeed/freefeed-react-client,kadmil/freefeed-react-client,davidmz/freefeed-react-client,davidmz/freefeed-react-client,davidmz/freefeed-react-client,FreeFeed/freefeed-react-client,FreeFeed/freefeed-react-client | ---
+++
@@ -0,0 +1,65 @@
+import React from 'react';
+import classnames from 'classnames';
+
+import {ELEMENT_RESIZE_EVENT} from './events';
+
+export default class FoldableContent extends React.Component {
+ static propTypes = {
+ maxUnfoldedHeight: React.PropTypes.number.isRequired,
+ foldedHeight: React.PropTypes.number.isRequired,
+ };
+
+ static defaultProps = {
+ maxUnfoldedHeight: 550,
+ foldedHeight: 400,
+ };
+
+ content = null;
+ state = {
+ contentHeight: 0,
+ expanded: false,
+ };
+
+ toggleFold = () => this.setState({expanded: !this.state.expanded});
+
+ updateHeight = () => {
+ const contentHeight = this.content.offsetHeight;
+ if (contentHeight !== this.state.contentHeight) {
+ this.setState({contentHeight});
+ }
+ }
+
+ setContent = (el) => {
+ if (el) {
+ el.addEventListener(ELEMENT_RESIZE_EVENT, this.updateHeight);
+ window.addEventListener('resize', this.updateHeight);
+ } else if (this.content) {
+ this.content.removeEventListener(ELEMENT_RESIZE_EVENT, this.updateHeight);
+ window.removeEventListener('resize', this.updateHeight);
+ }
+ this.content = el;
+ };
+
+ render() {
+ const foldNeeded = this.state.contentHeight > this.props.maxUnfoldedHeight;
+ const wrapperHeight = (foldNeeded && !this.state.expanded) ? this.props.foldedHeight : this.state.contentHeight;
+
+ return (
+ <div className="folder-container">
+ <div
+ className={classnames({'content-wrapper': true, folded: foldNeeded && !this.state.expanded})}
+ style={{height: wrapperHeight + 'px'}}
+ >
+ <div ref={this.setContent}>{this.props.children}</div>
+ </div>
+ {foldNeeded ? (
+ <div className="preview-expand">
+ <i className={`fa fa-${this.state.expanded ? 'minus' : 'plus'}-square-o`}/>
+ {' '}
+ <a onClick={this.toggleFold}>{this.state.expanded ? 'Fold' : 'Expand'} preview</a>
+ </div>
+ ) : false}
+ </div>
+ );
+ }
+} |
|
874bc8abb944b2b59c163c5abcdf096f9db58c6d | src/app/components/form-error-summary/FormErrorSummary.jsx | src/app/components/form-error-summary/FormErrorSummary.jsx | import React, { Component } from 'react';
import PropTypes from 'prop-types';
const propTypes = {
errors: PropTypes.arrayOf(PropTypes.string)
}
class FormErrorSummary extends Component {
constructor(props) {
super(props);
}
render() {
if (!this.props.errors.length) {
return null;
}
return (
<div className="error-summary" role="alert" aria-labelledby="error-summary-heading">
<h2 id="error-summary-heading">
Errors
</h2>
<p>Before saving please correct the following</p>
<ul className="error-summary__list">
{this.props.errors.map((error, index) => {
return <li key={index} className="error-summary__list-item">{error}</li>
})}
</ul>
</div>
)
}
}
FormErrorSummary.propTypes = propTypes;
export default FormErrorSummary; | Add form error sumamry componeent that lists all errors on a form | Add form error sumamry componeent that lists all errors on a form
| JSX | mit | ONSdigital/florence,ONSdigital/florence,ONSdigital/florence,ONSdigital/florence | ---
+++
@@ -0,0 +1,33 @@
+import React, { Component } from 'react';
+import PropTypes from 'prop-types';
+
+const propTypes = {
+ errors: PropTypes.arrayOf(PropTypes.string)
+}
+
+class FormErrorSummary extends Component {
+ constructor(props) {
+ super(props);
+ }
+ render() {
+ if (!this.props.errors.length) {
+ return null;
+ }
+ return (
+ <div className="error-summary" role="alert" aria-labelledby="error-summary-heading">
+ <h2 id="error-summary-heading">
+ Errors
+ </h2>
+ <p>Before saving please correct the following</p>
+ <ul className="error-summary__list">
+ {this.props.errors.map((error, index) => {
+ return <li key={index} className="error-summary__list-item">{error}</li>
+ })}
+ </ul>
+ </div>
+ )
+ }
+}
+
+FormErrorSummary.propTypes = propTypes;
+export default FormErrorSummary; |
|
7b73c183b466d0a3a74501f2ee33b3e44b587f69 | src/components/lazy-component.jsx | src/components/lazy-component.jsx | import React, { Suspense, useState, useEffect, useMemo } from 'react';
import ErrorBoundary from './error-boundary';
export function DelayedSuspense({ fallback, delay = 500, children }) {
const withDelay = fallback && delay > 0;
const [showFallback, setShowFallback] = useState(!withDelay);
useEffect(() => {
if (!withDelay) {
return;
}
const timeout = setTimeout(() => setShowFallback(true), delay);
return () => clearTimeout(timeout);
}, [delay, withDelay]);
return <Suspense fallback={showFallback && fallback}>{children}</Suspense>;
}
export const lazyComponent = (loader, { fallback, errorMessage, delay }) => (props) => {
// No deps: loader can depends only on the initial props
// eslint-disable-next-line react-hooks/exhaustive-deps
const Lazy = useMemo(() => React.lazy(() => loader(props)), []);
return (
<ErrorBoundary message={errorMessage}>
<DelayedSuspense fallback={fallback} delay={delay}>
<Lazy {...props} />
</DelayedSuspense>
</ErrorBoundary>
);
};
| Add a DelayedSuspense and lazyComponent helpers | Add a DelayedSuspense and lazyComponent helpers
DelayedSuspense makes fallback element visible after some delay (500 ms by default). lazyComponent creates a component via React.lazy and wraps it by DelayedSuspense and ErrorBoundary. | JSX | mit | FreeFeed/freefeed-react-client,FreeFeed/freefeed-react-client,FreeFeed/freefeed-react-client | ---
+++
@@ -0,0 +1,29 @@
+import React, { Suspense, useState, useEffect, useMemo } from 'react';
+import ErrorBoundary from './error-boundary';
+
+export function DelayedSuspense({ fallback, delay = 500, children }) {
+ const withDelay = fallback && delay > 0;
+ const [showFallback, setShowFallback] = useState(!withDelay);
+ useEffect(() => {
+ if (!withDelay) {
+ return;
+ }
+ const timeout = setTimeout(() => setShowFallback(true), delay);
+ return () => clearTimeout(timeout);
+ }, [delay, withDelay]);
+
+ return <Suspense fallback={showFallback && fallback}>{children}</Suspense>;
+}
+
+export const lazyComponent = (loader, { fallback, errorMessage, delay }) => (props) => {
+ // No deps: loader can depends only on the initial props
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ const Lazy = useMemo(() => React.lazy(() => loader(props)), []);
+ return (
+ <ErrorBoundary message={errorMessage}>
+ <DelayedSuspense fallback={fallback} delay={delay}>
+ <Lazy {...props} />
+ </DelayedSuspense>
+ </ErrorBoundary>
+ );
+}; |
|
bce07b396d588cfcc7b10a4275f5002e31d3e6ff | src/DirectChatToggleContactsButton.test.jsx | src/DirectChatToggleContactsButton.test.jsx | import React from 'react';
import { shallow } from 'enzyme';
import BoxToolButton from './BoxToolButton';
import DirectChatToggleContactsButton from './DirectChatToggleContactsButton';
test('DirectChatToggleContactsButton notifies DirectChat when clicked', () => {
let received = false;
const wrapper = shallow(
<DirectChatToggleContactsButton />,
{
context: {
$adminlte_directchat: {
toggleContacts: () => { received = true; },
},
},
},
);
wrapper.find(BoxToolButton).simulate('click');
expect(received).toEqual(true);
});
| Test direct chat toggle button click | Test direct chat toggle button click
| JSX | mit | react-admin-lte/react-admin-lte,react-admin-lte/react-admin-lte,jonmpqts/reactjs-admin-lte | ---
+++
@@ -0,0 +1,22 @@
+import React from 'react';
+import { shallow } from 'enzyme';
+import BoxToolButton from './BoxToolButton';
+import DirectChatToggleContactsButton from './DirectChatToggleContactsButton';
+
+test('DirectChatToggleContactsButton notifies DirectChat when clicked', () => {
+ let received = false;
+
+ const wrapper = shallow(
+ <DirectChatToggleContactsButton />,
+ {
+ context: {
+ $adminlte_directchat: {
+ toggleContacts: () => { received = true; },
+ },
+ },
+ },
+ );
+
+ wrapper.find(BoxToolButton).simulate('click');
+ expect(received).toEqual(true);
+}); |
|
a45b8d4337a2a19c0a0162c00bd2c4d8f75c98c8 | extensions/lite/views/Information/index.jsx | extensions/lite/views/Information/index.jsx | import React, { Component } from 'react'
import {
Row,
Col
} from 'react-bootstrap'
import InformationComponent from '~/components/Information'
import HeroComponent from '~/components/Hero'
class InformationHeroRowComponent extends Component {
render() {
return <Row>
<Col sm={12} md={8}>
<InformationComponent />
</Col>
<Col xs={12} sm={8} md={4} smOffset={2} mdOffset={0}>
<HeroComponent />
</Col>
</Row>
}
}
export default InformationHeroRowComponent
| Create a separate component for lite version | Create a separate component for lite version
| JSX | agpl-3.0 | botpress/botpress,botpress/botpress,botpress/botpress,botpress/botpress | ---
+++
@@ -0,0 +1,25 @@
+import React, { Component } from 'react'
+import {
+ Row,
+ Col
+} from 'react-bootstrap'
+
+import InformationComponent from '~/components/Information'
+import HeroComponent from '~/components/Hero'
+
+class InformationHeroRowComponent extends Component {
+
+ render() {
+ return <Row>
+ <Col sm={12} md={8}>
+ <InformationComponent />
+ </Col>
+ <Col xs={12} sm={8} md={4} smOffset={2} mdOffset={0}>
+ <HeroComponent />
+ </Col>
+ </Row>
+ }
+}
+
+export default InformationHeroRowComponent
+ |
|
c5eda35b432e0ac883751dd260ed62e73910ca3d | src/components/link-preview/scroll-helpers/scroll-safe.jsx | src/components/link-preview/scroll-helpers/scroll-safe.jsx | import React from 'react';
import _ from 'lodash';
import ResizeTracker from './resize-tracker';
import FoldableContent from './foldable-content';
import ScrollCompensator from './scroll-compensator';
/**
* ScrollSafe is a decorator for react classes. It provides:
* 1) automatic scroll compensation for the nested component and
* 2) Fold/Expand UI for the tall content.
*
* ScrollSafe can be used as a decorator:
* @ScrollSafe
* class Foo extends React.Component {
*
* …as a decorator with options:
* @ScrollSafe(options)
* class Foo extends React.Component {
*
* …or as a regular function:
* ScrollSafe(Foo) or ScrollSafe(Foo, options)
*
* Options is a plain object with the following fields:
* * trackResize (true by default) - auto-track resize of the nested content
* * foldable (true by default) - apply Fold/Expand UI for the tall content
*
* When you set 'trackResize' to false you still can manually signal to the
* ScrollSafe wrapper about your component resize - see contentResized() function in 'events.jsx'.
*/
export default function ScrollSafe(arg1, arg2) {
const defaultOptions = {
foldable: true,
trackResize: true,
};
if (_.isPlainObject(arg1)) {
// Call as a decorator with parameters: @ScrollSafe(opts)
return Child => ScrollSafe(Child, arg1);
}
const Child = arg1;
const {foldable, trackResize} = _.assign({}, defaultOptions, arg2);
const foo = function(props) {
let content = <Child {...props}/>;
if (trackResize) {
content = <ResizeTracker>{content}</ResizeTracker>;
}
if (foldable) {
content = <FoldableContent>{content}</FoldableContent>;
}
return <ScrollCompensator>{content}</ScrollCompensator>;
};
foo.displayName = 'ScrollSafe';
return foo;
}
| Add a decorator, combining scroll-related helper components | Add a decorator, combining scroll-related helper components
It combines ResizeTracker, FoldableContent and ScrollCompensator | JSX | mit | davidmz/freefeed-react-client,davidmz/freefeed-react-client,FreeFeed/freefeed-react-client,kadmil/freefeed-react-client,kadmil/freefeed-react-client,FreeFeed/freefeed-react-client,davidmz/freefeed-react-client,FreeFeed/freefeed-react-client,kadmil/freefeed-react-client | ---
+++
@@ -0,0 +1,59 @@
+import React from 'react';
+import _ from 'lodash';
+
+import ResizeTracker from './resize-tracker';
+import FoldableContent from './foldable-content';
+import ScrollCompensator from './scroll-compensator';
+
+/**
+ * ScrollSafe is a decorator for react classes. It provides:
+ * 1) automatic scroll compensation for the nested component and
+ * 2) Fold/Expand UI for the tall content.
+ *
+ * ScrollSafe can be used as a decorator:
+ * @ScrollSafe
+ * class Foo extends React.Component {
+ *
+ * …as a decorator with options:
+ * @ScrollSafe(options)
+ * class Foo extends React.Component {
+ *
+ * …or as a regular function:
+ * ScrollSafe(Foo) or ScrollSafe(Foo, options)
+ *
+ * Options is a plain object with the following fields:
+ * * trackResize (true by default) - auto-track resize of the nested content
+ * * foldable (true by default) - apply Fold/Expand UI for the tall content
+ *
+ * When you set 'trackResize' to false you still can manually signal to the
+ * ScrollSafe wrapper about your component resize - see contentResized() function in 'events.jsx'.
+ */
+export default function ScrollSafe(arg1, arg2) {
+ const defaultOptions = {
+ foldable: true,
+ trackResize: true,
+ };
+
+ if (_.isPlainObject(arg1)) {
+ // Call as a decorator with parameters: @ScrollSafe(opts)
+ return Child => ScrollSafe(Child, arg1);
+ }
+
+ const Child = arg1;
+ const {foldable, trackResize} = _.assign({}, defaultOptions, arg2);
+
+ const foo = function(props) {
+ let content = <Child {...props}/>;
+ if (trackResize) {
+ content = <ResizeTracker>{content}</ResizeTracker>;
+ }
+ if (foldable) {
+ content = <FoldableContent>{content}</FoldableContent>;
+ }
+ return <ScrollCompensator>{content}</ScrollCompensator>;
+ };
+ foo.displayName = 'ScrollSafe';
+
+ return foo;
+}
+ |
|
b6d9feb576f5d34347d1341fc654ea9250624d01 | client/views/tracks.jsx | client/views/tracks.jsx | /** @jsx React.DOM */
module("views/tracks", function(require) {
var MusicTrack = require("models/tracks").Track;
var FileListReader = require("lib/file-list-reader");
var Track = React.createClass({
addToQueue: function() {
this.props.queue.add(this.props.track);
},
render: function() {
return (
<li className="track">
<a href="#" onClick={this.addToQueue}>
<p>{this.props.track.title}</p>
</a>
</li>
);
}
});
var TrackList = React.createClass({
getInitialState: function() {
return {tracks: []};
},
componentDidMount: function() {
this.props.tracks.on("add" , this.onAddedTrack);
},
onAddedTrack: function(track) {
this.setState({tracks: this.props.tracks.slice()});
},
render: function() {
var queue = this.props.queue;
var className = React.addons.classSet({panel: true, current: this.props.active});
return (
<section className={className} data-type="list" data-position="left">
<ul>
{this.state.tracks.map(function(track) {
return <Track track={track} queue={queue}/>;
}.bind(this))}
</ul>
</section>
);
}
});
return {
Track: Track,
TrackList: TrackList
};
});
| Implement the Track and TrackList views | Implement the Track and TrackList views
| JSX | agpl-3.0 | tOkeshu/GhettoBlaster,tOkeshu/GhettoBlaster | ---
+++
@@ -0,0 +1,58 @@
+/** @jsx React.DOM */
+
+module("views/tracks", function(require) {
+ var MusicTrack = require("models/tracks").Track;
+ var FileListReader = require("lib/file-list-reader");
+
+ var Track = React.createClass({
+ addToQueue: function() {
+ this.props.queue.add(this.props.track);
+ },
+
+ render: function() {
+ return (
+ <li className="track">
+ <a href="#" onClick={this.addToQueue}>
+ <p>{this.props.track.title}</p>
+ </a>
+ </li>
+ );
+ }
+ });
+
+ var TrackList = React.createClass({
+ getInitialState: function() {
+ return {tracks: []};
+ },
+
+ componentDidMount: function() {
+ this.props.tracks.on("add" , this.onAddedTrack);
+ },
+
+ onAddedTrack: function(track) {
+ this.setState({tracks: this.props.tracks.slice()});
+ },
+
+ render: function() {
+ var queue = this.props.queue;
+ var className = React.addons.classSet({panel: true, current: this.props.active});
+
+ return (
+ <section className={className} data-type="list" data-position="left">
+ <ul>
+ {this.state.tracks.map(function(track) {
+ return <Track track={track} queue={queue}/>;
+ }.bind(this))}
+ </ul>
+ </section>
+ );
+ }
+ });
+
+ return {
+ Track: Track,
+ TrackList: TrackList
+ };
+});
+
+ |
|
243641236957817912875f67444f4d25a6e80a01 | src/app/components/radio-buttons/RadioList.jsx | src/app/components/radio-buttons/RadioList.jsx | import React, { Component } from "react";
import PropTypes from "prop-types";
import Radio from "./RadioButton";
const propTypes = {
radioData: PropTypes.arrayOf(
PropTypes.shape({
id: PropTypes.string.isRequired,
value: PropTypes.string.isRequired,
label: PropTypes.string.isRequired
})
).isRequired,
legend: PropTypes.string,
groupName: PropTypes.string.isRequired,
onChange: PropTypes.func,
selectedValue: PropTypes.string,
disabled: PropTypes.bool,
showLoadingState: PropTypes.bool
};
export default class RadioList extends Component {
constructor(props) {
super(props);
}
handleChange = event => {
if (this.props.onChange) {
this.props.onChange(event);
}
};
render() {
const radioData = this.props.radioData;
const hasRadioData = radioData.length;
const groupName = this.props.groupName;
const selectedValue = this.props.selectedValue;
const showLoadingState = this.props.showLoadingState;
return (
<div>
{hasRadioData ? (
<fieldset className="fieldset">
{this.props.legend ? <legend className="fieldset__legend">{this.props.legend}</legend> : ""}
<ul className="list list--neutral simple-select-list">
{radioData.map((radio, index) => {
return (
<li key={index} className="simple-select-list__item">
<Radio
inline={false}
key={index}
{...radio}
group={groupName}
onChange={this.handleChange}
checked={selectedValue === radio.value}
disabled={this.props.disabled}
/>
</li>
);
})}
</ul>
</fieldset>
) : null}
{showLoadingState && <span className="margin-top--1 loader loader--dark" />}
{!hasRadioData && !showLoadingState ? <p>Nothing to show</p> : ""}
</div>
);
}
}
RadioList.propTypes = propTypes;
| Add new radio list component | Add new radio list component
| JSX | mit | ONSdigital/florence,ONSdigital/florence,ONSdigital/florence,ONSdigital/florence | ---
+++
@@ -0,0 +1,70 @@
+import React, { Component } from "react";
+import PropTypes from "prop-types";
+import Radio from "./RadioButton";
+
+const propTypes = {
+ radioData: PropTypes.arrayOf(
+ PropTypes.shape({
+ id: PropTypes.string.isRequired,
+ value: PropTypes.string.isRequired,
+ label: PropTypes.string.isRequired
+ })
+ ).isRequired,
+ legend: PropTypes.string,
+ groupName: PropTypes.string.isRequired,
+ onChange: PropTypes.func,
+ selectedValue: PropTypes.string,
+ disabled: PropTypes.bool,
+ showLoadingState: PropTypes.bool
+};
+
+export default class RadioList extends Component {
+ constructor(props) {
+ super(props);
+ }
+
+ handleChange = event => {
+ if (this.props.onChange) {
+ this.props.onChange(event);
+ }
+ };
+
+ render() {
+ const radioData = this.props.radioData;
+ const hasRadioData = radioData.length;
+ const groupName = this.props.groupName;
+ const selectedValue = this.props.selectedValue;
+ const showLoadingState = this.props.showLoadingState;
+
+ return (
+ <div>
+ {hasRadioData ? (
+ <fieldset className="fieldset">
+ {this.props.legend ? <legend className="fieldset__legend">{this.props.legend}</legend> : ""}
+ <ul className="list list--neutral simple-select-list">
+ {radioData.map((radio, index) => {
+ return (
+ <li key={index} className="simple-select-list__item">
+ <Radio
+ inline={false}
+ key={index}
+ {...radio}
+ group={groupName}
+ onChange={this.handleChange}
+ checked={selectedValue === radio.value}
+ disabled={this.props.disabled}
+ />
+ </li>
+ );
+ })}
+ </ul>
+ </fieldset>
+ ) : null}
+ {showLoadingState && <span className="margin-top--1 loader loader--dark" />}
+ {!hasRadioData && !showLoadingState ? <p>Nothing to show</p> : ""}
+ </div>
+ );
+ }
+}
+
+RadioList.propTypes = propTypes; |
|
48e859346ff5158ce4285af3ee4d03a7afeaf917 | webofneeds/won-owner-webapp/src/main/webapp/app/components/details/react-viewer/select-viewer.jsx | webofneeds/won-owner-webapp/src/main/webapp/app/components/details/react-viewer/select-viewer.jsx | import React from "react";
import "~/style/_select-viewer.scss";
import PropTypes from "prop-types";
export default class WonSelectViewer extends React.Component {
render() {
const icon = this.props.detail.icon && (
<svg className="selectv__header__icon">
<use xlinkHref={this.props.detail.icon} href={this.props.detail.icon} />
</svg>
);
const label = this.props.detail.icon && (
<span className="selectv__header__label">{this.props.detail.label}</span>
);
const options =
this.props.detail.options &&
this.props.detail.options.map(option => {
<label className="selectv__input__inner">
<input
className="selectv__input__inner__select"
type={
this.props.detail && this.props.detail.multiSelect
? "checkbox"
: "radio"
}
value={option.value}
disabled="true"
checked={this.isChecked(option)}
/>
{option.label}
</label>;
});
return (
<won-select-viewer>
<div className="selectv__header">
{icon}
{label}
</div>
<div className="selectv__content">{options}</div>
</won-select-viewer>
);
}
isChecked(option) {
return this.content && !!this.content.find(elem => elem === option.value);
}
}
WonSelectViewer.propTypes = {
detail: PropTypes.object,
content: PropTypes.object,
};
| Implement selectviewer as react components | Implement selectviewer as react components
| JSX | apache-2.0 | researchstudio-sat/webofneeds,researchstudio-sat/webofneeds,researchstudio-sat/webofneeds,researchstudio-sat/webofneeds,researchstudio-sat/webofneeds,researchstudio-sat/webofneeds,researchstudio-sat/webofneeds | ---
+++
@@ -0,0 +1,55 @@
+import React from "react";
+
+import "~/style/_select-viewer.scss";
+import PropTypes from "prop-types";
+
+export default class WonSelectViewer extends React.Component {
+ render() {
+ const icon = this.props.detail.icon && (
+ <svg className="selectv__header__icon">
+ <use xlinkHref={this.props.detail.icon} href={this.props.detail.icon} />
+ </svg>
+ );
+
+ const label = this.props.detail.icon && (
+ <span className="selectv__header__label">{this.props.detail.label}</span>
+ );
+
+ const options =
+ this.props.detail.options &&
+ this.props.detail.options.map(option => {
+ <label className="selectv__input__inner">
+ <input
+ className="selectv__input__inner__select"
+ type={
+ this.props.detail && this.props.detail.multiSelect
+ ? "checkbox"
+ : "radio"
+ }
+ value={option.value}
+ disabled="true"
+ checked={this.isChecked(option)}
+ />
+ {option.label}
+ </label>;
+ });
+
+ return (
+ <won-select-viewer>
+ <div className="selectv__header">
+ {icon}
+ {label}
+ </div>
+ <div className="selectv__content">{options}</div>
+ </won-select-viewer>
+ );
+ }
+
+ isChecked(option) {
+ return this.content && !!this.content.find(elem => elem === option.value);
+ }
+}
+WonSelectViewer.propTypes = {
+ detail: PropTypes.object,
+ content: PropTypes.object,
+}; |
|
8452cd1857c074205efc22c81c7dc2e44428bde6 | app/scripts/components/FormFields/ImageUpload.jsx | app/scripts/components/FormFields/ImageUpload.jsx | import React, { PropTypes } from 'react'
import { Field } from 'redux-form';
import ImageFileUploader from 'components/ImageFileUploader';
class ImageUpload extends React.Component {
render() {
const { name, width, height } = this.props;
return (
<Field
name={name}
component={(field) => {
const { input } = field;
return (
<ImageFileUploader
{...input}
width={width}
height={height}
previewURL={input.value.previewURL}
/>
);
}}
/>
);
}
}
export default ImageUpload;
| Add an image upload form field | Add an image upload form field
| JSX | apache-2.0 | rgee/Game-Editor,rgee/Game-Editor | ---
+++
@@ -0,0 +1,27 @@
+import React, { PropTypes } from 'react'
+import { Field } from 'redux-form';
+import ImageFileUploader from 'components/ImageFileUploader';
+
+class ImageUpload extends React.Component {
+ render() {
+ const { name, width, height } = this.props;
+ return (
+ <Field
+ name={name}
+ component={(field) => {
+ const { input } = field;
+ return (
+ <ImageFileUploader
+ {...input}
+ width={width}
+ height={height}
+ previewURL={input.value.previewURL}
+ />
+ );
+ }}
+ />
+ );
+ }
+}
+
+export default ImageUpload; |
|
11eba895e59e7d2faa8307aaf7166b9200bc1396 | js/components/checkTweetNumber.jsx | js/components/checkTweetNumber.jsx | /** @jsx React.DOM */
var CheckTweetNumber = React.createClass({
getInitialState: function() {
return {
checked: false
};
},
handleChange: function(e) {
EventSystem.publish('input.check.show', {
key: "showNumber",
value: e.target.checked
});
this.setState({ checked: e.target.checked });
},
render: function() {
return <label className="checkbox">
<input
type="checkbox"
checked={this.state.checked}
onChange={this.handleChange} />
<span>Show tweet number</span>
</label>;
}
});
React.render(
<CheckTweetNumber />,
document.getElementById("options")
); | Add new component: option check to show the tweet number | Add new component: option check to show the tweet number
| JSX | mit | dburgos/tweet-splitter,dburgos/tweet-splitter | ---
+++
@@ -0,0 +1,31 @@
+/** @jsx React.DOM */
+var CheckTweetNumber = React.createClass({
+ getInitialState: function() {
+ return {
+ checked: false
+ };
+ },
+
+ handleChange: function(e) {
+ EventSystem.publish('input.check.show', {
+ key: "showNumber",
+ value: e.target.checked
+ });
+ this.setState({ checked: e.target.checked });
+ },
+
+ render: function() {
+ return <label className="checkbox">
+ <input
+ type="checkbox"
+ checked={this.state.checked}
+ onChange={this.handleChange} />
+ <span>Show tweet number</span>
+ </label>;
+ }
+});
+
+React.render(
+ <CheckTweetNumber />,
+ document.getElementById("options")
+); |
|
b8facb2cc86ceaf8e63d0f21a6aca32f67616368 | test/client/spec/components/api.spec.jsx | test/client/spec/components/api.spec.jsx | import React from "react/addons";
import API from "src/components/api";
const TestUtils = React.addons.TestUtils;
describe("components/api", function () {
it("renders propType documentation table", function () {
const renderer = TestUtils.createRenderer();
const sourceFake = {
props: {
name: {
name: "propName",
required: false,
type: {
name: "string"
},
description: "Name description\n@examples \"propValue1\"",
defaultValue: {
computed: false,
value: "test"
}
}
}
};
renderer.render(<API source={sourceFake} />);
const output = renderer.getRenderOutput();
expect(output.type).to.equal("table");
});
it("renders default message when proptypes are missing", function () {
const renderer = TestUtils.createRenderer();
const sourceFake = { props: null };
renderer.render(<API source={sourceFake} />);
const output = renderer.getRenderOutput();
expect(output.type).to.equal("em");
});
});
| Add test for API component | Add test for API component
| JSX | mit | aurelienshz/ecology,aurelienshz/ecology,FormidableLabs/ecology,FormidableLabs/ecology | ---
+++
@@ -0,0 +1,43 @@
+import React from "react/addons";
+
+import API from "src/components/api";
+
+const TestUtils = React.addons.TestUtils;
+
+describe("components/api", function () {
+
+ it("renders propType documentation table", function () {
+ const renderer = TestUtils.createRenderer();
+ const sourceFake = {
+ props: {
+ name: {
+ name: "propName",
+ required: false,
+ type: {
+ name: "string"
+ },
+ description: "Name description\n@examples \"propValue1\"",
+ defaultValue: {
+ computed: false,
+ value: "test"
+ }
+ }
+ }
+ };
+ renderer.render(<API source={sourceFake} />);
+
+ const output = renderer.getRenderOutput();
+
+ expect(output.type).to.equal("table");
+ });
+
+ it("renders default message when proptypes are missing", function () {
+ const renderer = TestUtils.createRenderer();
+ const sourceFake = { props: null };
+ renderer.render(<API source={sourceFake} />);
+
+ const output = renderer.getRenderOutput();
+
+ expect(output.type).to.equal("em");
+ });
+}); |
|
8787361bbf9c15acb937e0619f6814d9dd646dd8 | src/app/views/users/UsersController.jsx | src/app/views/users/UsersController.jsx | import React, { Component } from 'react';
import PropTypes from 'prop-types';
// UsersController.propTypes = {
// };
class UsersController extends Component {
render() {
return (
<div className="grid grid--justify-space-around">
<div className="grid__col-4">
<h1>Select a user</h1>
</div>
<div className="grid__col-4">
<h1>Create a user</h1>
</div>
</div>
);
}
}
export default UsersController; | Add basic users controllers component | Add basic users controllers component
| JSX | mit | ONSdigital/florence,ONSdigital/florence,ONSdigital/florence,ONSdigital/florence | ---
+++
@@ -0,0 +1,27 @@
+import React, { Component } from 'react';
+import PropTypes from 'prop-types';
+
+// UsersController.propTypes = {
+
+// };
+
+
+class UsersController extends Component {
+ render() {
+ return (
+ <div className="grid grid--justify-space-around">
+ <div className="grid__col-4">
+ <h1>Select a user</h1>
+ </div>
+
+ <div className="grid__col-4">
+ <h1>Create a user</h1>
+ </div>
+
+ </div>
+ );
+ }
+}
+
+
+export default UsersController; |
|
0f2cc7a349c0e776bd7d3e9a316659a9f1482224 | modules/janeswalk/components/WithLinks.jsx | modules/janeswalk/components/WithLinks.jsx | import React from 'react';
export default ({ children }) => {
const formatted = children.split(/ /).map(word => {
if (word.match(/((([A-Za-z]{3,9}:(?:\/\/)?)(?:[\-;:&=\+\$,\w]+@)?[A-Za-z0-9\.\-]+|(?:www\.|[\-;:&=\+\$,\w]+@)[A-Za-z0-9\.\-]+)((?:\/[\+~%\/\.\w\-_]*)?\??(?:[\-\+=&;%@\.\w_]*)#?(?:[\.\!\/\\\w]*))?)/)) {
return <a href={word.includes('http') ? word : `http://${word}`} target="_blank">{word} </a>;
}
return `${word} `;
});
return (
<p>
{formatted}
</p>
);
};
| Add module to put links into text | Add module to put links into text
| JSX | mit | jkoudys/janeswalk-web,jkoudys/janeswalk-web,jkoudys/janeswalk-web | ---
+++
@@ -0,0 +1,16 @@
+import React from 'react';
+
+export default ({ children }) => {
+ const formatted = children.split(/ /).map(word => {
+ if (word.match(/((([A-Za-z]{3,9}:(?:\/\/)?)(?:[\-;:&=\+\$,\w]+@)?[A-Za-z0-9\.\-]+|(?:www\.|[\-;:&=\+\$,\w]+@)[A-Za-z0-9\.\-]+)((?:\/[\+~%\/\.\w\-_]*)?\??(?:[\-\+=&;%@\.\w_]*)#?(?:[\.\!\/\\\w]*))?)/)) {
+ return <a href={word.includes('http') ? word : `http://${word}`} target="_blank">{word} </a>;
+ }
+ return `${word} `;
+ });
+
+ return (
+ <p>
+ {formatted}
+ </p>
+ );
+}; |
|
9ae2ec42883d779d23593579454e6804fc73c4e0 | web/src/components/common/Backend.jsx | web/src/components/common/Backend.jsx | import 'babel-polyfill';
import 'isomorphic-fetch';
const BACKEND_URL = 'http://localhost:5000'
import React, {Component} from 'react';
export function fetchJson(path) {
// use this function to make a GET request.
const url = `${BACKEND_URL}${path}`
return fetch(url)
.then(response => response.json())
.catch(ex => {
console.error('parsing failes', ex);
});
}
export function sendJson(method, path, payload) {
//use this function to make a POST requst
const url = `${BACKEND_URL}${path}`
return fetch(url, {
method: method,
body: JSON.stringify(payload),
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
}
}).then(response => response.json())
// .then(json => console.dir(json))
.catch(ex => {
console.error('parsing failed', ex)
});
}
export default class BackendTest extends Component {
constructor(props) {
super(props);
this.state = {
state: null
};
}
render() {
// fetchJson('/api/projects/dummyadd'),
sendJson('POST', '/api/projects/search', {
"query": {
"match_all": {}
}
}),
sendJson('POST', '/api/projects/search', {
"query": {
"match_all": {}
}
}).then(json => console.log(json))
return (
<div></div>
);
}
}
| Add wrapper for http requests | Add wrapper for http requests
| JSX | mit | Drakulix/knex,Drakulix/knex,Drakulix/knex,Drakulix/knex | ---
+++
@@ -0,0 +1,62 @@
+import 'babel-polyfill';
+import 'isomorphic-fetch';
+const BACKEND_URL = 'http://localhost:5000'
+ import React, {Component} from 'react';
+
+ export function fetchJson(path) {
+ // use this function to make a GET request.
+ const url = `${BACKEND_URL}${path}`
+
+ return fetch(url)
+ .then(response => response.json())
+ .catch(ex => {
+ console.error('parsing failes', ex);
+ });
+
+ }
+
+ export function sendJson(method, path, payload) {
+ //use this function to make a POST requst
+ const url = `${BACKEND_URL}${path}`
+
+ return fetch(url, {
+ method: method,
+ body: JSON.stringify(payload),
+ headers: {
+ 'Accept': 'application/json',
+ 'Content-Type': 'application/json'
+ }
+ }).then(response => response.json())
+ // .then(json => console.dir(json))
+ .catch(ex => {
+ console.error('parsing failed', ex)
+ });
+ }
+
+ export default class BackendTest extends Component {
+ constructor(props) {
+ super(props);
+
+ this.state = {
+ state: null
+ };
+ }
+
+ render() {
+ // fetchJson('/api/projects/dummyadd'),
+ sendJson('POST', '/api/projects/search', {
+ "query": {
+ "match_all": {}
+ }
+ }),
+ sendJson('POST', '/api/projects/search', {
+ "query": {
+ "match_all": {}
+ }
+ }).then(json => console.log(json))
+
+ return (
+ <div></div>
+ );
+ }
+ } |
|
a4b14c1dc0ad47bb5f32bb2d0904882e8a81a4a8 | client/source/components/User/NotificationsListEntry.jsx | client/source/components/User/NotificationsListEntry.jsx | import React, {Component} from 'react';
import { Grid, Row, Col, Badge, Glyphicon, FormControl, Button } from 'react-bootstrap';
export default ({user, text, handleUserClick}) => {
return (
<Row height={50} style={{borderBottom: "1px solid rgba(128,128,128, 0.2)"}}>
<Col xs={2} md={2}>
<h2 > <Glyphicon glyph="certificate" bsSize="large"/> </h2>
</Col>
<Col xs={10} md={10} >
<h4 id={user} onClick={handleUserClick.bind(this)}> {`@${user} ${text}`} </h4>
</Col>
</Row>
)
}
| Implement new NotificationListEntry component to dispaly of new notification response parameter. | Implement new NotificationListEntry component to dispaly of new notification response parameter.
| JSX | mit | JAC-Labs/SkilletHub,JAC-Labs/SkilletHub | ---
+++
@@ -0,0 +1,16 @@
+import React, {Component} from 'react';
+import { Grid, Row, Col, Badge, Glyphicon, FormControl, Button } from 'react-bootstrap';
+
+export default ({user, text, handleUserClick}) => {
+
+ return (
+ <Row height={50} style={{borderBottom: "1px solid rgba(128,128,128, 0.2)"}}>
+ <Col xs={2} md={2}>
+ <h2 > <Glyphicon glyph="certificate" bsSize="large"/> </h2>
+ </Col>
+ <Col xs={10} md={10} >
+ <h4 id={user} onClick={handleUserClick.bind(this)}> {`@${user} ${text}`} </h4>
+ </Col>
+ </Row>
+ )
+} |
|
82b9df02eca752ef259ab34081018ee5615c26b2 | client/js/components/assessments/sentence_sandbox/sentence_sandbox.jsx | client/js/components/assessments/sentence_sandbox/sentence_sandbox.jsx | import React from "react";
import { DragDropContext } from 'react-dnd';
import HTML5Backend from 'react-dnd-html5-backend';
import Word from "../fill_the_blank_dnd/word";
import DraggableWord from "../fill_the_blank_dnd/draggable_word";
import Dropzone from "../fill_the_blank_dnd/dropzone";
import DraggableWordGroup from "./draggable_word_group";
const Words = {
0: "asdf",
1: "fdsa",
2: "asdffdsa"
};
export class SentenceSandbox extends React.Component {
constructor() {
super();
this.state = {
wordChain: []
};
}
render() {
return return <div>
<div>
<h1>Words</h1>
<ul>
{_.map(_.omit(Words, this.state.wordChain), (word, wordId) => {
return <li key={wordId}><DraggableWord id={wordId}>{word}</DraggableWord></li>
})}
</ul>
</div>
<div>
<span>Start: </span>
{ _.map(this.state.wordChain() (wordId) => {
})
<Dropzone dropWord={(wordId) => { this.dropWord(wordId) }}>
<span>{blank}</span>
</Dropzone>
}
</div>
</div>
}
}
export default DragDropContext(HTML5Backend)(SentenceSandbox);
| Add a sentence sandbox component | Add a sentence sandbox component
| JSX | mit | atomicjolt/open_assessments,atomicjolt/OpenAssessmentsClient,atomicjolt/OpenAssessmentsClient,atomicjolt/OpenAssessmentsClient,atomicjolt/open_assessments,atomicjolt/open_assessments | ---
+++
@@ -0,0 +1,48 @@
+import React from "react";
+import { DragDropContext } from 'react-dnd';
+import HTML5Backend from 'react-dnd-html5-backend';
+
+import Word from "../fill_the_blank_dnd/word";
+import DraggableWord from "../fill_the_blank_dnd/draggable_word";
+import Dropzone from "../fill_the_blank_dnd/dropzone";
+import DraggableWordGroup from "./draggable_word_group";
+
+const Words = {
+ 0: "asdf",
+ 1: "fdsa",
+ 2: "asdffdsa"
+};
+
+export class SentenceSandbox extends React.Component {
+ constructor() {
+ super();
+
+ this.state = {
+ wordChain: []
+ };
+ }
+ render() {
+ return return <div>
+ <div>
+ <h1>Words</h1>
+ <ul>
+ {_.map(_.omit(Words, this.state.wordChain), (word, wordId) => {
+ return <li key={wordId}><DraggableWord id={wordId}>{word}</DraggableWord></li>
+ })}
+ </ul>
+ </div>
+ <div>
+ <span>Start: </span>
+ { _.map(this.state.wordChain() (wordId) => {
+
+ })
+ <Dropzone dropWord={(wordId) => { this.dropWord(wordId) }}>
+ <span>{blank}</span>
+ </Dropzone>
+ }
+ </div>
+ </div>
+ }
+}
+
+export default DragDropContext(HTML5Backend)(SentenceSandbox); |
|
99c903bb6e992e623428642110a72a827578f3c3 | app/assets/javascripts/components/search_results_list.es6.jsx | app/assets/javascripts/components/search_results_list.es6.jsx | class SearchResultsList extends React.Component {
render() {
return (
<ul className="dropdown-menu" id="autocomplete-items">
<li>
<a href={`/search?q=${this.props.term}`}>
<span className="glyphicon glyphicon-search"></span> Search for <strong>{this.props.term}</strong>
</a>
</li>
{this.renderPostHeader()}
{this.renderPosts()}
{this.renderUserHeader()}
{this.renderUsers()}
</ul>
);
}
renderPosts() {
return this.props.posts.slice(0, 3).map((post) => {
return <SearchPostListItem key={post.id} post={post} />
});
}
renderUsers() {
return this.props.users.slice(0, 3).map((user) => {
return <SearchUserListItem key={user.id} user={user} />
});
}
renderPostHeader() {
if (this.props.posts.length === 0) { return; }
return <li><h4 className="autocomplete-heading">Posts</h4></li>
}
renderUserHeader() {
if (this.props.users.length === 0) { return; }
return <li><h4 className="autocomplete-heading">People</h4></li>
}
}
| class SearchResultsList extends React.Component {
render() {
return (
<ul className="dropdown-menu" id="autocomplete-items">
<li>
<a href={`/search?q=${this.props.term}`}>
<span className="glyphicon glyphicon-search"></span> Search for <strong>{this.props.term}</strong>
</a>
</li>
{this.renderPostHeading()}
{this.renderPosts()}
{this.renderUserHeading()}
{this.renderUsers()}
</ul>
);
}
renderPosts() {
return this.props.posts.slice(0, 3).map((post) => {
return <SearchPostListItem key={post.id} post={post} />
});
}
renderUsers() {
return this.props.users.slice(0, 3).map((user) => {
return <SearchUserListItem key={user.id} user={user} />
});
}
renderPostHeading() {
if (this.props.posts.length === 0) { return; }
return <li><h4 className="autocomplete-heading">Posts</h4></li>
}
renderUserHeading() {
if (this.props.users.length === 0) { return; }
return <li><h4 className="autocomplete-heading">People</h4></li>
}
}
| Change the method names in SearchResultsList component | Change the method names in SearchResultsList component
| JSX | mit | dev-warner/Revinyl-Product,kenny-hibino/stories,dev-warner/Revinyl-Product,kenny-hibino/stories,aamin005/Firdowsspace,aamin005/Firdowsspace,aamin005/Firdowsspace,dev-warner/Revinyl-Product,kenny-hibino/stories | ---
+++
@@ -8,9 +8,9 @@
<span className="glyphicon glyphicon-search"></span> Search for <strong>{this.props.term}</strong>
</a>
</li>
- {this.renderPostHeader()}
+ {this.renderPostHeading()}
{this.renderPosts()}
- {this.renderUserHeader()}
+ {this.renderUserHeading()}
{this.renderUsers()}
</ul>
);
@@ -28,13 +28,13 @@
});
}
- renderPostHeader() {
+ renderPostHeading() {
if (this.props.posts.length === 0) { return; }
return <li><h4 className="autocomplete-heading">Posts</h4></li>
}
- renderUserHeader() {
+ renderUserHeading() {
if (this.props.users.length === 0) { return; }
return <li><h4 className="autocomplete-heading">People</h4></li> |
d2039485e7c38bb3d9cbedf0cdbbf3edb6d311fd | GeonodeDebug.jsx | GeonodeDebug.jsx | import React from 'react';
import ReactDOM from 'react-dom';
import GeoNodeViewer from './geonode.jsx';
import enMessages from 'boundless-sdk/locale/en.js';
import {IntlProvider} from 'react-intl';
class GeoNodeViewerDebug extends React.Component {
constructor(props) {
super(props);
this.state = { config: this.props.config };
this.config = JSON.stringify(this.props.config);
this.configUrl = '';
}
fetchConfigFromUrl(url) {
fetch(url).then((response) => {
return response.json();
}).then((json) => {
this.setState( { config: json});
});
}
configUrlChange(config) {
this.configUrl = config;
this.fetchConfigFromUrl('https://cors-anywhere.herokuapp.com/'+this.configUrl);
}
render() {
return (
<div>
<div id="debug">
<label for="debug">Debug URL</label>
<input
type="text"
value={this.configUrl}
onChange={(event) => { this.configUrlChange(event.target.value)}}
/>
</div>
<GeoNodeViewer config={this.state.config} />
</div>
)
}
}
GeoNodeViewer.props = {
config: React.PropTypes.object.isRequired
};
export default GeoNodeViewerDebug;
| Add debugViewer to add config urls and change the map | Add debugViewer to add config urls and change the map
just paste in geonode config urls and they get parsed via a proxy and
then the config is used to update the GeonodeViewer and therefore the
map
makes is easy to test certain confogurations
| JSX | mit | GeoNode/geonode-client,GeoNode/geonode-client,GeoNode/geonode-client,GeoNode/geonode-client | ---
+++
@@ -0,0 +1,44 @@
+import React from 'react';
+import ReactDOM from 'react-dom';
+import GeoNodeViewer from './geonode.jsx';
+import enMessages from 'boundless-sdk/locale/en.js';
+import {IntlProvider} from 'react-intl';
+
+class GeoNodeViewerDebug extends React.Component {
+ constructor(props) {
+ super(props);
+ this.state = { config: this.props.config };
+ this.config = JSON.stringify(this.props.config);
+ this.configUrl = '';
+ }
+ fetchConfigFromUrl(url) {
+ fetch(url).then((response) => {
+ return response.json();
+ }).then((json) => {
+ this.setState( { config: json});
+ });
+ }
+ configUrlChange(config) {
+ this.configUrl = config;
+ this.fetchConfigFromUrl('https://cors-anywhere.herokuapp.com/'+this.configUrl);
+ }
+ render() {
+ return (
+ <div>
+ <div id="debug">
+ <label for="debug">Debug URL</label>
+ <input
+ type="text"
+ value={this.configUrl}
+ onChange={(event) => { this.configUrlChange(event.target.value)}}
+ />
+ </div>
+ <GeoNodeViewer config={this.state.config} />
+ </div>
+ )
+ }
+}
+GeoNodeViewer.props = {
+ config: React.PropTypes.object.isRequired
+};
+export default GeoNodeViewerDebug; |
|
a5e2f8de90f77dd6482f92cbfdff8d8cc05b6640 | spec/react/container.test.jsx | spec/react/container.test.jsx |
import { describe, it, before, beforeEach, after, afterEach } from 'mocha';
import assert from 'power-assert';
import _ from 'lodash';
import React from 'react';
import TestUtils from 'react-addons-test-utils';
import Logger from '../../src/logger';
import { createStore, destroyStore, getAllStores, destroyAllStores } from '../../src/core';
import Container from '../../src/react/container';
describe("react.Container", () => {
let renderer = null;
let container = null;
let output = null;
let store = null;
let initState = {
test: "test"
};
before(() => {
store = createStore('spec', initState);
renderer = TestUtils.createRenderer();
class MyComponent extends React.Component {
render() {
let props = this.props;
return (
<div>
<h1>CH4</h1>
<p>{ props.spec.test }</p>
<button type="button" onClick={ (_e) => { store.set('test', 'changed') } }></button>
</div>
);
}
}
container = TestUtils.renderIntoDocument(
<Container stores={ [store] }>
<MyComponent />
</Container>
);
});
after(() => {
destroyAllStores();
});
it("setted init state", () => {
let p = TestUtils.findRenderedDOMComponentWithTag(container, 'p');
assert(p.textContent === initState.test);
});
it("changed state when clicked button", () => {
let button = TestUtils.findRenderedDOMComponentWithTag(container, 'button');
TestUtils.Simulate.click(button);
let p = TestUtils.findRenderedDOMComponentWithTag(container, 'p');
assert(p.textContent === "changed");
});
});
| Add spec for react container. | Add spec for react container.
| JSX | mit | kamito/ch4 | ---
+++
@@ -0,0 +1,58 @@
+
+import { describe, it, before, beforeEach, after, afterEach } from 'mocha';
+import assert from 'power-assert';
+import _ from 'lodash';
+import React from 'react';
+import TestUtils from 'react-addons-test-utils';
+
+import Logger from '../../src/logger';
+import { createStore, destroyStore, getAllStores, destroyAllStores } from '../../src/core';
+import Container from '../../src/react/container';
+
+describe("react.Container", () => {
+ let renderer = null;
+ let container = null;
+ let output = null;
+ let store = null;
+ let initState = {
+ test: "test"
+ };
+ before(() => {
+ store = createStore('spec', initState);
+ renderer = TestUtils.createRenderer();
+ class MyComponent extends React.Component {
+ render() {
+ let props = this.props;
+ return (
+ <div>
+ <h1>CH4</h1>
+ <p>{ props.spec.test }</p>
+ <button type="button" onClick={ (_e) => { store.set('test', 'changed') } }></button>
+ </div>
+ );
+ }
+ }
+ container = TestUtils.renderIntoDocument(
+ <Container stores={ [store] }>
+ <MyComponent />
+ </Container>
+ );
+ });
+
+ after(() => {
+ destroyAllStores();
+ });
+
+ it("setted init state", () => {
+ let p = TestUtils.findRenderedDOMComponentWithTag(container, 'p');
+ assert(p.textContent === initState.test);
+ });
+
+ it("changed state when clicked button", () => {
+ let button = TestUtils.findRenderedDOMComponentWithTag(container, 'button');
+ TestUtils.Simulate.click(button);
+ let p = TestUtils.findRenderedDOMComponentWithTag(container, 'p');
+ assert(p.textContent === "changed");
+ });
+
+}); |
|
3a29face102e0294321125e71de591481c525aac | docs/Tag.jsx | docs/Tag.jsx | import React, { PropTypes } from 'react'
export default function Tag ({text, inverted = false}) {
return (
<span className={`demo-tag ${inverted && 'inverted'}`}>{text}</span>
)
}
Tag.propTypes = {
text: PropTypes.string,
inverted: PropTypes.bool
}
| Create tag component for new docs | Create tag component for new docs
| JSX | mit | miduga/react-slidy | ---
+++
@@ -0,0 +1,12 @@
+import React, { PropTypes } from 'react'
+
+export default function Tag ({text, inverted = false}) {
+ return (
+ <span className={`demo-tag ${inverted && 'inverted'}`}>{text}</span>
+ )
+}
+
+Tag.propTypes = {
+ text: PropTypes.string,
+ inverted: PropTypes.bool
+} |
|
44b7222ae34af9a1b86f415a8f00977752bc3c46 | app/components/GradesStats.jsx | app/components/GradesStats.jsx | import React, { Component } from 'react';
class GradesStats extends Component {
render() {
const { assessment } = this.props;
if(!assessment) {
return (
<div className="chart-container">
<h5 className="pre-stats-text">Click on an Assessment or Category to begin.</h5>
</div>
);
} else {
return (
<div className="chart-container">
<h5 className="pre-stats-text">{assessment.name} has been selected!</h5>
</div>
);
}
}
}
export default GradesStats;
| Refactor Grades Stats into its own component | Refactor Grades Stats into its own component
| JSX | mit | joelseq/SourceGrade,joelseq/SourceGrade | ---
+++
@@ -0,0 +1,23 @@
+import React, { Component } from 'react';
+
+class GradesStats extends Component {
+ render() {
+ const { assessment } = this.props;
+
+ if(!assessment) {
+ return (
+ <div className="chart-container">
+ <h5 className="pre-stats-text">Click on an Assessment or Category to begin.</h5>
+ </div>
+ );
+ } else {
+ return (
+ <div className="chart-container">
+ <h5 className="pre-stats-text">{assessment.name} has been selected!</h5>
+ </div>
+ );
+ }
+ }
+}
+
+export default GradesStats; |
|
4c49ae1701f5b75c20a76ac681b91d9b98f2b299 | src/views/splash/beta/small-top-banner.jsx | src/views/splash/beta/small-top-banner.jsx | const FormattedMessage = require('react-intl').FormattedMessage;
const injectIntl = require('react-intl').injectIntl;
const React = require('react');
const FlexRow = require('../../../components/flex-row/flex-row.jsx');
const TitleBanner = require('../../../components/title-banner/title-banner.jsx');
require('./top-banner.scss');
const SmallTopBanner = () => (
<TitleBanner className="beta-top-banner">
<FlexRow>
<a
className="call-to-action button"
href="https://beta.scratch.mit.edu/"
>Call to Action</a>
</FlexRow>
</TitleBanner>
);
export default SmallTopBanner;
| Create small top banner component | Create small top banner component
| JSX | bsd-3-clause | LLK/scratch-www,LLK/scratch-www | ---
+++
@@ -0,0 +1,21 @@
+const FormattedMessage = require('react-intl').FormattedMessage;
+const injectIntl = require('react-intl').injectIntl;
+const React = require('react');
+
+const FlexRow = require('../../../components/flex-row/flex-row.jsx');
+const TitleBanner = require('../../../components/title-banner/title-banner.jsx');
+
+require('./top-banner.scss');
+
+const SmallTopBanner = () => (
+ <TitleBanner className="beta-top-banner">
+ <FlexRow>
+ <a
+ className="call-to-action button"
+ href="https://beta.scratch.mit.edu/"
+ >Call to Action</a>
+ </FlexRow>
+ </TitleBanner>
+);
+
+export default SmallTopBanner; |
|
64873eeb40160ec75d6884efbf350976963beac1 | src/components/AlertButtons.jsx | src/components/AlertButtons.jsx | /*
* When adding buttons to the bottom of a Bootstrap alert,
* you typically want those buttons to
* - be right-aligned;
* - not be flush up against the text they're below; and
* - not be flush up against each other.
*
* Unfortunately, these are not the default settings, because
* - right-alignment isn't the default;
* - there's no margin by default; and
* - React strips spaces between DOM components.
*
* This file provides two classes, AlertButtonToolbar and AlertButton.
* AlertButtonToolbar fixes the alignment and vertical margin issues;
* AlertButton fixes the horizontal margin issue (the third one in the list).
*
* You can use this like you use any other React Bootstrap components.
* Any props you pass to them will be passed straight through,
* except for "style", which may be modified.
*/
import React, {Component} from 'react';
import {Button} from 'react-bootstrap';
export class AlertButtonToolbar extends Component {
render() {
const style = {
marginTop: 15,
textAlign: "right",
...this.props.style,
};
return <div role="toolbar" {...this.props} style={style}>
{this.props.children}
</div>;
}
}
export class AlertButton extends Component {
render() {
const style = {
marginLeft: 5,
...this.props.style,
};
return <Button {...this.props} style={style}>
{this.props.children}
</Button>;
}
}
| Add AlertButtonToolbar, AlertButton to fix spacing | Add AlertButtonToolbar, AlertButton to fix spacing
| JSX | mit | WChargin/lc3,WChargin/lc3 | ---
+++
@@ -0,0 +1,52 @@
+/*
+ * When adding buttons to the bottom of a Bootstrap alert,
+ * you typically want those buttons to
+ * - be right-aligned;
+ * - not be flush up against the text they're below; and
+ * - not be flush up against each other.
+ *
+ * Unfortunately, these are not the default settings, because
+ * - right-alignment isn't the default;
+ * - there's no margin by default; and
+ * - React strips spaces between DOM components.
+ *
+ * This file provides two classes, AlertButtonToolbar and AlertButton.
+ * AlertButtonToolbar fixes the alignment and vertical margin issues;
+ * AlertButton fixes the horizontal margin issue (the third one in the list).
+ *
+ * You can use this like you use any other React Bootstrap components.
+ * Any props you pass to them will be passed straight through,
+ * except for "style", which may be modified.
+ */
+import React, {Component} from 'react';
+
+import {Button} from 'react-bootstrap';
+
+export class AlertButtonToolbar extends Component {
+
+ render() {
+ const style = {
+ marginTop: 15,
+ textAlign: "right",
+ ...this.props.style,
+ };
+ return <div role="toolbar" {...this.props} style={style}>
+ {this.props.children}
+ </div>;
+ }
+
+}
+
+export class AlertButton extends Component {
+
+ render() {
+ const style = {
+ marginLeft: 5,
+ ...this.props.style,
+ };
+ return <Button {...this.props} style={style}>
+ {this.props.children}
+ </Button>;
+ }
+
+} |
|
942b48533d01fddffc18101057816f559f1a0fad | app/Resources/client/jsx/organism/search/quickSearch.jsx | app/Resources/client/jsx/organism/search/quickSearch.jsx | $(document).ready(function(){
//autocomplete for organism search
$("#search_organism").autocomplete({
position: {
my: "right top", at: "right bottom"
},
source: function (request, response) {
var search = request.term;
$.ajax({
url: "{{ path('api', {'namespace': 'listing', 'classname': type~'s'}) }}",
data: {term: request.term, limit: 500, search: search, dbversion: '{{ dbversion }}'},
dataType: "json",
success: function (data) {
response(data);
}
});
},
minLength: 3
});
$("#search_organism").data("ui-autocomplete")._renderItem = function (ul, item) {
var details = Routing.generate('{{ type }}_details', {'dbversion': '{{ dbversion }}', 'fennec_id': item.fennec_id});
var link = "<a href='"+details+"'><span style='display:inline-block; width: 100%; font-style: italic;'>" + item.scientific_name + "</span></a>";
var li = $("<li>")
.append(link)
.appendTo(ul);
return li;
};
$("#btn_search_organism").click(function(){
var searchTerm = $("#search_organism").val();
var resultPage = Routing.generate('{{ type }}_result', {'dbversion': '{{ dbversion }}', 'limit': 500, 'search': searchTerm});
window.location.href = resultPage;
});
}); | Add quick search jsx template for organism page | Add quick search jsx template for organism page
| JSX | mit | molbiodiv/fennec,molbiodiv/fennec,molbiodiv/fennec,molbiodiv/fennec,molbiodiv/fennec | ---
+++
@@ -0,0 +1,35 @@
+$(document).ready(function(){
+ //autocomplete for organism search
+ $("#search_organism").autocomplete({
+ position: {
+ my: "right top", at: "right bottom"
+ },
+ source: function (request, response) {
+ var search = request.term;
+ $.ajax({
+ url: "{{ path('api', {'namespace': 'listing', 'classname': type~'s'}) }}",
+ data: {term: request.term, limit: 500, search: search, dbversion: '{{ dbversion }}'},
+ dataType: "json",
+ success: function (data) {
+ response(data);
+ }
+ });
+ },
+ minLength: 3
+ });
+
+ $("#search_organism").data("ui-autocomplete")._renderItem = function (ul, item) {
+ var details = Routing.generate('{{ type }}_details', {'dbversion': '{{ dbversion }}', 'fennec_id': item.fennec_id});
+ var link = "<a href='"+details+"'><span style='display:inline-block; width: 100%; font-style: italic;'>" + item.scientific_name + "</span></a>";
+ var li = $("<li>")
+ .append(link)
+ .appendTo(ul);
+ return li;
+ };
+
+ $("#btn_search_organism").click(function(){
+ var searchTerm = $("#search_organism").val();
+ var resultPage = Routing.generate('{{ type }}_result', {'dbversion': '{{ dbversion }}', 'limit': 500, 'search': searchTerm});
+ window.location.href = resultPage;
+ });
+}); |
|
9deb39f4db0bf9035ba1a577af52bcb5c8026b6f | app/components/signUp/signUp.jsx | app/components/signUp/signUp.jsx | import React from 'react';
export default React.createClass({
render: function () {
return (
<div className="box">
<p className="control">
<label className="label">Name</label>
<input
className="input"
type="text"
placeholder="Ernest Hemingway" />
</p>
<p className="control">
<label className="label">Email</label>
<input
className="input"
type="email"
placeholder="hi@me.com" />
</p>
<p className="control">
<label className="label">Password</label>
<input
className="input"
type="password"
placeholder="Something you won't forget, but others won't guess" />
</p>
<p className="control">
<button className="button is-primary">Submit</button>
</p>
</div>
)
}
})
| Add a sign up component | Add a sign up component | JSX | agpl-3.0 | empirical-org/Empirical-Core,empirical-org/Empirical-Core,empirical-org/Empirical-Core,empirical-org/Empirical-Core,empirical-org/Empirical-Core,empirical-org/Empirical-Core,empirical-org/Empirical-Core | ---
+++
@@ -0,0 +1,34 @@
+import React from 'react';
+
+export default React.createClass({
+ render: function () {
+ return (
+ <div className="box">
+ <p className="control">
+ <label className="label">Name</label>
+ <input
+ className="input"
+ type="text"
+ placeholder="Ernest Hemingway" />
+ </p>
+ <p className="control">
+ <label className="label">Email</label>
+ <input
+ className="input"
+ type="email"
+ placeholder="hi@me.com" />
+ </p>
+ <p className="control">
+ <label className="label">Password</label>
+ <input
+ className="input"
+ type="password"
+ placeholder="Something you won't forget, but others won't guess" />
+ </p>
+ <p className="control">
+ <button className="button is-primary">Submit</button>
+ </p>
+ </div>
+ )
+ }
+}) |
|
90a1a2a6b115de6f9a455c60eb37ab0648c505e0 | src/Dots.jsx | src/Dots.jsx | import React, { Component, PropTypes } from 'react'
import { Paper } from 'material-ui'
const styles = {
root: {
display: 'block'
},
dot: {
width: 10,
height: 10,
background: 'rgba(255,255,255,1)',
marginLeft: 3,
marginRight: 3,
float: 'left'
},
dotInactiv: {
width: 10,
height: 10,
background: 'rgba(255,255,255,0.5)',
marginLeft: 3,
marginRight: 3,
float: 'left'
}
}
export class Dots extends Component {
constructor(props) {
super(props)
}
renderDots(count, index) {
const dots = []
for (let i = 0; i < count; ++i) {
dots.push(this.renderDot(i === index))
}
return dots
}
renderDot(active) {
return (
<Paper
circle
zDepth={0}
style={active ? styles.dot : styles.dotInactiv}
/>
)
}
render() {
const { count, index } = this.props
const width = (count * 10) + (count * 6)
return (
<div style={{ ...this.props.style, ...styles.root, width }}>
{this.renderDots(count, index)}
</div>
)
}
}
Dots.propTypes = {
count: PropTypes.number.isRequired,
index: PropTypes.number.isRequired,
style: PropTypes.object
}
| Add dots component to display index. | Add dots component to display index.
| JSX | mit | TeamWertarbyte/material-auto-rotating-carousel | ---
+++
@@ -0,0 +1,65 @@
+import React, { Component, PropTypes } from 'react'
+import { Paper } from 'material-ui'
+
+const styles = {
+ root: {
+ display: 'block'
+ },
+ dot: {
+ width: 10,
+ height: 10,
+ background: 'rgba(255,255,255,1)',
+ marginLeft: 3,
+ marginRight: 3,
+ float: 'left'
+ },
+ dotInactiv: {
+ width: 10,
+ height: 10,
+ background: 'rgba(255,255,255,0.5)',
+ marginLeft: 3,
+ marginRight: 3,
+ float: 'left'
+ }
+}
+
+export class Dots extends Component {
+ constructor(props) {
+ super(props)
+ }
+
+ renderDots(count, index) {
+ const dots = []
+ for (let i = 0; i < count; ++i) {
+ dots.push(this.renderDot(i === index))
+ }
+ return dots
+ }
+
+ renderDot(active) {
+ return (
+ <Paper
+ circle
+ zDepth={0}
+ style={active ? styles.dot : styles.dotInactiv}
+ />
+ )
+ }
+
+ render() {
+ const { count, index } = this.props
+ const width = (count * 10) + (count * 6)
+
+ return (
+ <div style={{ ...this.props.style, ...styles.root, width }}>
+ {this.renderDots(count, index)}
+ </div>
+ )
+ }
+}
+
+Dots.propTypes = {
+ count: PropTypes.number.isRequired,
+ index: PropTypes.number.isRequired,
+ style: PropTypes.object
+} |
|
cb5ef75ceebdfb31249a86a060e8801c5418b87e | django_cradmin/apps/django_cradmin_js/staticsources/django_cradmin_js/source/filterlist/components/paginators/BoxLoadMorePaginator.jsx | django_cradmin/apps/django_cradmin_js/staticsources/django_cradmin_js/source/filterlist/components/paginators/BoxLoadMorePaginator.jsx | import React from 'react'
import PropTypes from 'prop-types'
import LoadMorePaginator from './LoadMorePaginator'
import BemUtilities from '../../../utilities/BemUtilities'
/**
* Just like {@link LoadMorePaginator}, except that the button is
* wrapped with a paragraph.
*
* See {@link BoxLoadMorePaginator.defaultProps} for documentation for
* props and their defaults.
*
* @example <caption>Spec - minimal</caption>
* {
* "component": "BoxLoadMorePaginator"
* }
*
* @example <caption>Spec - advanced</caption>
* {
* "component": "BoxLoadMorePaginator",
* "props": {
* "boxBemVariants": ['spacing--small'],
* "label": "Load some more items!",
* "bemBlock": "custombutton",
* "bemVariants": ["large", "dark"],
* "location": "left"
* }
* }
*/
export default class BoxLoadMorePaginator extends LoadMorePaginator {
static get propTypes () {
return {
...super.propTypes,
boxBemBlock: PropTypes.string.isRequired,
boxBemVariants: PropTypes.arrayOf(PropTypes.string).isRequired
}
}
/**
* Get default props. Extends the default props
* from {@link LoadMorePaginator.defaultProps}.
*
* @return {Object}
* @property {string} paragraphClassName The css class for the paragraph.
* Defaults to `null`.
* **Can be used in spec**.
*/
static get defaultProps () {
return {
...super.defaultProps,
boxBemBlock: 'box',
boxBemVariants: ['spacing--small']
}
}
get boxClassName () {
return BemUtilities.buildBemBlock(this.props.boxBemBlock, this.props.boxBemVariants)
}
renderLoadMoreButton () {
return <div className={this.boxClassName}>
{super.renderLoadMoreButton()}
</div>
}
}
| Add load more paginator for box | Add load more paginator for box
| JSX | bsd-3-clause | appressoas/django_cradmin,appressoas/django_cradmin,appressoas/django_cradmin | ---
+++
@@ -0,0 +1,65 @@
+import React from 'react'
+import PropTypes from 'prop-types'
+import LoadMorePaginator from './LoadMorePaginator'
+import BemUtilities from '../../../utilities/BemUtilities'
+
+/**
+ * Just like {@link LoadMorePaginator}, except that the button is
+ * wrapped with a paragraph.
+ *
+ * See {@link BoxLoadMorePaginator.defaultProps} for documentation for
+ * props and their defaults.
+ *
+ * @example <caption>Spec - minimal</caption>
+ * {
+ * "component": "BoxLoadMorePaginator"
+ * }
+ *
+ * @example <caption>Spec - advanced</caption>
+ * {
+ * "component": "BoxLoadMorePaginator",
+ * "props": {
+ * "boxBemVariants": ['spacing--small'],
+ * "label": "Load some more items!",
+ * "bemBlock": "custombutton",
+ * "bemVariants": ["large", "dark"],
+ * "location": "left"
+ * }
+ * }
+ */
+export default class BoxLoadMorePaginator extends LoadMorePaginator {
+ static get propTypes () {
+ return {
+ ...super.propTypes,
+ boxBemBlock: PropTypes.string.isRequired,
+ boxBemVariants: PropTypes.arrayOf(PropTypes.string).isRequired
+ }
+ }
+
+ /**
+ * Get default props. Extends the default props
+ * from {@link LoadMorePaginator.defaultProps}.
+ *
+ * @return {Object}
+ * @property {string} paragraphClassName The css class for the paragraph.
+ * Defaults to `null`.
+ * **Can be used in spec**.
+ */
+ static get defaultProps () {
+ return {
+ ...super.defaultProps,
+ boxBemBlock: 'box',
+ boxBemVariants: ['spacing--small']
+ }
+ }
+
+ get boxClassName () {
+ return BemUtilities.buildBemBlock(this.props.boxBemBlock, this.props.boxBemVariants)
+ }
+
+ renderLoadMoreButton () {
+ return <div className={this.boxClassName}>
+ {super.renderLoadMoreButton()}
+ </div>
+ }
+} |
|
731f2c9576608e7219c13ee704a13d250f5bd7f0 | webofneeds/won-owner-webapp/src/main/webapp/app/components/details/react-viewer/location-viewer.jsx | webofneeds/won-owner-webapp/src/main/webapp/app/components/details/react-viewer/location-viewer.jsx | import React from "react";
import "~/style/_location-viewer.scss";
import { get } from "../../../utils.js";
import WonAtomMap from "../../atom-map.jsx";
import PropTypes from "prop-types";
export default class WonLocationViewer extends React.Component {
constructor(props) {
super(props);
this.state = {
locationExpanded: false,
};
}
toggleLocation() {
this.setState({ locationExpanded: !this.state.locationExpanded });
}
render() {
const icon = this.props.detail.icon && (
<svg className="locationv__header__icon">
<use xlinkHref={this.props.detail.icon} href={this.props.detail.icon} />
</svg>
);
const label = this.props.detail.icon && (
<span className="locationv__header__label">
{this.props.detail.label}
</span>
);
const address = get(this.props.content, "address");
const addressElement = address ? (
<div
className="lv__content__text clickable"
onClick={() => this.toggleLocation()}
>
{address}
<svg className="lv__content__text__carret">
<use xlinkHref="#ico-filter_map" href="#ico-filter_map" />
</svg>
<svg className="lv__content__text__carret">
{this.props.content && this.state.locationExanded ? (
<use xlinkHref="#ico16_arrow_up" href="#ico16_arrow_up" />
) : (
<use xlinkHref="#ico16_arrow_down" href="#ico16_arrow_down" />
)}
</svg>
</div>
) : (
undefined
);
const map = this.state.locationExpanded ? (
<WonAtomMap locations={[this.props.content]} />
) : (
undefined
);
return (
<won-location-viewer>
<div className="locationv__header">
{icon}
{label}
</div>
<div className="locationv__content">
{addressElement}
{map}
</div>
</won-location-viewer>
);
}
}
WonLocationViewer.propTypes = {
detail: PropTypes.object,
content: PropTypes.object,
};
| Implement locationviewer as react components | Implement locationviewer as react components
| JSX | apache-2.0 | researchstudio-sat/webofneeds,researchstudio-sat/webofneeds,researchstudio-sat/webofneeds,researchstudio-sat/webofneeds,researchstudio-sat/webofneeds,researchstudio-sat/webofneeds,researchstudio-sat/webofneeds | ---
+++
@@ -0,0 +1,79 @@
+import React from "react";
+
+import "~/style/_location-viewer.scss";
+import { get } from "../../../utils.js";
+import WonAtomMap from "../../atom-map.jsx";
+
+import PropTypes from "prop-types";
+
+export default class WonLocationViewer extends React.Component {
+ constructor(props) {
+ super(props);
+ this.state = {
+ locationExpanded: false,
+ };
+ }
+
+ toggleLocation() {
+ this.setState({ locationExpanded: !this.state.locationExpanded });
+ }
+
+ render() {
+ const icon = this.props.detail.icon && (
+ <svg className="locationv__header__icon">
+ <use xlinkHref={this.props.detail.icon} href={this.props.detail.icon} />
+ </svg>
+ );
+
+ const label = this.props.detail.icon && (
+ <span className="locationv__header__label">
+ {this.props.detail.label}
+ </span>
+ );
+
+ const address = get(this.props.content, "address");
+ const addressElement = address ? (
+ <div
+ className="lv__content__text clickable"
+ onClick={() => this.toggleLocation()}
+ >
+ {address}
+ <svg className="lv__content__text__carret">
+ <use xlinkHref="#ico-filter_map" href="#ico-filter_map" />
+ </svg>
+ <svg className="lv__content__text__carret">
+ {this.props.content && this.state.locationExanded ? (
+ <use xlinkHref="#ico16_arrow_up" href="#ico16_arrow_up" />
+ ) : (
+ <use xlinkHref="#ico16_arrow_down" href="#ico16_arrow_down" />
+ )}
+ </svg>
+ </div>
+ ) : (
+ undefined
+ );
+
+ const map = this.state.locationExpanded ? (
+ <WonAtomMap locations={[this.props.content]} />
+ ) : (
+ undefined
+ );
+
+ return (
+ <won-location-viewer>
+ <div className="locationv__header">
+ {icon}
+ {label}
+ </div>
+ <div className="locationv__content">
+ {addressElement}
+ {map}
+ </div>
+ </won-location-viewer>
+ );
+ }
+}
+WonLocationViewer.propTypes = {
+ detail: PropTypes.object,
+ content: PropTypes.object,
+}; |
|
58ac1efd6fcbe067e0ccb3dc7e311b84671382f5 | client/modules/Challenges/Challenges.jsx | client/modules/Challenges/Challenges.jsx | /* eslint-disable max-len */
import React from 'react';
import PropTypes from 'prop-types';
import Helmet from 'react-helmet';
import Header from 'components/Header/Header';
import Footer from 'components/Footer/Footer';
import Info from './components/Info/Info';
import Category from './components/Category/Category';
import styles from './Challenges.scss';
const CATEGORIES = [
{
name: 'Urban Planning',
description: 'Description',
challenges: [
{
name: '14th Street',
},
{
name: 'Gaslamp',
},
],
},
{
name: 'Category 2',
description: 'Description',
challenges: [
{
name: 'Challenge 1',
},
{
name: 'Challenge 2',
},
],
},
];
/**
* Challenges
*/
const propTypes = {};
const contextTypes = {
router: PropTypes.object,
};
const defaultProps = {};
function Challenges() {
return (
<div className={styles.challenges}>
<Helmet
title="Challenges"
/>
<Header
backgroundImg={''}
headerText={'Challenges'}
subheaderText={''}
showButton={false}
/>
<Info />
<div>
{CATEGORIES.map(category =>
<Category key={category.name} {...category} />
)}
</div>
<Footer />
</div>
);
}
Challenges.propTypes = propTypes;
Challenges.contextTypes = contextTypes;
Challenges.defaultProps = defaultProps;
export default Challenges;
| /* eslint-disable max-len */
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import Helmet from 'react-helmet';
import Header from 'components/Header/Header';
import Footer from 'components/Footer/Footer';
import Info from './components/Info/Info';
import Category from './components/Category/Category';
import styles from './Challenges.scss';
/**
* Challenges
*/
const propTypes = {};
const contextTypes = {
router: PropTypes.object,
};
const defaultProps = {};
class Challenges extends Component {
constructor(props) {
super(props);
this.state = { categories: [] };
}
componentDidMount() {
fetch('https://d4sd-api.ucsd.edu/categories?challenges=true')
.then((response) => {
return response.json();
})
.then((data) => {
this.setState({ categories: data.categories });
});
}
render() {
return (
<section className={styles.challenges}>
<Helmet
title="Challenges"
/>
<Header
backgroundImg={''}
headerText={'Challenges'}
subheaderText={''}
showButton={false}
/>
<Info />
<div>
{this.state.categories.map(category =>
<Category key={category.name} {...category} />
)}
</div>
<Footer />
</section>
);
}
}
Challenges.propTypes = propTypes;
Challenges.contextTypes = contextTypes;
Challenges.defaultProps = defaultProps;
export default Challenges;
| Use API data on Challenge index | Use API data on Challenge index
| JSX | mit | davidcluu/civicchallenge-frontend,creativecolab/civicchallenge-frontend | ---
+++
@@ -1,6 +1,6 @@
/* eslint-disable max-len */
-import React from 'react';
+import React, { Component } from 'react';
import PropTypes from 'prop-types';
import Helmet from 'react-helmet';
@@ -10,33 +10,6 @@
import Category from './components/Category/Category';
import styles from './Challenges.scss';
-
-const CATEGORIES = [
- {
- name: 'Urban Planning',
- description: 'Description',
- challenges: [
- {
- name: '14th Street',
- },
- {
- name: 'Gaslamp',
- },
- ],
- },
- {
- name: 'Category 2',
- description: 'Description',
- challenges: [
- {
- name: 'Challenge 1',
- },
- {
- name: 'Challenge 2',
- },
- ],
- },
-];
/**
* Challenges
@@ -50,27 +23,44 @@
const defaultProps = {};
-function Challenges() {
- return (
- <div className={styles.challenges}>
- <Helmet
- title="Challenges"
- />
- <Header
- backgroundImg={''}
- headerText={'Challenges'}
- subheaderText={''}
- showButton={false}
- />
- <Info />
- <div>
- {CATEGORIES.map(category =>
- <Category key={category.name} {...category} />
- )}
- </div>
- <Footer />
- </div>
- );
+class Challenges extends Component {
+ constructor(props) {
+ super(props);
+ this.state = { categories: [] };
+ }
+
+ componentDidMount() {
+ fetch('https://d4sd-api.ucsd.edu/categories?challenges=true')
+ .then((response) => {
+ return response.json();
+ })
+ .then((data) => {
+ this.setState({ categories: data.categories });
+ });
+ }
+
+ render() {
+ return (
+ <section className={styles.challenges}>
+ <Helmet
+ title="Challenges"
+ />
+ <Header
+ backgroundImg={''}
+ headerText={'Challenges'}
+ subheaderText={''}
+ showButton={false}
+ />
+ <Info />
+ <div>
+ {this.state.categories.map(category =>
+ <Category key={category.name} {...category} />
+ )}
+ </div>
+ <Footer />
+ </section>
+ );
+ }
}
Challenges.propTypes = propTypes; |
d151c587aa0d531153bdce1338b63f4bea623518 | ui/src/message_popup/renderers/minimal_text_response_test.jsx | ui/src/message_popup/renderers/minimal_text_response_test.jsx | /* @flow weak */
import React from 'react';
import {shallow} from 'enzyme';
import {expect} from 'chai';
import sinon from 'sinon';
import MinimalTextResponse from './minimal_text_response.jsx';
function testProps(props) {
return {
onLogMessage: sinon.spy(),
onResponseSubmitted: sinon.spy(),
...props
};
}
describe('<MinimalTextResponse />', () => {
it('logs and submits response when capture flow is done', () => {
const props = testProps();
const wrapper = shallow(<MinimalTextResponse {...props} />);
wrapper.instance().setState({responseText: 'foo'});
wrapper.instance().onRespondTapped();
expect(props.onLogMessage.callCount).to.equal(1);
expect(props.onLogMessage.firstCall.args).to.deep.equal([
'message_popup_text_response',
{ responseText: 'foo' }
]);
expect(props.onResponseSubmitted.firstCall.args[0]).to.deep.equal({ responseText: 'foo' });
});
});
| Add tests to start fixing two types of text responses | Add tests to start fixing two types of text responses
| JSX | mit | mit-teaching-systems-lab/threeflows,mit-teaching-systems-lab/threeflows,mit-teaching-systems-lab/threeflows,mit-teaching-systems-lab/threeflows | ---
+++
@@ -0,0 +1,33 @@
+/* @flow weak */
+import React from 'react';
+
+import {shallow} from 'enzyme';
+import {expect} from 'chai';
+import sinon from 'sinon';
+
+import MinimalTextResponse from './minimal_text_response.jsx';
+
+
+function testProps(props) {
+ return {
+ onLogMessage: sinon.spy(),
+ onResponseSubmitted: sinon.spy(),
+ ...props
+ };
+}
+
+describe('<MinimalTextResponse />', () => {
+ it('logs and submits response when capture flow is done', () => {
+ const props = testProps();
+ const wrapper = shallow(<MinimalTextResponse {...props} />);
+ wrapper.instance().setState({responseText: 'foo'});
+ wrapper.instance().onRespondTapped();
+
+ expect(props.onLogMessage.callCount).to.equal(1);
+ expect(props.onLogMessage.firstCall.args).to.deep.equal([
+ 'message_popup_text_response',
+ { responseText: 'foo' }
+ ]);
+ expect(props.onResponseSubmitted.firstCall.args[0]).to.deep.equal({ responseText: 'foo' });
+ });
+}); |
|
65579c4a65555ac4bbdf60008adf6bfcbbe01447 | src/app/components/Panel/Panel.test.jsx | src/app/components/Panel/Panel.test.jsx | import React from 'react'
import { shallow } from 'enzyme'
import Panel from './Panel'
describe('Panel', () => {
let component
const mockCloseAction = jest.fn()
beforeEach(() => {
component = shallow(
<Panel isPanelVisible closeAction={mockCloseAction}>
<div />
</Panel>,
)
})
it('should render the panel', () => {
expect(component.find('section').props().children).toEqual(<div />)
})
it('should handle the onclose event', () => {
const button = component.find('button')
expect(button.exists()).toBeTruthy()
button.simulate('click')
expect(mockCloseAction).toHaveBeenCalled()
})
})
| Test added for the panel component | Test added for the panel component
| JSX | mpl-2.0 | DatapuntAmsterdam/atlas,DatapuntAmsterdam/atlas_prototype,DatapuntAmsterdam/atlas,Amsterdam/atlas,DatapuntAmsterdam/atlas,Amsterdam/atlas,Amsterdam/atlas,DatapuntAmsterdam/atlas_prototype,Amsterdam/atlas | ---
+++
@@ -0,0 +1,31 @@
+import React from 'react'
+import { shallow } from 'enzyme'
+
+import Panel from './Panel'
+
+describe('Panel', () => {
+ let component
+ const mockCloseAction = jest.fn()
+
+ beforeEach(() => {
+ component = shallow(
+ <Panel isPanelVisible closeAction={mockCloseAction}>
+ <div />
+ </Panel>,
+ )
+ })
+
+ it('should render the panel', () => {
+ expect(component.find('section').props().children).toEqual(<div />)
+ })
+
+ it('should handle the onclose event', () => {
+ const button = component.find('button')
+
+ expect(button.exists()).toBeTruthy()
+
+ button.simulate('click')
+
+ expect(mockCloseAction).toHaveBeenCalled()
+ })
+}) |
|
a1d1c2b1f3aa362f621b3826199e34cc58ba40fb | test/watch-stores-test.jsx | test/watch-stores-test.jsx | /*globals describe, it*/
/*eslint no-unused-expressions: false*/
import chai, {expect} from 'chai';
/* Must import testdom before React. */
import testdom from 'testdom';
testdom('<html><body></body></html>');
import React from 'react';
import Fluxxor from 'fluxxor';
import 'react/addons';
const {TestUtils} = React.addons;
import {watchStores, createFluxContext} from '..';
function createContext(delegateRender) {
const flux = new Fluxxor.Flux({}, {});
return createFluxContext(flux, class Context extends React.Component {
render() {
return delegateRender();
}
});
}
describe('watchStores', () => {
it('wraps an existing React component', () => {
class DummyComponent extends React.Component {
render() {
return <span>Hello, ladies!</span>;
}
}
const Component = watchStores(DummyComponent, () => ({}));
expect(<Component />).to.satisfy(TestUtils.isElement);
/* Render the component within a context. */
const Context = createContext(() => <Component />);
/* Render the instance: */
const tree = TestUtils.renderIntoDocument(<Context />);
/* It rendered properly when the weird message above appears in the DOM. */
const element = TestUtils.findRenderedDOMComponentWithTag(tree, 'span');
expect(element.getDOMNode().textContent).to.equal('Hello, ladies!');
});
});
| Add bare minimum test for store-watch. | Add bare minimum test for store-watch.
| JSX | mit | eddieantonio/fluxxor-components | ---
+++
@@ -0,0 +1,48 @@
+/*globals describe, it*/
+/*eslint no-unused-expressions: false*/
+import chai, {expect} from 'chai';
+
+/* Must import testdom before React. */
+import testdom from 'testdom';
+testdom('<html><body></body></html>');
+
+import React from 'react';
+import Fluxxor from 'fluxxor';
+
+import 'react/addons';
+const {TestUtils} = React.addons;
+
+import {watchStores, createFluxContext} from '..';
+
+function createContext(delegateRender) {
+ const flux = new Fluxxor.Flux({}, {});
+
+ return createFluxContext(flux, class Context extends React.Component {
+ render() {
+ return delegateRender();
+ }
+ });
+}
+
+describe('watchStores', () => {
+ it('wraps an existing React component', () => {
+ class DummyComponent extends React.Component {
+ render() {
+ return <span>Hello, ladies!</span>;
+ }
+ }
+
+ const Component = watchStores(DummyComponent, () => ({}));
+ expect(<Component />).to.satisfy(TestUtils.isElement);
+
+ /* Render the component within a context. */
+ const Context = createContext(() => <Component />);
+
+ /* Render the instance: */
+ const tree = TestUtils.renderIntoDocument(<Context />);
+
+ /* It rendered properly when the weird message above appears in the DOM. */
+ const element = TestUtils.findRenderedDOMComponentWithTag(tree, 'span');
+ expect(element.getDOMNode().textContent).to.equal('Hello, ladies!');
+ });
+}); |
|
529c4d2c8ab0f34c58a6ee1c5857023876b5b626 | t/run/096.null-for-function-arg.todo.jsx | t/run/096.null-for-function-arg.todo.jsx | /*EXPECTED
null
*/
class Test {
static function f(funcArg : function():void) : void {
log funcArg;
}
static function run() : void {
Test.f(null);
}
}
| Add a TODO test to give null as a function arg | Add a TODO test to give null as a function arg
| JSX | mit | dj31416/JSX,jsx/JSX,dj31416/JSX,mattn/JSX,jsx/JSX,jsx/JSX,dj31416/JSX,jsx/JSX,dj31416/JSX,mattn/JSX,dj31416/JSX,jsx/JSX | ---
+++
@@ -0,0 +1,13 @@
+/*EXPECTED
+null
+*/
+
+class Test {
+ static function f(funcArg : function():void) : void {
+ log funcArg;
+ }
+
+ static function run() : void {
+ Test.f(null);
+ }
+} |
|
4b08cf688f27edd3032aa2c560696c40c67cf50f | features/apimgt/org.wso2.carbon.apimgt.store.feature/src/main/resources/admin_new/source/src/app/components/APICategories/DeleteAPICategory.jsx | features/apimgt/org.wso2.carbon.apimgt.store.feature/src/main/resources/admin_new/source/src/app/components/APICategories/DeleteAPICategory.jsx | /*
* Copyright (c) 2020, 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 API from 'AppData/api';
import PropTypes from 'prop-types';
import DialogContentText from '@material-ui/core/DialogContentText';
import DeleteForeverIcon from '@material-ui/icons/DeleteForever';
import FormDialogBase from 'AppComponents/AdminPages/Addons/FormDialogBase';
/**
* API call to delete api category with uuid: id
* @param {number} id uuid of the api category to delete.
* @returns {Promise}.
*/
function apiCall(id) {
const restApi = new API();
return restApi.deleteAPICategory(id);
}
/**
* Render delete dialog box.
* @param {JSON} props component props.
* @returns {JSX} Loading animation.
*/
function Delete({ updateList, dataRow }) {
const { id } = dataRow;
const formSaveCallback = () => {
const promiseAPICall = apiCall(id);
promiseAPICall
.then((data) => {
updateList();
return data;
})
.catch((e) => {
return e;
});
return promiseAPICall;
};
return (
<FormDialogBase
title='Delete API category?'
saveButtonText='Delete'
icon={<DeleteForeverIcon />}
formSaveCallback={formSaveCallback}
>
<DialogContentText>
Are you sure you want to delete this API Category?
</DialogContentText>
</FormDialogBase>
);
}
Delete.propTypes = {
updateList: PropTypes.number.isRequired,
dataRow: PropTypes.shape({
id: PropTypes.number.isRequired,
}).isRequired,
};
export default Delete;
| Apply new theme for API Category delete | Apply new theme for API Category delete
| JSX | apache-2.0 | praminda/carbon-apimgt,tharikaGitHub/carbon-apimgt,nuwand/carbon-apimgt,chamindias/carbon-apimgt,chamilaadhi/carbon-apimgt,ruks/carbon-apimgt,isharac/carbon-apimgt,bhathiya/carbon-apimgt,tharikaGitHub/carbon-apimgt,chamilaadhi/carbon-apimgt,prasa7/carbon-apimgt,tharikaGitHub/carbon-apimgt,tharindu1st/carbon-apimgt,jaadds/carbon-apimgt,nuwand/carbon-apimgt,nuwand/carbon-apimgt,jaadds/carbon-apimgt,jaadds/carbon-apimgt,chamilaadhi/carbon-apimgt,nuwand/carbon-apimgt,jaadds/carbon-apimgt,prasa7/carbon-apimgt,chamindias/carbon-apimgt,tharindu1st/carbon-apimgt,isharac/carbon-apimgt,uvindra/carbon-apimgt,bhathiya/carbon-apimgt,chamindias/carbon-apimgt,tharindu1st/carbon-apimgt,ruks/carbon-apimgt,malinthaprasan/carbon-apimgt,bhathiya/carbon-apimgt,uvindra/carbon-apimgt,ruks/carbon-apimgt,Rajith90/carbon-apimgt,malinthaprasan/carbon-apimgt,sanjeewa-malalgoda/carbon-apimgt,wso2/carbon-apimgt,wso2/carbon-apimgt,malinthaprasan/carbon-apimgt,wso2/carbon-apimgt,Rajith90/carbon-apimgt,praminda/carbon-apimgt,isharac/carbon-apimgt,fazlan-nazeem/carbon-apimgt,fazlan-nazeem/carbon-apimgt,tharindu1st/carbon-apimgt,ruks/carbon-apimgt,sanjeewa-malalgoda/carbon-apimgt,Rajith90/carbon-apimgt,prasa7/carbon-apimgt,fazlan-nazeem/carbon-apimgt,malinthaprasan/carbon-apimgt,prasa7/carbon-apimgt,tharikaGitHub/carbon-apimgt,chamindias/carbon-apimgt,isharac/carbon-apimgt,uvindra/carbon-apimgt,bhathiya/carbon-apimgt,Rajith90/carbon-apimgt,chamilaadhi/carbon-apimgt,uvindra/carbon-apimgt,fazlan-nazeem/carbon-apimgt,wso2/carbon-apimgt,sanjeewa-malalgoda/carbon-apimgt,sanjeewa-malalgoda/carbon-apimgt,praminda/carbon-apimgt | ---
+++
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2020, 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 API from 'AppData/api';
+import PropTypes from 'prop-types';
+import DialogContentText from '@material-ui/core/DialogContentText';
+import DeleteForeverIcon from '@material-ui/icons/DeleteForever';
+import FormDialogBase from 'AppComponents/AdminPages/Addons/FormDialogBase';
+
+/**
+ * API call to delete api category with uuid: id
+ * @param {number} id uuid of the api category to delete.
+ * @returns {Promise}.
+ */
+function apiCall(id) {
+ const restApi = new API();
+ return restApi.deleteAPICategory(id);
+}
+
+/**
+ * Render delete dialog box.
+ * @param {JSON} props component props.
+ * @returns {JSX} Loading animation.
+ */
+function Delete({ updateList, dataRow }) {
+ const { id } = dataRow;
+
+ const formSaveCallback = () => {
+ const promiseAPICall = apiCall(id);
+
+ promiseAPICall
+ .then((data) => {
+ updateList();
+ return data;
+ })
+ .catch((e) => {
+ return e;
+ });
+ return promiseAPICall;
+ };
+
+ return (
+ <FormDialogBase
+ title='Delete API category?'
+ saveButtonText='Delete'
+ icon={<DeleteForeverIcon />}
+ formSaveCallback={formSaveCallback}
+ >
+ <DialogContentText>
+ Are you sure you want to delete this API Category?
+ </DialogContentText>
+ </FormDialogBase>
+ );
+}
+Delete.propTypes = {
+ updateList: PropTypes.number.isRequired,
+ dataRow: PropTypes.shape({
+ id: PropTypes.number.isRequired,
+ }).isRequired,
+};
+export default Delete; |
|
10907710e35a5e5e656f602b60b03db22c4950d6 | app/javascript/components/aggregate_status_card.jsx | app/javascript/components/aggregate_status_card.jsx | import React, { useEffect, useState } from 'react';
import PropTypes from 'prop-types';
import PfAggregateStatusCard from './pf_aggregate_status_card';
const AggregateStatusCard = ({ providerId, providerType }) => {
const [data, setCardData] = useState({ loading: true });
useEffect(() => {
const url = `/${providerType}_dashboard/aggregate_status_data/${providerId ? providerId : ''}`;
http.get(url)
.then(response => {
console.log(response);
const aggStatusData = response.data.aggStatus;
setCardData({
loading: false,
status: aggStatusData.status,
aggStatus: aggStatusData.attrData,
showTopBorder: aggStatusData.showTopBorder,
aggregateLayout: aggStatusData.aggregateLayout,
aggregateClass: aggStatusData.aggregateClass,
})
});
}, []);
if (data.loading) {
return <div>loading...</div>;
}
return (
<div className='aggregate_status'>
<div className='col-xs-12 col-sm-12 col-md-3 col-lg-2 here'>
<PfAggregateStatusCard
layout={data.aggregateLayout}
className={data.aggregateClass}
data={data.status}
showTopBorder={data.showTopBorder}
/>
</div>
<div className='col-xs-12 col-sm-12 col-md-9 col-lg-10'>
<div className='row'>
{ data.aggStatus.map( st => (
<div key={st.id} className='col-xs-12 col-sm-6 col-md-4 col-lg-3'>
<PfAggregateStatusCard
layout='mini'
id={st.id}
data={st}
showTopBorder={true}
/>
</div>
)
)}
</div>
</div>
</div>
);
};
AggregateStatusCard.propTypes = {
providerId: PropTypes.string,
providerType: PropTypes.string.isRequired,
};
export default AggregateStatusCard;
| Implement AggregateStatusCard in React (provider dashboard). | Implement AggregateStatusCard in React (provider dashboard).
| JSX | apache-2.0 | ManageIQ/manageiq-ui-classic,ManageIQ/manageiq-ui-classic,ManageIQ/manageiq-ui-classic,ManageIQ/manageiq-ui-classic | ---
+++
@@ -0,0 +1,64 @@
+import React, { useEffect, useState } from 'react';
+import PropTypes from 'prop-types';
+
+import PfAggregateStatusCard from './pf_aggregate_status_card';
+
+const AggregateStatusCard = ({ providerId, providerType }) => {
+ const [data, setCardData] = useState({ loading: true });
+
+ useEffect(() => {
+ const url = `/${providerType}_dashboard/aggregate_status_data/${providerId ? providerId : ''}`;
+ http.get(url)
+ .then(response => {
+ console.log(response);
+ const aggStatusData = response.data.aggStatus;
+ setCardData({
+ loading: false,
+ status: aggStatusData.status,
+ aggStatus: aggStatusData.attrData,
+ showTopBorder: aggStatusData.showTopBorder,
+ aggregateLayout: aggStatusData.aggregateLayout,
+ aggregateClass: aggStatusData.aggregateClass,
+ })
+ });
+ }, []);
+
+ if (data.loading) {
+ return <div>loading...</div>;
+ }
+
+ return (
+ <div className='aggregate_status'>
+ <div className='col-xs-12 col-sm-12 col-md-3 col-lg-2 here'>
+ <PfAggregateStatusCard
+ layout={data.aggregateLayout}
+ className={data.aggregateClass}
+ data={data.status}
+ showTopBorder={data.showTopBorder}
+ />
+ </div>
+ <div className='col-xs-12 col-sm-12 col-md-9 col-lg-10'>
+ <div className='row'>
+ { data.aggStatus.map( st => (
+ <div key={st.id} className='col-xs-12 col-sm-6 col-md-4 col-lg-3'>
+ <PfAggregateStatusCard
+ layout='mini'
+ id={st.id}
+ data={st}
+ showTopBorder={true}
+ />
+ </div>
+ )
+ )}
+ </div>
+ </div>
+ </div>
+ );
+};
+
+AggregateStatusCard.propTypes = {
+ providerId: PropTypes.string,
+ providerType: PropTypes.string.isRequired,
+};
+
+export default AggregateStatusCard; |
|
67fb23f6b6200bb2c728904a108434d2401c0575 | client/src/js/components/Viruses/HMM/Toolbar.jsx | client/src/js/components/Viruses/HMM/Toolbar.jsx | /**
* @license
* The MIT License (MIT)
* Copyright 2015 Government of Canada
*
* @author
* Ian Boyes
*
* @exports VirusToolbar
*/
'use strict';
var React = require('react');
var Icon = require('virtool/js/components/Base/Icon.jsx');
var Flex = require('virtool/js/components/Base/Flex.jsx');
var PushButton = require('virtool/js/components/Base/PushButton.jsx');
/**
* A toolbar component rendered at the top of the virus manager table. Allows searching of viruses by name and
* abbreviation. Includes a button for creating a new virus.
*/
var VirusToolbar = React.createClass({
propTypes: {
onChange: React.PropTypes.func
},
getInitialState: function () {
// The state showAdd is true when the modal should be visible.
return {
canModify: dispatcher.user.permissions.modify_hmm
};
},
componentDidMount: function () {
this.refs.input.focus();
dispatcher.user.on('change', this.onUserChange);
},
componentWillUnmount: function () {
dispatcher.user.off('change', this.onUserChange);
},
onUserChange: function () {
this.setState({
canModify: dispatcher.user.permissions.modify_hmm
});
},
/**
* Updates the function used to filter virus documents. Triggered by a change in the search input field.
*
* @func
*/
handleChange: function () {
var re = new RegExp(this.refs.input.value, 'i');
var filterFunction = function (document) {
return re.test(document.label) || re.test(document.cluster);
};
this.props.onChange(filterFunction);
},
/**
* Changes state to show the add or export modal form. Triggered by clicking the a menu item.
*
* @func
*/
showImport: function () {
dispatcher.router.setExtra(["import"])
},
render: function () {
var button;
var mayImport = dispatcher.collections.hmm.documents.length === 0;
if (this.state.canModify) {
button = (
<Flex.Item shrink={0} pad>
<PushButton bsStyle="primary" onClick={this.showImport} disabled={!mayImport}>
<Icon name="new-entry" /> Import
</PushButton>
</Flex.Item>
);
}
return (
<div style={{marginBottom: '15px'}}>
<Flex>
<Flex.Item grow={2}>
<div className='input-group'>
<span id='find-addon' className='input-group-addon'>
<Icon name='search' /> Find
</span>
<input
ref='input'
aria-describedby='find-addon'
className='form-control'
type='text'
placeholder='Definition or cluster'
onChange={this.handleChange}
/>
</div>
</Flex.Item>
{button}
</Flex>
</div>
);
}
});
module.exports = VirusToolbar; | Add HMM toolbar for filtering and importing annotations | Add HMM toolbar for filtering and importing annotations
| JSX | mit | virtool/virtool,igboyes/virtool,igboyes/virtool,virtool/virtool | ---
+++
@@ -0,0 +1,119 @@
+/**
+ * @license
+ * The MIT License (MIT)
+ * Copyright 2015 Government of Canada
+ *
+ * @author
+ * Ian Boyes
+ *
+ * @exports VirusToolbar
+ */
+
+'use strict';
+
+var React = require('react');
+
+var Icon = require('virtool/js/components/Base/Icon.jsx');
+var Flex = require('virtool/js/components/Base/Flex.jsx');
+var PushButton = require('virtool/js/components/Base/PushButton.jsx');
+
+/**
+ * A toolbar component rendered at the top of the virus manager table. Allows searching of viruses by name and
+ * abbreviation. Includes a button for creating a new virus.
+ */
+var VirusToolbar = React.createClass({
+
+ propTypes: {
+ onChange: React.PropTypes.func
+ },
+
+ getInitialState: function () {
+ // The state showAdd is true when the modal should be visible.
+ return {
+ canModify: dispatcher.user.permissions.modify_hmm
+ };
+ },
+
+ componentDidMount: function () {
+ this.refs.input.focus();
+ dispatcher.user.on('change', this.onUserChange);
+ },
+
+ componentWillUnmount: function () {
+ dispatcher.user.off('change', this.onUserChange);
+ },
+
+ onUserChange: function () {
+ this.setState({
+ canModify: dispatcher.user.permissions.modify_hmm
+ });
+ },
+
+ /**
+ * Updates the function used to filter virus documents. Triggered by a change in the search input field.
+ *
+ * @func
+ */
+ handleChange: function () {
+ var re = new RegExp(this.refs.input.value, 'i');
+
+ var filterFunction = function (document) {
+ return re.test(document.label) || re.test(document.cluster);
+ };
+
+ this.props.onChange(filterFunction);
+ },
+
+ /**
+ * Changes state to show the add or export modal form. Triggered by clicking the a menu item.
+ *
+ * @func
+ */
+ showImport: function () {
+ dispatcher.router.setExtra(["import"])
+ },
+
+ render: function () {
+
+ var button;
+
+ var mayImport = dispatcher.collections.hmm.documents.length === 0;
+
+ if (this.state.canModify) {
+ button = (
+ <Flex.Item shrink={0} pad>
+ <PushButton bsStyle="primary" onClick={this.showImport} disabled={!mayImport}>
+ <Icon name="new-entry" /> Import
+ </PushButton>
+ </Flex.Item>
+ );
+ }
+
+ return (
+ <div style={{marginBottom: '15px'}}>
+ <Flex>
+ <Flex.Item grow={2}>
+ <div className='input-group'>
+ <span id='find-addon' className='input-group-addon'>
+ <Icon name='search' /> Find
+ </span>
+ <input
+ ref='input'
+ aria-describedby='find-addon'
+ className='form-control'
+ type='text'
+ placeholder='Definition or cluster'
+ onChange={this.handleChange}
+ />
+ </div>
+ </Flex.Item>
+
+ {button}
+ </Flex>
+ </div>
+ );
+ }
+
+});
+
+module.exports = VirusToolbar; |
|
f80d18a9b6b20e8f209df064afbf789caa7e9678 | example/js/init.jsx | example/js/init.jsx | 'use strict';
import React from 'react/addons';
import App from './app';
let appWrapperEl = document.getElementById('app-wrapper'),
loadApp = e => React.render(<App />, appWrapperEl);
document.addEventListener('DOMContentLoaded', loadApp); | Build the jsx index source | Build the jsx index source
| JSX | mit | renemonroy/react-row,renemonroy/react-row | ---
+++
@@ -0,0 +1,9 @@
+'use strict';
+
+import React from 'react/addons';
+import App from './app';
+
+let appWrapperEl = document.getElementById('app-wrapper'),
+ loadApp = e => React.render(<App />, appWrapperEl);
+
+document.addEventListener('DOMContentLoaded', loadApp); |
|
c4240bd87fd7d9b9e16e0b5524827f56c559d6b5 | src/browser/components/UpdaterPage/UpdaterPage.stories.jsx | src/browser/components/UpdaterPage/UpdaterPage.stories.jsx | // Copyright (c) 2015-2016 Yuya Ochiai
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import React from 'react';
import {storiesOf} from '@storybook/react';
import {action} from '@storybook/addon-actions';
import UpdaterPage from '../UpdaterPage.jsx';
import '../../css/components/UpdaterPage.css';
/*
appName: propTypes.string.isRequired,
notifyOnly: propTypes.bool.isRequired,
isDownloading: propTypes.bool.isRequired,
progress: propTypes.number,
onClickInstall: propTypes.func.isRequired,
onClickDownload: propTypes.func.isRequired,
onClickReleaseNotes: propTypes.func.isRequired,
onClickRemind: propTypes.func.isRequired,
onClickSkip: propTypes.func.isRequired,
*/
const appName = 'Storybook App';
storiesOf('UpdaterPage', module).
add('Normal', () => (
<UpdaterPage
appName={appName}
notifyOnly={false}
isDownloading={false}
progress={0}
onClickInstall={action('clicked install')}
onClickReleaseNotes={action('clicked release notes')}
onClickRemind={action('clicked remind')}
onClickSkip={action('clicked skip')}
/>
)).
add('NotifyOnly', () => (
<UpdaterPage
appName={appName}
notifyOnly={true}
onClickDownload={action('clicked download')}
/>
)).
add('Downloading', () => (
<UpdaterPage
appName={appName}
isDownloading={true}
progress={0}
/>
));
| Add storybook file for UpdaterPage | Add storybook file for UpdaterPage
| JSX | apache-2.0 | mattermost/desktop,mattermost/desktop,mattermost/desktop,yuya-oc/electron-mattermost,yuya-oc/electron-mattermost,mattermost/desktop,yuya-oc/desktop,mattermost/desktop,yuya-oc/desktop,yuya-oc/electron-mattermost,yuya-oc/desktop | ---
+++
@@ -0,0 +1,52 @@
+// Copyright (c) 2015-2016 Yuya Ochiai
+// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
+// See LICENSE.txt for license information.
+
+import React from 'react';
+import {storiesOf} from '@storybook/react';
+
+import {action} from '@storybook/addon-actions';
+
+import UpdaterPage from '../UpdaterPage.jsx';
+import '../../css/components/UpdaterPage.css';
+
+/*
+appName: propTypes.string.isRequired,
+notifyOnly: propTypes.bool.isRequired,
+isDownloading: propTypes.bool.isRequired,
+progress: propTypes.number,
+onClickInstall: propTypes.func.isRequired,
+onClickDownload: propTypes.func.isRequired,
+onClickReleaseNotes: propTypes.func.isRequired,
+onClickRemind: propTypes.func.isRequired,
+onClickSkip: propTypes.func.isRequired,
+*/
+const appName = 'Storybook App';
+
+storiesOf('UpdaterPage', module).
+ add('Normal', () => (
+ <UpdaterPage
+ appName={appName}
+ notifyOnly={false}
+ isDownloading={false}
+ progress={0}
+ onClickInstall={action('clicked install')}
+ onClickReleaseNotes={action('clicked release notes')}
+ onClickRemind={action('clicked remind')}
+ onClickSkip={action('clicked skip')}
+ />
+ )).
+ add('NotifyOnly', () => (
+ <UpdaterPage
+ appName={appName}
+ notifyOnly={true}
+ onClickDownload={action('clicked download')}
+ />
+ )).
+ add('Downloading', () => (
+ <UpdaterPage
+ appName={appName}
+ isDownloading={true}
+ progress={0}
+ />
+ )); |
|
78968df16d12af4d41ca5a31e179c8994e3fb857 | app/server/bootstrap.jsx | app/server/bootstrap.jsx | Meteor.startup(() => {
if (Meteor.users.find().count() === 0) {
Accounts.createUser({
email: "dev@usecamino.com",
password: "sherpa"
});
}
});
| Add dummy user for development | Add dummy user for development
| JSX | mit | fjaguero/camino,fjaguero/camino | ---
+++
@@ -0,0 +1,10 @@
+Meteor.startup(() => {
+
+ if (Meteor.users.find().count() === 0) {
+ Accounts.createUser({
+ email: "dev@usecamino.com",
+ password: "sherpa"
+ });
+ }
+
+}); |
|
ee1cffe867801dd54949283cda2db4f7c41ada23 | src/scripts/components/lib/Adjustable.jsx | src/scripts/components/lib/Adjustable.jsx | /**
* @jsx React.DOM
*/
/**
* To adjust the size of the area
*/
'use strict';
var emptyFunction = require('react/lib/emptyFunction');
var Adjustable = React.createClass({
render: function() {
return (
<div />
);
}
});
module.exports = Adjustable; | Create a component to make the div area adjustable | Create a component to make the div area adjustable
| JSX | mit | haohcraft/react-webpack-starter | ---
+++
@@ -0,0 +1,22 @@
+/**
+ * @jsx React.DOM
+ */
+
+/**
+ * To adjust the size of the area
+ */
+'use strict';
+
+var emptyFunction = require('react/lib/emptyFunction');
+
+var Adjustable = React.createClass({
+
+ render: function() {
+ return (
+ <div />
+ );
+ }
+
+});
+
+module.exports = Adjustable; |
|
9a84fd97376d9f18c97d0a066e9c94bf730fdf41 | app/assets/javascripts/views/number_input_view.js.jsx | app/assets/javascripts/views/number_input_view.js.jsx | /** @jsx React.DOM */
var NumberInput = React.createClass({
componentWillMount: function() {
this.setState({
amount: this.props.startingAmount,
editable: this.props.alwaysEditable
});
},
componentDidMount: function() {
this.listenForChanges(this.refs.inputField && this.refs.inputField.getDOMNode());
},
componentDidUpdate: function() {
this.componentDidMount();
},
render: function() {
if (this.state.editable) {
return this.editable();
}
return this.uneditable();
},
editable: function() {
return (
<div className="input-group">
<input name={this.props.name} ref="inputField" type="number" className="form-control" min="0" step="0.1" defaultValue={this.state.amount}/>
<span className="input-group-addon">%</span>
</div>
);
},
uneditable: function() {
var self = this;
$('#edit-contract-' + this.props.user.username).click(function(e) {
$(self.props.confirmButton).css('visibility', 'hidden');
$(this).text() === 'Edit' ? $(this).text('Cancel') : $(this).text('Edit');
self.setState({ editable: !self.state.editable });
});
return (<span><strong>{this.props.startingAmount + '%'}</strong> tip when coins are minted</span>);
},
listenForChanges: function(node) {
$(node).on('change keydown', this.handleChange);
},
handleChange: function(e) {
var confirmLink = $(this.props.confirmButton);
if (!_.isEmpty(confirmLink)) {
var node = $(this.refs.inputField.getDOMNode());
if (node && node.val() !== this.props.startingAmount) {
confirmLink.css('visibility', 'visible');
confirmLink.off('click');
confirmLink.on('click', { node: node, self: this }, this.confirm);
} else {
confirmLink.css('visibility', 'hidden');
confirmLink.off('click');
}
}
},
confirm: function(e) {
var node = e.data.node;
var self = e.data.self;
var obj = {
contract: {
amount: node.val(),
user: this.props.user.id
}
};
_.debounce($.ajax({
url: self.props.updatePath,
method: 'PATCH',
data: obj,
success: self.handleSuccess,
error: self.handleError
}), 300);
},
handleSuccess: function(data) {
window.location.reload(true);
},
handleError: function(jqxhr, status) {
console.error(status);
}
});
| Add number_input_view to version control | Add number_input_view to version control
| JSX | agpl-3.0 | assemblymade/meta,lachlanjc/meta,lachlanjc/meta,assemblymade/meta,assemblymade/meta,assemblymade/meta,lachlanjc/meta,lachlanjc/meta | ---
+++
@@ -0,0 +1,95 @@
+/** @jsx React.DOM */
+
+var NumberInput = React.createClass({
+ componentWillMount: function() {
+ this.setState({
+ amount: this.props.startingAmount,
+ editable: this.props.alwaysEditable
+ });
+ },
+
+ componentDidMount: function() {
+ this.listenForChanges(this.refs.inputField && this.refs.inputField.getDOMNode());
+ },
+
+ componentDidUpdate: function() {
+ this.componentDidMount();
+ },
+
+ render: function() {
+ if (this.state.editable) {
+ return this.editable();
+ }
+
+ return this.uneditable();
+ },
+
+ editable: function() {
+ return (
+ <div className="input-group">
+ <input name={this.props.name} ref="inputField" type="number" className="form-control" min="0" step="0.1" defaultValue={this.state.amount}/>
+ <span className="input-group-addon">%</span>
+ </div>
+ );
+ },
+
+ uneditable: function() {
+ var self = this;
+
+ $('#edit-contract-' + this.props.user.username).click(function(e) {
+ $(self.props.confirmButton).css('visibility', 'hidden');
+ $(this).text() === 'Edit' ? $(this).text('Cancel') : $(this).text('Edit');
+ self.setState({ editable: !self.state.editable });
+ });
+
+ return (<span><strong>{this.props.startingAmount + '%'}</strong> tip when coins are minted</span>);
+ },
+
+ listenForChanges: function(node) {
+ $(node).on('change keydown', this.handleChange);
+ },
+
+ handleChange: function(e) {
+ var confirmLink = $(this.props.confirmButton);
+
+ if (!_.isEmpty(confirmLink)) {
+ var node = $(this.refs.inputField.getDOMNode());
+
+ if (node && node.val() !== this.props.startingAmount) {
+ confirmLink.css('visibility', 'visible');
+ confirmLink.off('click');
+ confirmLink.on('click', { node: node, self: this }, this.confirm);
+ } else {
+ confirmLink.css('visibility', 'hidden');
+ confirmLink.off('click');
+ }
+ }
+ },
+
+ confirm: function(e) {
+ var node = e.data.node;
+ var self = e.data.self;
+ var obj = {
+ contract: {
+ amount: node.val(),
+ user: this.props.user.id
+ }
+ };
+
+ _.debounce($.ajax({
+ url: self.props.updatePath,
+ method: 'PATCH',
+ data: obj,
+ success: self.handleSuccess,
+ error: self.handleError
+ }), 300);
+ },
+
+ handleSuccess: function(data) {
+ window.location.reload(true);
+ },
+
+ handleError: function(jqxhr, status) {
+ console.error(status);
+ }
+}); |
|
0679f444877006966a737654897309c969aed660 | src/components/head/new_page.jsx | src/components/head/new_page.jsx | /**
* @license Apache-2.0
*
* Copyright (c) 2021 The Stdlib Authors.
*
* 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.
*/
// MODULES //
import React from 'react';
import { Helmet } from 'react-helmet-async';
// MAIN //
/**
* Component for updating the `<head>` of the document when navigating to a new page.
*
* @private
* @param {Object} props - component properties
* @param {string} props.title - document title
* @param {string} props.description - document description
* @param {string} props.url - document URL
* @returns {ReactElement} React element
*/
function Head( props ) {
var t = props.title + ' | stdlib';
return (
<Helmet>
<title>{ t }</title>
<meta name="description" content={ props.description } />
<link rel="canonical" href={ props.url } />
<meta property="og:url" content={ props.url } />
<meta property="og:title" content={ t } />
<meta property="og:description" content={ props.description } />
<meta name="twitter:card" content={ t } />
<meta name="twitter:url" content={ props.url } />
<meta name="twitter:description" content={ props.description } />
</Helmet>
);
}
// EXPORTS //
export default Head;
| Add component for updating the document head when navigating to a new page | Add component for updating the document head when navigating to a new page
| JSX | apache-2.0 | stdlib-js/www,stdlib-js/www,stdlib-js/www | ---
+++
@@ -0,0 +1,60 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2021 The Stdlib Authors.
+*
+* 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.
+*/
+
+// MODULES //
+
+import React from 'react';
+import { Helmet } from 'react-helmet-async';
+
+
+// MAIN //
+
+/**
+* Component for updating the `<head>` of the document when navigating to a new page.
+*
+* @private
+* @param {Object} props - component properties
+* @param {string} props.title - document title
+* @param {string} props.description - document description
+* @param {string} props.url - document URL
+* @returns {ReactElement} React element
+*/
+function Head( props ) {
+ var t = props.title + ' | stdlib';
+ return (
+ <Helmet>
+ <title>{ t }</title>
+ <meta name="description" content={ props.description } />
+
+ <link rel="canonical" href={ props.url } />
+
+ <meta property="og:url" content={ props.url } />
+ <meta property="og:title" content={ t } />
+ <meta property="og:description" content={ props.description } />
+
+ <meta name="twitter:card" content={ t } />
+ <meta name="twitter:url" content={ props.url } />
+ <meta name="twitter:description" content={ props.description } />
+ </Helmet>
+ );
+}
+
+
+// EXPORTS //
+
+export default Head; |
|
1683161581bb8f71bfb364ed4ace13135f68a4a1 | app/app/components/home/RegisteredUserHome.jsx | app/app/components/home/RegisteredUserHome.jsx | import React from 'react';
import {Link} from 'react-router'
import auth from '../../utils/auth.jsx'
export default class RegisteredUserHome extends React.Component {
componentWillMount() {
auth.getUser(localStorage.id).then((res) => {
console.log(res.data)
this.user = res.data.user
})
}
render(){
return(
<div className="starter-template">
<h1>Welcome Back, {this.user.first_name}</h1>
<p className="lead">Cras justo odio, dapibus ac facilisis in, egestas eget quam. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus.</p>
</div>
)
}
} | Rename and add home page component for logged in userse | Rename and add home page component for logged in userse
| JSX | mit | taodav/MicroSerfs,taodav/MicroSerfs | ---
+++
@@ -0,0 +1,20 @@
+import React from 'react';
+import {Link} from 'react-router'
+import auth from '../../utils/auth.jsx'
+
+export default class RegisteredUserHome extends React.Component {
+ componentWillMount() {
+ auth.getUser(localStorage.id).then((res) => {
+ console.log(res.data)
+ this.user = res.data.user
+ })
+ }
+ render(){
+ return(
+ <div className="starter-template">
+ <h1>Welcome Back, {this.user.first_name}</h1>
+ <p className="lead">Cras justo odio, dapibus ac facilisis in, egestas eget quam. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus.</p>
+ </div>
+ )
+ }
+} |