hexsha
stringlengths 40
40
| size
int64 3
522k
| ext
stringclasses 1
value | lang
stringclasses 1
value | max_stars_repo_path
stringlengths 6
191
| max_stars_repo_name
stringlengths 6
110
| max_stars_repo_head_hexsha
stringlengths 40
40
| max_stars_repo_licenses
sequence | max_stars_count
int64 1
82k
⌀ | max_stars_repo_stars_event_min_datetime
stringlengths 24
24
⌀ | max_stars_repo_stars_event_max_datetime
stringlengths 24
24
⌀ | max_issues_repo_path
stringlengths 6
191
| max_issues_repo_name
stringlengths 6
110
| max_issues_repo_head_hexsha
stringlengths 40
40
| max_issues_repo_licenses
sequence | max_issues_count
int64 1
74.7k
⌀ | max_issues_repo_issues_event_min_datetime
stringlengths 24
24
⌀ | max_issues_repo_issues_event_max_datetime
stringlengths 24
24
⌀ | max_forks_repo_path
stringlengths 6
191
| max_forks_repo_name
stringlengths 6
110
| max_forks_repo_head_hexsha
stringlengths 40
40
| max_forks_repo_licenses
sequence | max_forks_count
int64 1
17.8k
⌀ | max_forks_repo_forks_event_min_datetime
stringlengths 24
24
⌀ | max_forks_repo_forks_event_max_datetime
stringlengths 24
24
⌀ | content
stringlengths 3
522k
| avg_line_length
float64 3
44.5k
| max_line_length
int64 3
401k
| alphanum_fraction
float64 0.08
1
| tabs_spaces.tabs
bool 2
classes | tabs_spaces.spaces
bool 2
classes | react_component.class
bool 2
classes | react_component.function
bool 2
classes |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
d00007f0967a66b9c4a913ae7c1b9fd081b75263 | 556 | jsx | JSX | src/js/containers/pages/ArrayHookPage.jsx | react-custom-projects/custom-react-hooks | 1a28a9209cc8db20c3abc0ac58a6d8ece5a6b5ad | [
"MIT"
] | null | null | null | src/js/containers/pages/ArrayHookPage.jsx | react-custom-projects/custom-react-hooks | 1a28a9209cc8db20c3abc0ac58a6d8ece5a6b5ad | [
"MIT"
] | null | null | null | src/js/containers/pages/ArrayHookPage.jsx | react-custom-projects/custom-react-hooks | 1a28a9209cc8db20c3abc0ac58a6d8ece5a6b5ad | [
"MIT"
] | null | null | null | import React from 'react';
//custom hooks
import useArray from '../../customHooks/UseArray';
const ArrayHookPage = () => {
const toDos = useArray([]);
return (
<div className="magnify-container">
<h3>ToDos</h3>
<button onClick={() => toDos.add(Math.random())}>Add</button>
<ul>
{toDos.value.map((el, i) => (
<li key={i}>
{el} <button onClick={() => toDos.removeByIndex(i)}>Delete</button>
</li>
))}
</ul>
<button onClick={() => toDos.clear()}>Clear Todos</button>
</div>
);
};
export default ArrayHookPage;
| 22.24 | 73 | 0.591727 | true | false | false | true |
d00009246fb13dcca8132937d1f4a1baaac1b137 | 8,866 | jsx | JSX | src/tools/webui/src/components/pages/Configuration.jsx | mpranj/libelektra | 373a87dad9101a875aeb79abc8e49560612af2bc | [
"MIT",
"BSD-3-Clause-Clear",
"Apache-2.0",
"BSD-3-Clause"
] | 188 | 2015-01-07T20:34:26.000Z | 2022-03-16T09:55:09.000Z | src/tools/webui/src/components/pages/Configuration.jsx | mpranj/libelektra | 373a87dad9101a875aeb79abc8e49560612af2bc | [
"MIT",
"BSD-3-Clause-Clear",
"Apache-2.0",
"BSD-3-Clause"
] | 3,813 | 2015-01-02T14:00:08.000Z | 2022-03-31T14:19:11.000Z | src/tools/webui/src/components/pages/Configuration.jsx | mpranj/libelektra | 373a87dad9101a875aeb79abc8e49560612af2bc | [
"MIT",
"BSD-3-Clause-Clear",
"Apache-2.0",
"BSD-3-Clause"
] | 149 | 2015-01-10T02:07:50.000Z | 2022-03-16T09:50:24.000Z | /**
* @file
*
* @brief this is the configuration page
*
* it renders the interactive tree view
*
* @copyright BSD License (see LICENSE.md or https://www.libelektra.org)
*/
import React, { Component } from "react";
import { Card, CardHeader, CardText } from "material-ui/Card";
import IconButton from "material-ui/IconButton";
import NavigationRefresh from "material-ui/svg-icons/navigation/refresh";
import TreeView from "../../containers/ConnectedTreeView";
import TreeSearch from "../../containers/ConnectedTreeSearch";
import InstanceError from "../InstanceError.jsx";
const NAMESPACES = ["user", "system", "spec", "dir"];
// create tree structure from kdb ls result (list of available keys)
const partsTree = (acc, parts) => {
if (parts.length <= 0) return acc;
const part = parts.shift();
if (!acc[part]) acc[part] = {};
partsTree(acc[part], parts);
return acc;
};
const createTree = (ls) =>
ls.reduce((acc, item) => {
return partsTree(acc, item.split("/"));
}, {});
const parseDataSet = (
getKey,
sendNotification,
instanceId,
tree,
path,
parent
) => {
return Object.keys(tree).map((key) => {
const newPath = path ? path + "/" + key : key;
let data = {
name: key,
path: newPath,
root: !path,
parent: parent,
};
const children = parseDataSet(
getKey,
sendNotification,
instanceId,
tree[key],
newPath,
data
);
data.children =
Array.isArray(children) && children.length > 0
? (notify = true) => {
return new Promise((resolve) => {
getKey(instanceId, newPath, true);
resolve(children);
});
}
: false;
return data;
});
};
const parseData = (getKey, sendNotification, instanceId, ls, kdb) => {
if (!Array.isArray(ls)) return;
const tree = createTree(ls);
return parseDataSet(getKey, sendNotification, instanceId, tree);
};
const getUnfolded = (searchResults) => {
let unfolded = [];
for (let r of searchResults) {
const parts = r.split("/");
let path = "";
for (let p of parts) {
path = path.length === 0 ? p : path + "/" + p;
if (!unfolded.includes(path)) {
unfolded.push(path);
}
}
}
return unfolded;
};
// configuration page
export default class Configuration extends Component {
constructor(props, ...rest) {
super(props, ...rest);
const { getKdb, match } = props;
const { id } = match && match.params;
getKdb(id);
this.state = { data: this.generateData(props) || [] };
}
componentWillReceiveProps(nextProps) {
this.setState({ data: this.generateData(nextProps) || [] });
}
updateKey = (data, [keyPath, ...paths], keyData) =>
Array.isArray(data)
? data.map((d) => {
if (d.name === keyPath) {
if (paths.length > 0) {
// recurse deeper
return {
...d,
children: this.updateKey(d.children, paths, keyData),
};
}
// we found the key, replace data
return keyData;
}
// not the path we want to edit
return d;
})
: data;
updateData = (keyData, paths) => {
const { data } = this.state;
const newData = this.updateKey(data, paths, keyData);
return this.setState({ data: newData });
};
waitForData = () => {
const { sendNotification } = this.props;
const { data } = this.state;
const user = Array.isArray(data) && data.find((d) => d.path === "user");
if (!user || !user.children) {
this.timeout = setTimeout(this.waitForData, 100);
} else {
this.preload(data).then(() =>
sendNotification("configuration data loaded!")
);
}
};
componentDidMount() {
this.waitForData();
}
generateData = ({ ls, match, getKey }) => {
const { id } = match && match.params;
const { sendNotification } = this.props;
return parseData(getKey, sendNotification, id, [...NAMESPACES, ...ls]);
};
refresh = () => {
return window.location.reload();
};
preload = async (tree, paths = [], levels = 1) => {
if (!tree) return await Promise.resolve(tree);
return await Promise.all(
tree.map(async (item, i) => {
let { children } = item;
if (!children) return item;
const childItems =
typeof children === "function"
? await children(false) // resolve children if necessary
: children;
const newPaths = [...paths, item.name];
let promises = [
this.updateData(
{
...item,
children: childItems,
},
newPaths
),
];
if (levels > 0) {
if (NAMESPACES.includes(newPaths.indexOf(0))) {
promises.push(this.preload(childItems, newPaths, levels - 1));
}
}
return Promise.all(promises);
})
);
};
render() {
const { instance, match, instanceError, search } = this.props;
const { data } = this.state;
if (instanceError) {
return (
<Card>
<CardHeader
title={
<h1>
<b>404</b> instance not found
</h1>
}
/>
<CardText>
<InstanceError
instance={instance}
error={instanceError}
refresh={this.refresh}
/>
</CardText>
</Card>
);
}
if (!instance) {
const title = (
<h1>
<b>Loading instance...</b> please wait
</h1>
);
return (
<Card>
<CardHeader title={title} />
</Card>
);
}
const { id } = match && match.params;
const { name, description, host, visibility } = instance;
const title = (
<h1>
<b>{name}</b>
<IconButton
className="hoverEffect"
style={{ marginLeft: 6, width: 28, height: 28, padding: 6 }}
iconStyle={{ width: 16, height: 16 }}
onClick={this.refresh}
tooltip="refresh"
>
<NavigationRefresh />
</IconButton>
</h1>
);
const isSearching = search && search.done;
const hasResults = search && search.results && search.results.length > 0;
const searchError = search && search.error;
const filteredData =
isSearching && hasResults
? this.generateData({ ...this.props, ls: search.results })
: data;
const autoUnfold =
isSearching &&
hasResults &&
search.results &&
search.results.length <= 10;
const filteredInstance = autoUnfold
? { ...instance, unfolded: getUnfolded(search.results) }
: instance;
return (
<Card style={{ padding: "8px 16px" }}>
<CardHeader
title={title}
subtitle={
<span>
{description ? description + " — " : ""}
host: <span style={{ opacity: 0.7 }}>{host}</span>
— visibility:{" "}
<span style={{ opacity: 0.7 }}>{visibility}</span>
</span>
}
/>
<CardText>
{instanceError ? (
<InstanceError
instance={instance}
error={instanceError}
refresh={this.refresh}
/>
) : data && Array.isArray(data) && data.length > 0 ? (
[
<TreeSearch instanceId={id} />,
searchError ? (
<div
style={{
fontSize: "1.1em",
color: "rgba(0, 0, 0, 0.4)",
marginTop: "1.5em",
padingLeft: "0.5em",
}}
>
<b>{searchError.name}:</b> {searchError.message}
</div>
) : isSearching && !hasResults ? (
<div
style={{
fontSize: "1.1em",
color: "rgba(0, 0, 0, 0.4)",
marginTop: "1.5em",
padingLeft: "0.5em",
}}
>
No results found for "{search.query}".
</div>
) : (
<TreeView
searching={isSearching || (search && search.clearing)}
instance={filteredInstance}
instanceId={id}
data={filteredData}
instanceVisibility={visibility}
/>
),
]
) : (
<div style={{ fontSize: "1.1em", color: "rgba(0, 0, 0, 0.4)" }}>
Loading configuration data...
</div>
)}
</CardText>
</Card>
);
}
}
| 26.153392 | 77 | 0.498195 | false | true | true | false |
d0000dce55c161037f27e15cb22892616fa3941f | 1,447 | jsx | JSX | src/modules/landing-page/components/About.jsx | StudioKarsa/studiokarsa-web | ddf4bedf99e74fdb414577f85262f7f1c2530700 | [
"RSA-MD"
] | 7 | 2021-06-23T03:07:34.000Z | 2021-09-17T15:30:02.000Z | src/modules/landing-page/components/About.jsx | StudioKarsa/studiokarsa.tech | ddf4bedf99e74fdb414577f85262f7f1c2530700 | [
"RSA-MD"
] | 2 | 2021-07-11T13:23:33.000Z | 2021-07-12T14:33:15.000Z | src/modules/landing-page/components/About.jsx | StudioKarsa/studiokarsa.tech | ddf4bedf99e74fdb414577f85262f7f1c2530700 | [
"RSA-MD"
] | null | null | null | import React from 'react'
import { useTranslation } from 'react-i18next'
import { Link } from 'gatsby'
import TeamSVG from '../../../assets/images/team.svg'
import ArrowSVG from '../../../assets/icons/arrow.svg'
const About = () => {
const { t } = useTranslation()
return (
<div id="section-about" className="flex flex-col px-6 md:px-20 space-y-2">
<div className="flex flex-col">
<h2 className="text-2xl lg:text-3xl font-medium text-primary tracking-wide uppercase">
{t('landingPage.about.title')}
</h2>
<h2 className="text-2xl lg:text-4xl font-semibold tracking-wider">
{t('landingPage.about.subtitle')}
</h2>
</div>
<div className="flex flex-col md:flex-row justify-between">
<div className="w-full md:w-1/2 p-2 md:p-8">
<TeamSVG className="w-full h-full" />
</div>
<div className="flex w-full md:w-1/2 p-2 md:p-8 text-lg">
<div className="my-auto">
<p>{t('landingPage.about.content')}</p>
<br />
<Link
to="/"
className="group font-semibold flex flex-row items-center hover:underline"
>
{t('common.learnMore')}
<ArrowSVG className="w-5 h-5 ml-12 group-hover:transform group-hover:translate-x-4 duration-200" />
</Link>
</div>
</div>
</div>
</div>
)
}
export default About
| 32.886364 | 113 | 0.564616 | false | true | false | true |
d0001cdfec9f7208b4c756359d08eeed65b74d24 | 1,033 | jsx | JSX | agile/src/app/agile/containers/project/Backlog/BacklogComponent/SprintComponent/SprintItemComponent/BacklogHeader.jsx | choerodon/choerodon-front-agile | 0275762f89d3ee9e9e624fb729ba67494f73c823 | [
"Apache-2.0"
] | 17 | 2018-06-08T08:35:43.000Z | 2021-11-19T06:29:29.000Z | agile/src/app/agile/containers/project/Backlog/BacklogComponent/SprintComponent/SprintItemComponent/BacklogHeader.jsx | choerodon/choerodon-front-agile | 0275762f89d3ee9e9e624fb729ba67494f73c823 | [
"Apache-2.0"
] | null | null | null | agile/src/app/agile/containers/project/Backlog/BacklogComponent/SprintComponent/SprintItemComponent/BacklogHeader.jsx | choerodon/choerodon-front-agile | 0275762f89d3ee9e9e624fb729ba67494f73c823 | [
"Apache-2.0"
] | 16 | 2018-06-08T09:58:32.000Z | 2020-01-02T09:47:59.000Z | import React, { Component } from 'react';
import { observer, inject } from 'mobx-react';
import SprintName from './SprintHeaderComponent/SprintName';
import SprintVisibleIssue from './SprintHeaderComponent/SprintVisibleIssue';
import '../Sprint.scss';
import BacklogStore from '../../../../../../stores/project/backlog/BacklogStore';
@inject('AppState', 'HeaderStore')
@observer class BacklogHeader extends Component {
render() {
const {
data, expand, toggleSprint, sprintId, issueCount,
} = this.props;
return (
<div className="c7n-backlog-sprintTop">
<div className="c7n-backlog-springTitle">
<div className="c7n-backlog-sprintTitleSide">
<SprintName
type="backlog"
expand={expand}
sprintName="待办事项"
toggleSprint={toggleSprint}
/>
<SprintVisibleIssue
issueCount={issueCount}
/>
</div>
</div>
</div>
);
}
}
export default BacklogHeader;
| 28.694444 | 81 | 0.607938 | false | true | true | false |
d0002670d92c11e085f8d1f77fe233fe479265e9 | 1,166 | jsx | JSX | imports/ui2/components/TabNav.jsx | gabijuns/liane-toolkit | 583304cb4396c342bfec32532b37d0827d952c38 | [
"MIT"
] | null | null | null | imports/ui2/components/TabNav.jsx | gabijuns/liane-toolkit | 583304cb4396c342bfec32532b37d0827d952c38 | [
"MIT"
] | null | null | null | imports/ui2/components/TabNav.jsx | gabijuns/liane-toolkit | 583304cb4396c342bfec32532b37d0827d952c38 | [
"MIT"
] | null | null | null | import React, { Component } from "react";
import styled, { css } from "styled-components";
const Container = styled.nav`
display: flex;
align-items: center;
justify-content: center;
margin: 0 0 2rem;
font-size: 0.8em;
font-weight: 600;
background: #333;
a {
text-align: center;
flex: 1 1 auto;
color: #666;
padding: 0.5rem 1rem;
text-decoration: none;
border-bottom: 2px solid transparent;
&:hover,
&:active,
&:focus {
color: #000;
border-color: #eee;
}
&.active {
color: #333;
border-color: #000;
}
}
${props =>
props.dark &&
css`
background: #333;
a {
color: rgba(255, 255, 255, 0.6);
&:hover,
&:active,
&:focus {
color: #fff;
border-color: rgba(0, 0, 0, 0.3);
}
&.active {
color: #f7f7f7;
border-color: #212121;
}
}
`}
`;
export default class TabNav extends Component {
render() {
const { children, ...props } = this.props;
return (
<Container {...props} className="tab-nav">
{children}
</Container>
);
}
}
| 19.433333 | 48 | 0.517153 | false | true | true | false |
d00029d7001284f38d3aea4994b1015b4b333ba8 | 6,444 | jsx | JSX | src/pages/staff/food/AddFood.jsx | CS2102-Team-51/main | 99198373ca74b16528df9184fab1e1d9a900951f | [
"MIT"
] | null | null | null | src/pages/staff/food/AddFood.jsx | CS2102-Team-51/main | 99198373ca74b16528df9184fab1e1d9a900951f | [
"MIT"
] | 6 | 2020-03-29T18:58:20.000Z | 2020-03-29T19:14:55.000Z | src/pages/staff/food/AddFood.jsx | CS2102-Team-51/main | 99198373ca74b16528df9184fab1e1d9a900951f | [
"MIT"
] | 2 | 2020-02-07T15:17:59.000Z | 2020-02-08T07:04:35.000Z | import React, {Component} from 'react';
import Button from '@material-ui/core/Button';
import TextField from '@material-ui/core/TextField';
import Dialog from '@material-ui/core/Dialog';
import DialogActions from '@material-ui/core/DialogActions';
import DialogContent from '@material-ui/core/DialogContent';
import DialogContentText from '@material-ui/core/DialogContentText';
import DialogTitle from '@material-ui/core/DialogTitle';
import Radio from '@material-ui/core/Radio';
import RadioGroup from '@material-ui/core/RadioGroup';
import {FormControlLabel} from '@material-ui/core';
import * as apiRoute from '../../../components/Api/route';
import Axios from 'axios';
export default class AddRestaurant extends Component {
constructor () {
super ();
this.state = {
success: false,
rname: '',
raddress: '',
rmincost: '',
};
this._handleClose = this._handleClose.bind (this);
this._handleRegister = this._handleRegister.bind (this);
this._showSuccess = this._showSuccess.bind (this);
}
componentDidMount () {}
componentDidUpdate (prevProps) {
if (this.props.setOpen !== prevProps.setOpen) {
console.log ('This is my status: ', this.props.status);
console.log ('This is my food: ', this.props.singleFood);
if (this.props.status === 'Edit') {
this.setState ({
fname: this.props.singleFood[3],
fprice: this.props.singleFood[4],
favailable: this.props.singleFood[2],
flimit: this.props.singleFood[2],
});
}
}
}
_handleClose = () => {
this.setState ({
success: false,
showError: '',
fname: '',
fprice: '',
favailable: '',
flimit: '',
});
this.props.updateSetOpen (false);
};
_handleRegister = () => {
let food = {
fname: this.state.fname.trim (),
fprice: this.state.fprice.trim (),
favailable: this.state.favailable.trim (),
flimit: this.state.flimit.trim (),
};
if (this.props.status === 'Create') {
Axios.post (apiRoute.FOOD_API + '/post/' + this.props.rid, food, {
withCredentials: false,
})
.then (response => {
console.log (response);
this._showSuccess ();
this.props.fetchFood ();
})
.catch (error => {
console.log (error);
});
} else {
Axios.put (
apiRoute.FOOD_API + '/update/' + this.props.singleFood.fid + '/' + this.props.rid,
food,
{
withCredentials: false,
}
)
.then (response => {
console.log (response);
this._showSuccess ();
this.props.fetchFood ();
})
.catch (error => {
console.log (error);
this._showError ('nameTaken');
});
}
};
_showSuccess () {
this.setState ({
success: true,
showError: '',
});
}
updateFname (event) {
this.setState ({
fname: event.target.value,
});
}
updateFprice (event) {
this.setState ({
fprice: event.target.value,
});
}
updateFavailable (event) {
this.setState ({
favailable: event.target.value,
});
}
updateFlimit (event) {
this.setState ({
flimit: event.target.value,
});
}
render () {
return (
<div>
<Dialog
open={this.props.setOpen}
onClose={this._handleClose}
aria-labelledby="form-dialog-title"
maxWidth="xl"
>
<DialogTitle id="form-dialog-title">
{this.props.status === 'Create'
? 'Register a Restaurant'
: 'Edit a Restaurant'}
</DialogTitle>
<DialogContent>
<DialogContentText>
You're one step away from bringing happiness (and food) to thousands of others!
</DialogContentText>
{this.state.showError
? <DialogContentText className="registrationError">
{this.state.showError}
</DialogContentText>
: ''}
{this.state.success && this.props.status === 'Create'
? <DialogContentText className="registrationSuccess">
Registration success!
</DialogContentText>
: ''}
{this.state.success && this.props.status === 'Edit'
? <DialogContentText className="registrationSuccess">
Update success!
</DialogContentText>
: ''}
<TextField
autoFocus
margin="dense"
value={this.state.fname}
onChange={e => this.updateFname (e)}
id="fullname"
label="Food Name"
variant="outlined"
inputProps={{maxLength: 50}}
required
fullWidth
/>
<TextField
margin="dense"
value={this.state.fprice}
onChange={e => this.updateFprice (e)}
id="username"
label="Food Price"
type="number"
variant="outlined"
inputProps={{maxLength: 50}}
required
fullWidth
/>
<TextField
margin="dense"
value={this.state.favailable}
onChange={e => this.updateFavailable (e)}
id="password"
label="Food Availability (true or false)"
type="boolean"
variant="outlined"
inputProps={{maxLength: 50}}
required
fullWidth
/>
<TextField
margin="dense"
value={this.state.flimit}
onChange={e => this.updateFlimit (e)}
id="password"
label="Food Limit"
type="number"
variant="outlined"
inputProps={{maxLength: 50}}
required
fullWidth
/>
</DialogContent>
<DialogActions>
<Button onClick={this._handleClose} color="primary">
Cancel
</Button>
<Button onClick={this._handleRegister} color="primary">
{this.props.status === 'Create' ? 'Create' : 'Update'}
</Button>
</DialogActions>
</Dialog>
</div>
);
}
}
| 28.387665 | 93 | 0.522036 | false | true | true | false |
d000322489ad25f38f083d1f2ff169902bf48c31 | 450 | jsx | JSX | designsystem/examples/form/Checkbox.jsx | NghiNg/designsystem | 548fdb7b32e0d956f29d098f001007936a22125e | [
"MIT"
] | null | null | null | designsystem/examples/form/Checkbox.jsx | NghiNg/designsystem | 548fdb7b32e0d956f29d098f001007936a22125e | [
"MIT"
] | null | null | null | designsystem/examples/form/Checkbox.jsx | NghiNg/designsystem | 548fdb7b32e0d956f29d098f001007936a22125e | [
"MIT"
] | null | null | null | import { Checkbox } from '@sb1/ffe-form-react';
<fieldset className="ffe-fieldset">
<legend className="ffe-form-label ffe-form-label--block">
Hvilke aviser leser du?
</legend>
<Checkbox name="newspapers" value="vg">
VG
</Checkbox>
<Checkbox name="newspapers" value="dagbladet">
Dagbladet
</Checkbox>
<Checkbox name="newspapers" value="aftenposten">
Aftenposten
</Checkbox>
</fieldset>
| 26.470588 | 61 | 0.637778 | false | true | false | true |
d000506f694749bd1135ef62724500540d5f2d33 | 1,955 | jsx | JSX | src/client/components/containers/EventsContainer.jsx | TWetmore/Swell | ed852fbb6079c63e7986adcf294c889c524109c8 | [
"MIT"
] | 10 | 2020-12-31T16:25:16.000Z | 2021-02-12T01:56:20.000Z | src/client/components/containers/EventsContainer.jsx | njfleming/Swell | 632fcd4df07f87ce813b6b8e042768fb47c89c91 | [
"MIT"
] | null | null | null | src/client/components/containers/EventsContainer.jsx | njfleming/Swell | 632fcd4df07f87ce813b6b8e042768fb47c89c91 | [
"MIT"
] | null | null | null | import React from 'react';
import {UnControlled as CodeMirror} from 'react-codemirror2';
import EmptyState from '../display/EmptyState';
import EventPreview from '../display/EventPreview';
import 'codemirror/theme/neo.css'
export default function EventsContainer({currentResponse}) {
const { request, response } = currentResponse;
if (!response || !response.events || response.events.length < 1) {
return (
<EmptyState connection={currentResponse.connection}/>
);
}
const { events, headers } = response;
let responseBody = '';
// If it's a stream or graphQL subscription
if (
(events && events.length > 1) ||
(headers?.["content-type"] && headers["content-type"].includes('stream')) ||
(currentResponse.graphQL && request.method === 'SUBSCRIPTION')
) {
let eventType = 'Stream';
if (currentResponse.graphQL && request.method === 'SUBSCRIPTION') {
eventType = 'Subscription'
}
events.forEach((event, idx) => {
const eventStr = JSON.stringify(event, null, 4);
responseBody += `-------------${eventType} Event ${idx + 1}-------------\n${eventStr}\n\n`;
});
}
// If it's a single response
else {
responseBody = JSON.stringify(events[0], null, 4);
}
return (
<div className="tab_content-response overflow-event-parent-container" id="events-display">
{request.method === 'GET' && (
<EventPreview
className='overflow-event-child-container'
contents={responseBody}
/>
)}
<div className='overflow-event-parent-container'>
<CodeMirror
className='overflow-event-child-container'
value={responseBody}
options={{
mode: 'application/json',
theme: 'neo responsebody',
lineNumbers: true,
tabSize: 4,
lineWrapping: true,
readOnly: true,
}}
/>
</div>
</div>
);
} | 28.75 | 97 | 0.596419 | false | true | false | true |
d0005faaed23832d240c25d2576b22049bdd76d6 | 2,660 | jsx | JSX | src/views/Projects.jsx | tschaeff/thor-news-gastbyjs-blog | c1ad216e1501823ee670a11274e8a39dfe1c0c06 | [
"MIT"
] | 8 | 2019-01-28T19:32:53.000Z | 2020-05-04T16:58:21.000Z | src/views/Projects.jsx | thorwebdev/thor-news-gastbyjs-blog | a5dc15814366abfce7b949b16440e821faea312b | [
"MIT"
] | 2 | 2019-01-13T11:10:00.000Z | 2019-02-05T00:08:28.000Z | src/views/Projects.jsx | thorwebdev/thor-news-gastbyjs-blog | a5dc15814366abfce7b949b16440e821faea312b | [
"MIT"
] | 2 | 2019-11-14T07:31:50.000Z | 2020-01-31T17:17:25.000Z | import React from "react";
import PropTypes from "prop-types";
import { Divider, DividerMiddle } from "../elements/Dividers";
import Content from "../elements/Content";
import Inner from "../elements/Inner";
import { UpDown, UpDownWide } from "../styles/animations";
import { colors } from "../../tailwind";
import SVG from "../components/SVG";
const Projects = ({ children }) => (
<>
<DividerMiddle
bg="linear-gradient(to right, SlateBlue 0%, DeepSkyBlue 100%)"
speed={-0.2}
offset={1.1}
factor={2}
/>
<Content speed={0.4} offset={1.2} factor={2}>
<Inner>{children}</Inner>
</Content>
<Divider speed={0.1} offset={1} factor={2}>
<UpDown>
<SVG icon="box" width={6} fill={colors.white} left="85%" top="75%" />
<SVG icon="upDown" width={8} fill={colors.teal} left="70%" top="20%" />
<SVG
icon="triangle"
width={8}
stroke={colors.orange}
left="25%"
top="5%"
/>
<SVG
icon="circle"
hiddenMobile
width={24}
fill={colors.white}
left="17%"
top="60%"
/>
</UpDown>
<UpDownWide>
<SVG
icon="arrowUp"
hiddenMobile
width={16}
fill={colors.green}
left="20%"
top="90%"
/>
<SVG
icon="triangle"
width={12}
stroke={colors.white}
left="90%"
top="30%"
/>
<SVG
icon="circle"
width={16}
fill={colors.yellow}
left="70%"
top="90%"
/>
<SVG
icon="triangle"
hiddenMobile
width={16}
stroke={colors.teal}
left="18%"
top="75%"
/>
<SVG icon="circle" width={6} fill={colors.white} left="75%" top="10%" />
<SVG
icon="upDown"
hiddenMobile
width={8}
fill={colors.green}
left="45%"
top="10%"
/>
</UpDownWide>
<SVG icon="circle" width={6} fill={colors.white} left="4%" top="20%" />
<SVG icon="circle" width={12} fill={colors.pink} left="80%" top="60%" />
<SVG icon="box" width={6} fill={colors.orange} left="10%" top="10%" />
<SVG icon="box" width={12} fill={colors.yellow} left="29%" top="26%" />
<SVG icon="hexa" width={16} stroke={colors.red} left="75%" top="30%" />
<SVG icon="hexa" width={8} stroke={colors.yellow} left="80%" top="70%" />
</Divider>
</>
);
export default Projects;
Projects.propTypes = {
children: PropTypes.node.isRequired
};
| 27.42268 | 80 | 0.495113 | false | true | false | true |
d00065730e697c5c4c86d6097e4d728a84db8d32 | 1,760 | jsx | JSX | src/components/Hero/Hero.jsx | tracey-web/portfolio | c301d7f4064939b0c6667781a2f070b550adb45e | [
"MIT"
] | null | null | null | src/components/Hero/Hero.jsx | tracey-web/portfolio | c301d7f4064939b0c6667781a2f070b550adb45e | [
"MIT"
] | null | null | null | src/components/Hero/Hero.jsx | tracey-web/portfolio | c301d7f4064939b0c6667781a2f070b550adb45e | [
"MIT"
] | null | null | null | import React, { useContext, useState, useEffect } from 'react';
import { Container } from 'react-bootstrap';
import Fade from 'react-reveal/Fade';
import { Link } from 'react-scroll';
import VideoBg from 'reactjs-videobg';
import PortfolioContext from '../../context/context';
import mp4 from '../../images/clouds.mp4';
import poster from '../../images/clouds.png';
const Header = () => {
const { hero } = useContext(PortfolioContext);
const { title, name, subtitle, cta } = hero;
const [isDesktop, setIsDesktop] = useState(false);
const [isMobile, setIsMobile] = useState(false);
useEffect(() => {
if (window.innerWidth > 769) {
setIsDesktop(true);
setIsMobile(false);
} else {
setIsMobile(true);
setIsDesktop(false);
}
}, []);
return (
<section id="hero" className="jumbotron">
<VideoBg poster={poster} wrapperClass="cloud-video">
<VideoBg.Source src={mp4} type="video/mp4" />
</VideoBg>
<Container>
<Fade left={isDesktop} bottom={isMobile} duration={1000} delay={500} distance="30px">
<h1 className="hero-title">
{title || 'Hi, my name is'}{' '}
<span className="text-color-main">{name || 'Tracey Hill'}</span>.
<br />
{subtitle || "I'm a software engineer."}
</h1>
</Fade>
<Fade left={isDesktop} bottom={isMobile} duration={1000} delay={1000} distance="30px">
<p className="hero-cta">
<span className="cta-btn cta-btn--hero">
<Link to="about" smooth duration={1000}>
{cta || 'Learn more'}
</Link>
</span>
</p>
</Fade>
</Container>
</section>
);
};
export default Header;
| 31.428571 | 94 | 0.576136 | false | true | false | true |
d0008858a0dc613211ac22def08629552334b7d0 | 1,408 | jsx | JSX | src/components/UserAccount/UserAccountDetails.jsx | MasterEatsPlatzi/Master-Eats | 5df6d8969040b2038303fd72c14098c932be987b | [
"MIT"
] | 1 | 2020-07-01T04:39:25.000Z | 2020-07-01T04:39:25.000Z | src/components/UserAccount/UserAccountDetails.jsx | MasterEatsPlatzi/Master-Eats | 5df6d8969040b2038303fd72c14098c932be987b | [
"MIT"
] | 6 | 2020-07-03T16:45:42.000Z | 2022-02-27T07:34:14.000Z | src/components/UserAccount/UserAccountDetails.jsx | MasterEatsPlatzi/Master-Eats | 5df6d8969040b2038303fd72c14098c932be987b | [
"MIT"
] | null | null | null | import React from 'react';
import './UserAccount.scss';
import { Link } from 'react-router-dom';
const UserAccountDetails = () => {
return (
<div className="UserAccount__container__menu-settings">
<h2>Mi cuenta</h2>
<form action="">
<div className="form-wrapper">
<div className="form-row">
<label htmlFor="name">Nombre</label><br />
<input type="text" id="name" placeholder="Juan Carlos" ></input>
</div>
<div className="form-row">
<label htmlFor="lname">Apellidos</label><br />
<input type="text" id="lname" placeholder="Martinez Barajas" ></input>
</div>
</div>
<div className="form-wrapper">
<div className="form-row">
<label htmlFor="email">Email</label><br />
<input type="email" id="email" name="email" placeholder="carlos4587@gmail.com" ></input>
</div>
<div className="form-row">
<label htmlFor="phone">Telefono</label><br />
<input type="tel" id="phone" name="phone" pattern="[0-9]{3}-[0-9]{2}-[0-9]{3}" placeholder="3203889058" ></input>
</div>
</div>
<div className="form-button">
<Link to="/success"><button type="submit" form="" value="Submit">Guardar</button></Link>
</div>
</form>
</div>
)
}
export default UserAccountDetails; | 37.052632 | 125 | 0.557528 | false | true | false | true |
d00098a2c0173690e38a34a5535312546bf46c61 | 1,098 | jsx | JSX | frontend/src/components/main/main.jsx | ChrisMeyer7088/PersonalSite | 6d068b5ac21a5134cfbddd6fb6bd24c33711c1f3 | [
"MIT"
] | null | null | null | frontend/src/components/main/main.jsx | ChrisMeyer7088/PersonalSite | 6d068b5ac21a5134cfbddd6fb6bd24c33711c1f3 | [
"MIT"
] | null | null | null | frontend/src/components/main/main.jsx | ChrisMeyer7088/PersonalSite | 6d068b5ac21a5134cfbddd6fb6bd24c33711c1f3 | [
"MIT"
] | null | null | null | import { useRef } from 'react';
import { Header } from '../header/header.jsx';
import { About } from '../about/about.jsx';
import { Work } from '../work/work.jsx';
import { Projects } from '../projects/projects.jsx';
import { Contact } from '../contact/contact.jsx';
import { Icons } from '../icons/icons.jsx'
import { useResize} from '../custom/useResize.jsx';
import styles from './main.scss';
export const Main = () => {
const ref = useRef();
const { width, height } = useResize(ref);
const isMobile = width < 600;
return (
<div ref={ref} className={styles.page}>
<Header width={width} />
<div className={styles.containerInfo}>
<section id="about" className={`${styles.section} ${styles.sectionHeight}`}><About /></section>
<section id="work" className={styles.section}><Work isMobile={isMobile} /></section>
<section id="projects" className={styles.section}><Projects isMobile={isMobile} /></section>
<section id="contact" className={styles.section}><Contact /></section>
</div>
{ !isMobile && <Icons />}
</div>
);
}; | 37.862069 | 103 | 0.632058 | false | true | false | true |
d000a72069056e997b16a99d18b964177805ac68 | 355 | jsx | JSX | Print/source/js/components/Title.jsx | kmakoto0212/kintone-plugins | 429ed92fd85c6bfa56863aabf059fbf73c85b6f6 | [
"MIT"
] | null | null | null | Print/source/js/components/Title.jsx | kmakoto0212/kintone-plugins | 429ed92fd85c6bfa56863aabf059fbf73c85b6f6 | [
"MIT"
] | null | null | null | Print/source/js/components/Title.jsx | kmakoto0212/kintone-plugins | 429ed92fd85c6bfa56863aabf059fbf73c85b6f6 | [
"MIT"
] | null | null | null | /* eslint-disable react/prop-types */
import React, {memo} from 'react';
import Label from '@components/Label';
import '@css/header';
const Title = ({title}) => {
return (
<>
<Label
className="header-title"
text={title}
fontSize="16px"
isVisible={!!title}
/>
</>
);
};
export default memo(Title);
| 17.75 | 38 | 0.560563 | false | true | false | true |
d000b3eaef0d8ffaa066f93e8c0d8c94bc1b8002 | 2,566 | jsx | JSX | src/components/Tables/Acessos.jsx | user-cube/ies_frontend | 406401eba6ade48b16634027c6648115ce060a0f | [
"MIT"
] | 1 | 2019-12-22T21:32:08.000Z | 2019-12-22T21:32:08.000Z | src/components/Tables/Acessos.jsx | user-cube/ies_frontend | 406401eba6ade48b16634027c6648115ce060a0f | [
"MIT"
] | null | null | null | src/components/Tables/Acessos.jsx | user-cube/ies_frontend | 406401eba6ade48b16634027c6648115ce060a0f | [
"MIT"
] | null | null | null | import React from "react";
// react component for creating dynamic tables
import ReactTable from "react-table";
class LastAccessTable extends React.Component {
constructor(props) {
super(props);
this.state = {
acessos: props.acessosX,
colums: [
{
Header: 'Ocorrência',
accessor: 'timestamp',
sortable: true,
minWidth: 400,
style: {
textAlign: "center",
height: "50px",
}
}, {
Header: 'Responsável',
accessor: 'user',
sortable: false,
filterable: true,
minWidth: 200,
style: {
textAlign: "center",
height: "50px",
}
}, {
Header: 'Ação',
accessor: 'action',
sortable: false,
filterable: true,
minWidth: 200,
style: {
textAlign: "center",
height: "50px",
}
}, {
Header: 'Fonte',
accessor: 'origin',
sortable: false,
filterable: true,
minWidth: 200,
style: {
textAlign: "center",
height: "50px",
}
}
],
};
}
componentDidMount() {
this.setState({
acessos: this.props.acessosX,
})
}
componentDidUpdate(prevProps) {
if (this.props.acessosX !== prevProps.acessosX) {
this.setState({acessosX: this.props.acessosX});
}
}
render() {
return (
<>
<ReactTable
noDataText="Sem Dados"
data={this.props.acessosX}
columns={this.state.colums}
showPaginationTop={true}
showPaginationBottom={false}
defaultPageSize={10}
defaultFilterMethod={this.filterMethod}
resizable={false}
className="-striped -highlight -pagination"
/>
</>
);
}
}
export default LastAccessTable;
| 28.831461 | 63 | 0.377631 | false | true | true | false |
d000bd5aa9eebf5e2c831ac7b8d0a2c09a3dd655 | 480 | jsx | JSX | client/src/components/comment-card/styles.jsx | Suzan-Dev/vlog | 2a1de3c66b325171cb8f09b80f1dc08c80ca5ba7 | [
"MIT"
] | null | null | null | client/src/components/comment-card/styles.jsx | Suzan-Dev/vlog | 2a1de3c66b325171cb8f09b80f1dc08c80ca5ba7 | [
"MIT"
] | null | null | null | client/src/components/comment-card/styles.jsx | Suzan-Dev/vlog | 2a1de3c66b325171cb8f09b80f1dc08c80ca5ba7 | [
"MIT"
] | 1 | 2022-01-18T11:05:46.000Z | 2022-01-18T11:05:46.000Z | import { makeStyles } from '@material-ui/core/styles';
const useStyles = makeStyles((theme) => ({
commentCardContainer: {
margin: theme.spacing(3, 0),
display: 'flex',
alignContent: 'center',
'& > div:last-child': {
marginLeft: theme.spacing(2),
'& > div': {
display: 'flex',
alignItems: 'center',
},
},
},
authorName: {
fontWeight: 'bold',
marginRight: theme.spacing(1),
},
}));
export default useStyles;
| 19.2 | 54 | 0.56875 | false | true | false | true |
d000c516fbca143cbaf02b3edf56e2d4acc2164d | 3,073 | jsx | JSX | ui/src/components/Company/LoginCompanyPage.jsx | IvayloIV/AdsPartners | 693c5c7abb4ab9e5b8944fd6c874ce82dca9d5e0 | [
"MIT"
] | null | null | null | ui/src/components/Company/LoginCompanyPage.jsx | IvayloIV/AdsPartners | 693c5c7abb4ab9e5b8944fd6c874ce82dca9d5e0 | [
"MIT"
] | null | null | null | ui/src/components/Company/LoginCompanyPage.jsx | IvayloIV/AdsPartners | 693c5c7abb4ab9e5b8944fd6c874ce82dca9d5e0 | [
"MIT"
] | null | null | null | import React, { useState } from 'react';
import { useDispatch } from "react-redux";
import { toast } from 'react-toastify';
import TextField from '@material-ui/core/TextField';
import { Button } from 'semantic-ui-react';
import * as validations from '../../validations/login';
import { loginCompanyAction } from '../../actions/companyActions';
export default props => {
const [email, setEmail] = useState('');
const [password, setPassword] = useState('');
const [emailValidation, setEmailValidation] = useState('');
const [passwordValidation, setPasswordValidation] = useState('');
const dispatch = useDispatch();
const onChangeHandler = (e, setValue, setValidation) => {
const name = e.target.name;
const value = e.target.value;
if (setValidation !== null) {
setValidation(validations[name](value));
}
setValue(value);
};
const onSubmitHandler = async (e) => {
e.preventDefault();
let haveError = false;
haveError = validateField('email', email, setEmailValidation) || haveError;
haveError = validateField('password', password, setPasswordValidation) || haveError;
if (haveError) {
toast.error('Поправете грешките в полетата.');
return;
}
const params = { email, password };
const json = await dispatch(loginCompanyAction(params))
if (json !== null) {
props.history.push("/");
}
};
const validateField = (name, value, setValidation) => {
let validationValue = validations[name](value);
setValidation(validationValue);
return validationValue !== '';
};
return (
<div className="login-container company-login">
<div className="login-form">
<h1>Вход за компания</h1>
<form onSubmit={onSubmitHandler}>
<div className="login-field">
<TextField
type="text"
label="Мейл"
value={email}
name="email"
onChange={e => onChangeHandler(e, setEmail, setEmailValidation)}
/>
<span data-testid="emailValidation">{emailValidation}</span>
</div>
<div className="login-field">
<TextField
type="password"
label="Парола"
value={password}
name="password"
onChange={e => onChangeHandler(e, setPassword, setPasswordValidation)}
/>
<span>{passwordValidation}</span>
</div>
<div>
<Button color="blue" type="submit" id="login-button">Влез</Button>
</div>
</form>
</div>
</div>
);
};
| 35.321839 | 98 | 0.508949 | false | true | false | true |
d000c7561690a331bf6a90a180127b66cac28cbd | 6,928 | jsx | JSX | features/apimgt/org.wso2.carbon.apimgt.publisher.feature/src/main/resources/publisher/source/src/app/components/Base/Header/headersearch/SearchUtils.jsx | miyurud/carbon-apimgt | 0990a1eac7c7ca648d763f79330d39eea0417d40 | [
"Apache-2.0"
] | 2 | 2019-09-19T11:30:08.000Z | 2019-10-27T07:38:16.000Z | features/apimgt/org.wso2.carbon.apimgt.publisher.feature/src/main/resources/publisher/source/src/app/components/Base/Header/headersearch/SearchUtils.jsx | miyurud/carbon-apimgt | 0990a1eac7c7ca648d763f79330d39eea0417d40 | [
"Apache-2.0"
] | null | null | null | features/apimgt/org.wso2.carbon.apimgt.publisher.feature/src/main/resources/publisher/source/src/app/components/Base/Header/headersearch/SearchUtils.jsx | miyurud/carbon-apimgt | 0990a1eac7c7ca648d763f79330d39eea0417d40 | [
"Apache-2.0"
] | null | null | null | /*
* Copyright (c) 2018, 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 match from 'autosuggest-highlight/match';
import parse from 'autosuggest-highlight/parse';
import TextField from '@material-ui/core/TextField';
import MenuItem from '@material-ui/core/MenuItem';
import ListItemText from '@material-ui/core/ListItemText';
import ListItemIcon from '@material-ui/core/ListItemIcon';
import Divider from '@material-ui/core/Divider';
import Icon from '@material-ui/core/Icon';
import InputAdornment from '@material-ui/core/InputAdornment';
import SearchOutlined from '@material-ui/icons/SearchOutlined';
import { Link } from 'react-router-dom';
import ProductIcon from 'AppComponents/Shared/CustomIcon';
import CircularProgress from '@material-ui/core/CircularProgress';
import API from 'AppData/api';
import SearchParser from './SearchParser';
/* Utility methods defined here are described in
* react-autosuggest documentation https://github.com/moroshko/react-autosuggest
*/
/**
*
* @param {Object} inputProps Props given for the underline input element
* @returns {React.Component} @inheritdoc
*/
function renderInput(inputProps) {
const {
classes, ref, isLoading, onChange, ...other
} = inputProps; // `isLoading` has destructured here to prevent passing unintended prop to TextField
let loadingAdorment = null;
if (isLoading) {
loadingAdorment = (
<InputAdornment position='end'>
<CircularProgress />
</InputAdornment>
);
}
return (
<TextField
id='searchQuery'
InputProps={{
inputRef: ref,
className: classes.input,
classes: { focused: classes.inputFocused },
startAdornment: (
<InputAdornment position='start'>
<SearchOutlined />
</InputAdornment>
),
endAdornment: loadingAdorment,
onChange,
...other,
}}
/>
);
}
function getPath(suggestion) {
switch (suggestion.type) {
case 'API':
return `/apis/${suggestion.id}/overview`;
case 'APIPRODUCT':
return `/api-products/${suggestion.id}/overview`;
default:
if (suggestion.associatedType === 'API') {
return `/apis/${suggestion.apiUUID}/documents/${suggestion.id}/details`;
} else {
return `/api-products/${suggestion.apiUUID}/documents/${suggestion.id}/details`;
}
}
}
function getArtifactMetaInfo(suggestion) {
switch (suggestion.type) {
case 'API':
return suggestion.version;
case 'APIPRODUCT':
return '';
default:
return suggestion.apiName + ' ' + suggestion.apiVersion;
}
}
function getIcon(type) {
switch (type) {
case 'API':
return <Icon style={{ fontSize: 30 }}>settings_applications</Icon>;
case 'APIPRODUCT':
return (
<ProductIcon
width={16}
height={16}
icon='api-product'
strokeColor='#000000'
/>
);
default:
return <Icon style={{ fontSize: 30 }}>library_books</Icon>;
}
}
/**
*
* Use your imagination to define how suggestions are rendered.
* @param {Object} suggestion This is either API object or document coming from search API call
* @param {Object} { query, isHighlighted } query : User entered value
* @returns {React.Component} @inheritdoc
*/
function renderSuggestion(suggestion, { query, isHighlighted }) {
const matches = match(suggestion.name, query);
const parts = parse(suggestion.name, matches);
const path = getPath(suggestion);
const artifactMetaInfo = getArtifactMetaInfo(suggestion);
// TODO: Style the version ( and apiName if docs) apearing in the menu item
return (
<>
<Link to={path} style={{ color: 'black' }}>
<MenuItem selected={isHighlighted}>
<ListItemIcon>
{getIcon(suggestion.type)}
</ListItemIcon>
<ListItemText
primary={parts.map((part, index) => {
return part.highlight ? (
<span key={String(index)} style={{ fontWeight: 500 }}>
{part.text}
</span>
) : (
<strong key={String(index)} style={{ fontWeight: 300 }}>
{part.text}
</strong>
);
})}
secondary={artifactMetaInfo}
/>
</MenuItem>
</Link>
<Divider />
</>
);
}
/**
* When suggestion is clicked, Autosuggest needs to populate the input
* based on the clicked suggestion. Teach Autosuggest how to calculate the input value for every given suggestion.
*
* @param {Object} suggestion API Object returned from APIS search api.list[]
* @returns {String} API Name
*/
function getSuggestionValue(suggestion) {
return suggestion.name;
}
/**
* Build the search query from the user input
* @param searchText
* @returns {string}
*/
function buildSearchQuery(searchText) {
const inputValue = searchText.trim().toLowerCase();
return SearchParser.parse(inputValue);
}
/**
* Called for any input change to get the results set
*
* @param {String} value current value in input element
* @returns {Promise} If no input text, return a promise which resolve to empty array, else return the API.all response
*/
function getSuggestions(value) {
const modifiedSearchQuery = buildSearchQuery(value);
if (value.trim().length === 0 || !modifiedSearchQuery) {
return new Promise((resolve) => resolve({ obj: { list: [] } }));
} else {
return API.search({ query: modifiedSearchQuery, limit: 8 });
}
}
export {
renderInput, renderSuggestion, getSuggestions, getSuggestionValue, buildSearchQuery,
};
| 34.128079 | 119 | 0.594544 | false | true | false | true |
d000f0dc93d91ca5eafc8f53d5234467958778af | 3,014 | jsx | JSX | src/components/Header/HeaderControlsNotifications.jsx | serCJm/react-admin-dashboard | 92b56f1ca2293b460a5310d8b9c955d6ef9b5916 | [
"MIT"
] | 1 | 2018-12-13T20:01:17.000Z | 2018-12-13T20:01:17.000Z | src/components/Header/HeaderControlsNotifications.jsx | serCJm/react-admin-dashboard | 92b56f1ca2293b460a5310d8b9c955d6ef9b5916 | [
"MIT"
] | 9 | 2019-09-07T22:46:35.000Z | 2022-02-26T06:52:37.000Z | src/components/Header/HeaderControlsNotifications.jsx | serCJm/react-admin-dashboard | 92b56f1ca2293b460a5310d8b9c955d6ef9b5916 | [
"MIT"
] | null | null | null | import React, { Component } from "react";
import { NavLink } from "react-router-dom";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faEnvelope } from "@fortawesome/free-solid-svg-icons";
import { faBell } from "@fortawesome/free-solid-svg-icons";
import { faRss } from "@fortawesome/free-solid-svg-icons";
import HeaderControlsBell from "./HeaderControlsBell";
import HeaderControlsRSS from "./HeaderControlsRSS";
class HeaderControlsNotifications extends Component {
state = {
showNotifications: false,
showRSS: false
};
handleNotificationsClick = () => {
if (!this.state.showNotifications) {
// attach/remove event handler
document.addEventListener(
"click",
this.handleNotificationsOutsideClick,
false
);
} else {
document.removeEventListener(
"click",
this.handleNotificationsOutsideClick,
false
);
}
this.setState(prevState => ({
showNotifications: !prevState.showNotifications
}));
};
handleNotificationsOutsideClick = e => {
// ignore clicks on the component itself
if (this.node1.contains(e.target)) {
return;
}
this.handleNotificationsClick();
};
handleRSSClick = () => {
if (!this.state.showRSS) {
// attach/remove event handler
document.addEventListener("click", this.handleRSSOutsideClick, false);
} else {
document.removeEventListener("click", this.handleRSSOutsideClick, false);
}
this.setState(prevState => ({
showRSS: !prevState.showRSS
}));
};
handleRSSOutsideClick = e => {
// ignore clicks on the component itself
if (this.node2.contains(e.target)) {
return;
}
this.handleRSSClick();
};
render() {
let headerControlsBell = null;
if (this.state.showNotifications) {
headerControlsBell = <HeaderControlsBell />;
}
let headerControlsRSS = null;
if (this.state.showRSS) {
headerControlsRSS = <HeaderControlsRSS />;
}
return (
<div className="header-controls-item">
<NavLink
className="header-controls-icon"
to="/inbox"
aria-label="Go to inbox"
>
<span>
<FontAwesomeIcon icon={faEnvelope} />
</span>
</NavLink>
<span
className="header-controls-icon"
ref={node => {
this.node1 = node;
}}
onClick={this.handleNotificationsClick}
>
<FontAwesomeIcon icon={faBell} />
{headerControlsBell}
<div className="bubble1">3</div>
</span>
<span
className="header-controls-icon"
ref={node => {
this.node2 = node;
}}
onClick={this.handleRSSClick}
>
<FontAwesomeIcon icon={faRss} />
<div className="bubble2">4</div>
{headerControlsRSS}
</span>
</div>
);
}
}
export default HeaderControlsNotifications;
| 26.672566 | 79 | 0.60219 | false | true | true | false |
d0010ef5b3e1c812a02bc262e18d1d803d953d49 | 11,376 | jsx | JSX | superset-frontend/src/explore/components/ExploreChartHeader.jsx | choice-form/superset | 8d579798671459ea1635f177b7c8e6f1612ff3b2 | [
"Apache-2.0"
] | null | null | null | superset-frontend/src/explore/components/ExploreChartHeader.jsx | choice-form/superset | 8d579798671459ea1635f177b7c8e6f1612ff3b2 | [
"Apache-2.0"
] | 1 | 2022-02-23T10:34:59.000Z | 2022-02-23T10:34:59.000Z | superset-frontend/src/explore/components/ExploreChartHeader.jsx | choice-form/superset | 8d579798671459ea1635f177b7c8e6f1612ff3b2 | [
"Apache-2.0"
] | null | null | null | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF 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 { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import PropTypes from 'prop-types';
import Icons from 'src/components/Icons';
import { CategoricalColorNamespace, SupersetClient, styled, t } from 'src/core';
import { Tooltip } from 'src/components/Tooltip';
import ReportModal from 'src/components/ReportModal';
import {
fetchUISpecificReport,
toggleActive,
deleteActiveReport,
} from 'src/reports/actions/reports';
import { isFeatureEnabled, FeatureFlag } from 'src/featureFlags';
import HeaderReportActionsDropdown from 'src/components/ReportModal/HeaderReportActionsDropdown';
import { chartPropShape } from 'src/dashboard/util/propShapes';
import EditableTitle from 'src/components/EditableTitle';
import AlteredSliceTag from 'src/components/AlteredSliceTag';
import FaveStar from 'src/components/FaveStar';
import Timer from 'src/components/Timer';
import CachedLabel from 'src/components/CachedLabel';
import PropertiesModal from 'src/explore/components/PropertiesModal';
import { sliceUpdated } from 'src/explore/actions/exploreActions';
import CertifiedIcon from 'src/components/CertifiedIcon';
import ExploreActionButtons from './ExploreActionButtons';
import RowCountLabel from './RowCountLabel';
const CHART_STATUS_MAP = {
failed: 'danger',
loading: 'warning',
success: 'success',
};
const propTypes = {
actions: PropTypes.object.isRequired,
addHistory: PropTypes.func,
can_overwrite: PropTypes.bool.isRequired,
can_download: PropTypes.bool.isRequired,
dashboardId: PropTypes.number,
isStarred: PropTypes.bool.isRequired,
slice: PropTypes.object,
sliceName: PropTypes.string,
table_name: PropTypes.string,
form_data: PropTypes.object,
ownState: PropTypes.object,
timeout: PropTypes.number,
chart: chartPropShape,
};
const StyledHeader = styled.div`
display: flex;
flex-direction: row;
align-items: center;
flex-wrap: wrap;
justify-content: space-between;
span[role='button'] {
display: flex;
height: 100%;
}
.title-panel {
display: flex;
align-items: center;
}
.right-button-panel {
display: flex;
align-items: center;
> .btn-group {
flex: 0 0 auto;
margin-left: ${({ theme }) => theme.gridUnit}px;
}
}
.action-button {
color: ${({ theme }) => theme.colors.grayscale.base};
margin: 0 ${({ theme }) => theme.gridUnit * 1.5}px 0
${({ theme }) => theme.gridUnit}px;
}
`;
const StyledButtons = styled.span`
display: flex;
align-items: center;
`;
export class ExploreChartHeader extends React.PureComponent {
constructor(props) {
super(props);
this.state = {
isPropertiesModalOpen: false,
showingReportModal: false,
};
this.openPropertiesModal = this.openPropertiesModal.bind(this);
this.closePropertiesModal = this.closePropertiesModal.bind(this);
this.showReportModal = this.showReportModal.bind(this);
this.hideReportModal = this.hideReportModal.bind(this);
this.renderReportModal = this.renderReportModal.bind(this);
this.fetchChartDashboardData = this.fetchChartDashboardData.bind(this);
}
componentDidMount() {
const { dashboardId } = this.props;
if (this.canAddReports()) {
const { user, chart } = this.props;
// this is in the case that there is an anonymous user.
this.props.fetchUISpecificReport(
user.userId,
'chart_id',
'charts',
chart.id,
);
}
if (dashboardId) {
this.fetchChartDashboardData();
}
}
async fetchChartDashboardData() {
const { dashboardId, slice } = this.props;
const response = await SupersetClient.get({
endpoint: `/api/v1/chart/${slice.slice_id}`,
});
const chart = response.json.result;
const dashboards = chart.dashboards || [];
const dashboard =
dashboardId &&
dashboards.length &&
dashboards.find(d => d.id === dashboardId);
if (dashboard && dashboard.json_metadata) {
// setting the chart to use the dashboard custom label colors if any
const labelColors =
JSON.parse(dashboard.json_metadata).label_colors || {};
const categoricalNamespace = CategoricalColorNamespace.getNamespace();
Object.keys(labelColors).forEach(label => {
categoricalNamespace.setColor(label, labelColors[label]);
});
}
}
getSliceName() {
const { sliceName, table_name: tableName } = this.props;
const title = sliceName || t('%s - untitled', tableName);
return title;
}
postChartFormData() {
this.props.actions.postChartFormData(
this.props.form_data,
true,
this.props.timeout,
this.props.chart.id,
this.props.ownState,
);
}
openPropertiesModal() {
this.setState({
isPropertiesModalOpen: true,
});
}
closePropertiesModal() {
this.setState({
isPropertiesModalOpen: false,
});
}
showReportModal() {
this.setState({ showingReportModal: true });
}
hideReportModal() {
this.setState({ showingReportModal: false });
}
renderReportModal() {
const attachedReportExists = !!Object.keys(this.props.reports).length;
return attachedReportExists ? (
<HeaderReportActionsDropdown
showReportModal={this.showReportModal}
hideReportModal={this.hideReportModal}
toggleActive={this.props.toggleActive}
deleteActiveReport={this.props.deleteActiveReport}
/>
) : (
<>
<span
role="button"
title={t('Schedule email report')}
tabIndex={0}
className="action-button"
onClick={this.showReportModal}
>
<Icons.Calendar />
</span>
</>
);
}
canAddReports() {
if (!isFeatureEnabled(FeatureFlag.ALERT_REPORTS)) {
return false;
}
const { user } = this.props;
if (!user) {
// this is in the case that there is an anonymous user.
return false;
}
const roles = Object.keys(user.roles || []);
const permissions = roles.map(key =>
user.roles[key].filter(
perms => perms[0] === 'menu_access' && perms[1] === 'Manage',
),
);
return permissions[0].length > 0;
}
render() {
const { user, form_data: formData, slice } = this.props;
const {
chartStatus,
chartUpdateEndTime,
chartUpdateStartTime,
latestQueryFormData,
queriesResponse,
} = this.props.chart;
// TODO: when will get appropriate design for multi queries use all results and not first only
const queryResponse = queriesResponse?.[0];
const chartFinished = ['failed', 'rendered', 'success'].includes(
this.props.chart.chartStatus,
);
return (
<StyledHeader id="slice-header" className="panel-title-large">
<div className="title-panel">
{slice?.certified_by && (
<>
<CertifiedIcon
certifiedBy={slice.certified_by}
details={slice.certification_details}
/>{' '}
</>
)}
<EditableTitle
title={this.getSliceName()}
canEdit={!this.props.slice || this.props.can_overwrite}
onSaveTitle={this.props.actions.updateChartTitle}
/>
{this.props.slice && (
<StyledButtons>
{user.userId && (
<FaveStar
itemId={this.props.slice.slice_id}
fetchFaveStar={this.props.actions.fetchFaveStar}
saveFaveStar={this.props.actions.saveFaveStar}
isStarred={this.props.isStarred}
showTooltip
/>
)}
<PropertiesModal
show={this.state.isPropertiesModalOpen}
onHide={this.closePropertiesModal}
onSave={this.props.sliceUpdated}
slice={this.props.slice}
/>
<Tooltip
id="edit-desc-tooltip"
title={t('Edit chart properties')}
>
<span
role="button"
tabIndex={0}
className="edit-desc-icon"
onClick={this.openPropertiesModal}
>
<i className="fa fa-edit" />
</span>
</Tooltip>
{this.props.chart.sliceFormData && (
<AlteredSliceTag
className="altered"
origFormData={this.props.chart.sliceFormData}
currentFormData={formData}
/>
)}
</StyledButtons>
)}
</div>
<div className="right-button-panel">
{chartFinished && queryResponse && (
<RowCountLabel
rowcount={Number(queryResponse.rowcount) || 0}
limit={Number(formData.row_limit) || 0}
/>
)}
{chartFinished && queryResponse && queryResponse.is_cached && (
<CachedLabel
onClick={this.postChartFormData.bind(this)}
cachedTimestamp={queryResponse.cached_dttm}
/>
)}
<Timer
startTime={chartUpdateStartTime}
endTime={chartUpdateEndTime}
isRunning={chartStatus === 'loading'}
status={CHART_STATUS_MAP[chartStatus]}
/>
{this.canAddReports() && this.renderReportModal()}
<ReportModal
show={this.state.showingReportModal}
onHide={this.hideReportModal}
props={{
userId: this.props.user.userId,
userEmail: this.props.user.email,
chart: this.props.chart,
creationMethod: 'charts',
}}
/>
<ExploreActionButtons
actions={{
...this.props.actions,
openPropertiesModal: this.openPropertiesModal,
}}
slice={this.props.slice}
canDownloadCSV={this.props.can_download}
chartStatus={chartStatus}
latestQueryFormData={latestQueryFormData}
queryResponse={queryResponse}
/>
</div>
</StyledHeader>
);
}
}
ExploreChartHeader.propTypes = propTypes;
function mapDispatchToProps(dispatch) {
return bindActionCreators(
{ sliceUpdated, fetchUISpecificReport, toggleActive, deleteActiveReport },
dispatch,
);
}
export default connect(null, mapDispatchToProps)(ExploreChartHeader);
| 30.745946 | 98 | 0.620781 | false | true | false | true |
d0011ff5c50f8e4a30346178d0638e77a3147cc9 | 4,495 | jsx | JSX | __tests__/components/SEO.spec.jsx | pcooney10/react-seo | 531e9d5580faf5e53ca263a595b9ad5964819a54 | [
"Apache-2.0"
] | null | null | null | __tests__/components/SEO.spec.jsx | pcooney10/react-seo | 531e9d5580faf5e53ca263a595b9ad5964819a54 | [
"Apache-2.0"
] | null | null | null | __tests__/components/SEO.spec.jsx | pcooney10/react-seo | 531e9d5580faf5e53ca263a595b9ad5964819a54 | [
"Apache-2.0"
] | null | null | null | /*
* Copyright 2020 American Express Travel Related Services Company, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,either express
* or implied. See the License for the specific language governing permissions and limitations
* under the License.
*/
import React from 'react';
import { shallow } from 'enzyme';
import SEO from '../../src';
jest.mock('react-helmet', () => ({ Helmet: 'Helmet' }));
describe('SEO', () => {
it('should render correctly with the minimal tags', () => {
const component = shallow(
<SEO
title="Lorem Ipsum"
siteUrl="https://example.com"
/>
);
expect(component).toMatchSnapshot();
});
it('should provide the canonical URL', () => {
const component = shallow(
<SEO
description="Lorem ipsum sat delor."
keywords={['foo', 'bar']}
siteUrl="https://example.com"
title="Lorem Ipsum"
canonical="https://example.com/index.html"
/>
);
const helmet = component.find('Helmet');
const { link } = helmet.props();
expect(link).toEqual([{
rel: 'canonical', href: 'https://example.com/index.html',
}]);
});
it('should provide the robots', () => {
const component = shallow(
<SEO
description="Lorem ipsum sat delor."
keywords={['foo', 'bar']}
robots={['index', 'follow']}
siteUrl="https://example.com"
title="Lorem Ipsum"
canonical="https://example.com/index.html"
/>
);
const helmet = component.find('Helmet');
const { meta } = helmet.props();
const robots = meta.find((tag) => tag.name === 'robots');
expect(robots).toMatchObject({
name: 'robots', content: 'index,follow',
});
});
it('should render image tags correctly', () => {
const component = shallow(
<SEO
description="Lorem ipsum sat delor."
keywords={['foo', 'bar']}
siteUrl="https://example.com"
title="Lorem Ipsum"
image={{
src: 'http://example.com/ogp.jpg',
type: 'image/jpeg',
width: 500,
height: 300,
alt: 'A shiny red apple with a bite taken out',
}}
/>
);
expect(component).toMatchSnapshot();
});
it('should render video tags correctly', () => {
const component = shallow(
<SEO
description="Lorem ipsum sat delor."
keywords={['foo', 'bar']}
siteUrl="https://example.com"
title="Lorem Ipsum"
video={{
src: 'http://example.com/movie.swf',
type: 'application/x-shockwave-flash',
width: 500,
height: 300,
alt: 'A shiny red apple with a bite taken out',
}}
/>
);
expect(component).toMatchSnapshot();
});
it('should render Open Graph tags correctly', () => {
const component = shallow(
<SEO
description="Lorem ipsum sat delor."
keywords={['foo', 'bar']}
siteUrl="https://example.com"
title="Lorem Ipsum"
openGraph={{
title: 'Open Graph Title',
}}
/>
);
expect(component).toMatchSnapshot();
});
it('should render Twitter Card tags correctly', () => {
const component = shallow(
<SEO
description="Lorem ipsum sat delor."
keywords={['foo', 'bar']}
siteUrl="https://example.com"
title="Lorem Ipsum"
twitterCard={{
title: 'Twitter Card Title',
}}
/>
);
expect(component).toMatchSnapshot();
});
it('should render Helmet props correctly', () => {
const component = shallow(
<SEO
author="John Doe"
description="Lorem ipsum sat delor."
keywords={['foo', 'bar']}
siteUrl="https://example.com"
title="Lorem Ipsum"
canonical="https://example.com/foo/bar"
defaultTitle="Curabitur pretium tincidunt lacus."
defer={false}
encodeSpecialCharacters={true}
onChangeClientState={jest.fn()}
titleTemplate={null}
zipTies={false}
/>
);
expect(component).toMatchSnapshot();
});
});
| 27.919255 | 100 | 0.573749 | false | true | false | true |
d001326025cdb56143af9fd8827c12ac049dbfc3 | 4,746 | jsx | JSX | src/components/MainHeader/NavLinks.jsx | ngwessels/SeatGeek-CLone | cd06c2a522fedc91928cca4692403ace97487aac | [
"MIT"
] | 1 | 2019-06-04T00:34:33.000Z | 2019-06-04T00:34:33.000Z | src/components/MainHeader/NavLinks.jsx | ngwessels/SeatGeek-CLone | cd06c2a522fedc91928cca4692403ace97487aac | [
"MIT"
] | null | null | null | src/components/MainHeader/NavLinks.jsx | ngwessels/SeatGeek-CLone | cd06c2a522fedc91928cca4692403ace97487aac | [
"MIT"
] | null | null | null | import React from 'react';
import NavButton from './NavButton';
function NavLinks() {
var style = {
display: 'flex',
alignItems: 'center',
}
var bump = {
paddingRight: '20px'
}
return (
<div style={style}>
<svg style={bump} preserveAspectRatio="xMidYMid" width="128" height="24" viewBox="0 0 128 24" class="seatgeek-logo__svg">
<path fill="#FFF" fillrule="evenodd" d="M128.000,19.649 L124.626,19.649 L120.335,13.763 L120.336,19.649 L117.450,19.649 L117.450,4.136 L120.334,4.136 L120.335,13.014 L124.531,8.050 L127.894,8.050 L123.306,13.361 L128.000,19.649 ZM111.842,17.457 C113.923,17.457 115.348,16.328 115.348,16.328 L115.348,18.955 C114.481,19.430 113.291,19.904 111.534,19.904 C105.582,19.904 105.279,15.251 105.279,13.852 C105.279,10.696 107.273,7.784 110.807,7.784 C115.936,7.784 115.912,12.338 115.912,13.227 L115.912,14.719 L108.192,14.719 C108.379,16.136 109.524,17.457 111.842,17.457 ZM113.194,12.385 C113.066,11.277 112.481,10.214 110.931,10.214 C109.125,10.214 108.364,11.368 108.197,12.385 L113.194,12.385 ZM99.929,17.457 C102.009,17.457 103.434,16.328 103.434,16.328 L103.434,18.955 C102.567,19.430 101.377,19.904 99.620,19.904 C93.668,19.904 93.365,15.251 93.365,13.852 C93.365,10.696 95.359,7.784 98.894,7.784 C104.022,7.784 103.998,12.338 103.998,13.227 L103.998,14.719 L96.279,14.719 C96.466,16.136 97.610,17.457 99.929,17.457 ZM101.280,12.385 C101.153,11.277 100.568,10.214 99.018,10.214 C97.212,10.214 96.450,11.368 96.284,12.385 L101.280,12.385 ZM87.036,19.902 C82.303,19.902 79.163,17.037 79.163,12.057 C79.163,6.854 82.956,3.917 86.982,3.917 C90.010,3.917 91.456,4.877 91.456,4.877 L91.456,7.823 C90.269,7.091 89.194,6.501 87.035,6.501 C84.026,6.501 82.158,9.071 82.158,12.057 C82.158,14.865 83.799,17.313 86.945,17.313 C88.142,17.313 88.926,17.039 88.926,17.039 L88.926,13.719 L85.813,13.719 L85.813,11.133 L90.407,11.133 C91.185,11.133 91.816,11.768 91.816,12.551 L91.816,18.955 C91.816,18.955 90.300,19.902 87.036,19.902 ZM76.456,17.459 C77.381,17.459 78.463,16.833 78.463,16.833 L78.454,19.339 C78.454,19.339 77.557,19.902 75.707,19.902 C71.750,19.902 71.900,17.025 71.900,15.301 L71.900,5.186 L74.784,5.186 C74.784,5.937 74.784,6.932 74.784,8.024 L78.004,8.024 L78.004,10.469 L74.785,10.469 C74.785,12.937 74.785,15.706 74.785,15.706 C74.785,16.760 75.136,17.459 76.456,17.459 ZM60.968,16.416 C60.968,13.426 63.413,12.612 67.416,12.760 C67.416,11.387 67.330,10.214 65.131,10.214 C63.426,10.214 61.682,11.350 61.682,11.350 L61.682,8.728 C61.682,8.728 63.637,7.772 65.847,7.772 C67.323,7.772 70.275,7.965 70.275,12.113 C70.275,15.917 70.277,19.478 70.277,19.478 C70.277,19.478 67.971,19.902 66.252,19.902 C63.991,19.902 60.968,19.400 60.968,16.416 ZM67.391,14.767 C66.493,14.718 63.861,14.494 63.861,16.186 C63.861,18.180 67.391,17.488 67.391,17.488 L67.391,14.767 ZM55.973,17.457 C58.054,17.457 59.479,16.328 59.479,16.328 L59.479,18.955 C58.612,19.430 57.422,19.904 55.665,19.904 C49.713,19.904 49.410,15.251 49.410,13.852 C49.410,10.696 51.404,7.784 54.939,7.784 C60.067,7.784 60.043,12.338 60.043,13.227 L60.043,14.719 L52.324,14.719 C52.511,16.136 53.655,17.457 55.973,17.457 ZM57.325,12.385 C57.198,11.277 56.613,10.214 55.062,10.214 C53.257,10.214 52.495,11.368 52.329,12.385 L57.325,12.385 ZM44.915,11.012 C45.675,11.331 48.304,12.385 48.304,15.315 C48.304,18.777 45.325,19.902 42.356,19.902 C39.387,19.902 37.491,18.654 37.491,18.654 L37.491,15.688 C37.491,15.688 39.912,17.313 42.356,17.313 C44.800,17.313 45.299,16.437 45.299,15.560 C45.299,14.676 44.849,14.288 44.129,13.904 C43.409,13.520 42.060,13.013 40.569,12.477 C39.079,11.941 37.296,11.026 37.296,8.390 C37.296,5.187 40.075,3.919 42.877,3.919 C45.679,3.919 47.415,4.877 47.415,4.877 L47.415,7.823 C47.415,7.823 45.206,6.501 42.745,6.501 C41.017,6.501 40.361,7.215 40.291,8.103 C40.216,9.057 40.897,9.408 41.507,9.723 C41.929,9.942 44.284,10.747 44.915,11.012 ZM28.872,17.454 L26.133,17.454 L26.133,12.573 C26.133,11.780 26.772,11.137 27.560,11.137 L31.269,11.137 L31.269,13.722 L28.872,13.722 L28.872,17.454 ZM15.635,24.000 C9.429,24.000 5.363,22.277 5.363,22.277 L5.363,19.348 C5.363,19.348 9.358,21.185 15.635,21.185 C21.911,21.185 25.906,19.348 25.906,19.348 L25.906,22.277 C25.906,22.277 21.840,24.000 15.635,24.000 ZM7.931,16.306 L5.363,2.584 C5.363,2.584 9.286,0.000 15.635,0.000 C21.983,0.000 25.906,2.584 25.906,2.584 L23.338,16.306 L7.931,16.306 ZM2.397,13.722 L0.000,13.722 L0.000,11.137 L3.709,11.137 C4.497,11.137 5.136,11.780 5.136,12.573 L5.136,17.454 L2.397,17.454 L2.397,13.722 Z"></path>
</svg>
<NavButton title='Sports'/>
<NavButton title='Music'/>
<NavButton title='More'/>
<NavButton title='Sell'/>
</div>
);
}
export default NavLinks;
| 169.5 | 4,180 | 0.705225 | false | true | false | true |
d00142066cb277fc203dfeae311af88ef3c2ab54 | 9,078 | jsx | JSX | awx/ui_next/src/screens/Template/WorkflowJobTemplate.jsx | jwlogemann/awx | 4a8f1d41fa05f25e310f3166449e1a93de4fddb1 | [
"Apache-2.0"
] | 1 | 2020-03-29T13:01:12.000Z | 2020-03-29T13:01:12.000Z | awx/ui_next/src/screens/Template/WorkflowJobTemplate.jsx | jwlogemann/awx | 4a8f1d41fa05f25e310f3166449e1a93de4fddb1 | [
"Apache-2.0"
] | 1 | 2019-09-24T21:08:04.000Z | 2019-09-24T21:08:04.000Z | awx/ui_next/src/screens/Template/WorkflowJobTemplate.jsx | jbradberry/awx | b8ec94a0ae5356614342820d2e3b67c06bf7bb44 | [
"Apache-2.0"
] | null | null | null | import React, { Component } from 'react';
import { t } from '@lingui/macro';
import { withI18n } from '@lingui/react';
import { Card, CardActions, PageSection } from '@patternfly/react-core';
import { Switch, Route, Redirect, withRouter, Link } from 'react-router-dom';
import { TabbedCardHeader } from '@components/Card';
import AppendBody from '@components/AppendBody';
import CardCloseButton from '@components/CardCloseButton';
import ContentError from '@components/ContentError';
import FullPage from '@components/FullPage';
import JobList from '@components/JobList';
import RoutedTabs from '@components/RoutedTabs';
import { Schedules } from '@components/Schedule';
import ContentLoading from '@components/ContentLoading';
import { ResourceAccessList } from '@components/ResourceAccessList';
import NotificationList from '@components/NotificationList';
import {
WorkflowJobTemplatesAPI,
CredentialsAPI,
OrganizationsAPI,
} from '@api';
import WorkflowJobTemplateDetail from './WorkflowJobTemplateDetail';
import WorkflowJobTemplateEdit from './WorkflowJobTemplateEdit';
import { Visualizer } from './WorkflowJobTemplateVisualizer';
class WorkflowJobTemplate extends Component {
constructor(props) {
super(props);
this.state = {
contentError: null,
hasContentLoading: true,
template: null,
webhook_key: null,
isNotifAdmin: false,
};
this.loadTemplate = this.loadTemplate.bind(this);
this.loadSchedules = this.loadSchedules.bind(this);
this.loadScheduleOptions = this.loadScheduleOptions.bind(this);
}
async componentDidMount() {
await this.loadTemplate();
}
async componentDidUpdate(prevProps) {
const { location } = this.props;
if (location !== prevProps.location) {
await this.loadTemplate();
}
}
async loadTemplate() {
const { setBreadcrumb, match } = this.props;
const { id } = match.params;
this.setState({ contentError: null });
try {
const { data } = await WorkflowJobTemplatesAPI.readDetail(id);
if (data?.related?.webhook_key) {
const {
data: { webhook_key },
} = await WorkflowJobTemplatesAPI.readWebhookKey(id);
this.setState({ webhook_key });
}
if (data?.summary_fields?.webhook_credential) {
const {
data: {
summary_fields: {
credential_type: { name },
},
},
} = await CredentialsAPI.readDetail(
data.summary_fields.webhook_credential.id
);
data.summary_fields.webhook_credential.kind = name;
}
const notifAdminRes = await OrganizationsAPI.read({
page_size: 1,
role_level: 'notification_admin_role',
});
setBreadcrumb(data);
this.setState({
template: data,
isNotifAdmin: notifAdminRes.data.results.length > 0,
});
} catch (err) {
this.setState({ contentError: err });
} finally {
this.setState({ hasContentLoading: false });
}
}
loadScheduleOptions() {
const { template } = this.state;
return WorkflowJobTemplatesAPI.readScheduleOptions(template.id);
}
loadSchedules(params) {
const { template } = this.state;
return WorkflowJobTemplatesAPI.readSchedules(template.id, params);
}
render() {
const { i18n, me, location, match, setBreadcrumb } = this.props;
const {
contentError,
hasContentLoading,
template,
webhook_key,
isNotifAdmin,
} = this.state;
const canSeeNotificationsTab = me.is_system_auditor || isNotifAdmin;
const canToggleNotifications = isNotifAdmin;
const tabsArray = [
{ name: i18n._(t`Details`), link: `${match.url}/details` },
{ name: i18n._(t`Access`), link: `${match.url}/access` },
];
if (canSeeNotificationsTab) {
tabsArray.push({
name: i18n._(t`Notifications`),
link: `${match.url}/notifications`,
});
}
if (template) {
tabsArray.push({
name: i18n._(t`Schedules`),
link: `${match.url}/schedules`,
});
}
tabsArray.push({
name: i18n._(t`Visualizer`),
link: `${match.url}/visualizer`,
});
tabsArray.push({
name: i18n._(t`Completed Jobs`),
link: `${match.url}/completed_jobs`,
});
tabsArray.forEach((tab, n) => {
tab.id = n;
});
if (hasContentLoading) {
return (
<PageSection>
<Card>
<ContentLoading />
</Card>
</PageSection>
);
}
if (contentError) {
return (
<PageSection>
<Card>
<ContentError error={contentError}>
{contentError.response.status === 404 && (
<span>
{i18n._(`Template not found.`)}{' '}
<Link to="/templates">{i18n._(`View all Templates.`)}</Link>
</span>
)}
</ContentError>
</Card>
</PageSection>
);
}
const cardHeader = (
<TabbedCardHeader>
<RoutedTabs tabsArray={tabsArray} />
<CardActions>
<CardCloseButton linkTo="/templates" />
</CardActions>
</TabbedCardHeader>
);
return (
<PageSection>
<Card>
{location.pathname.endsWith('edit') ||
location.pathname.includes('schedules/')
? null
: cardHeader}
<Switch>
<Redirect
from="/templates/workflow_job_template/:id"
to="/templates/workflow_job_template/:id/details"
exact
/>
{template && (
<Route
key="wfjt-details"
path="/templates/workflow_job_template/:id/details"
render={() => (
<WorkflowJobTemplateDetail
template={template}
webhook_key={webhook_key}
/>
)}
/>
)}
{template && (
<Route
path="/templates/workflow_job_template/:id/access"
render={() => (
<ResourceAccessList
resource={template}
apiModel={WorkflowJobTemplatesAPI}
/>
)}
/>
)}
{canSeeNotificationsTab && (
<Route
path="/templates/workflow_job_template/:id/notifications"
render={() => (
<NotificationList
id={Number(match.params.id)}
canToggleNotifications={canToggleNotifications}
apiModel={WorkflowJobTemplatesAPI}
/>
)}
/>
)}
{template && (
<Route
key="wfjt-edit"
path="/templates/workflow_job_template/:id/edit"
render={() => (
<WorkflowJobTemplateEdit
template={template}
webhook_key={webhook_key}
/>
)}
/>
)}
{template && (
<Route
key="wfjt-visualizer"
path="/templates/workflow_job_template/:id/visualizer"
render={() => (
<AppendBody>
<FullPage>
<Visualizer template={template} />
</FullPage>
</AppendBody>
)}
/>
)}
{template?.id && (
<Route path="/templates/workflow_job_template/:id/completed_jobs">
<JobList
defaultParams={{
workflow_job__workflow_job_template: template.id,
}}
/>
</Route>
)}
{template?.id && (
<Route
path="/templates/workflow_job_template/:id/schedules"
render={() => (
<Schedules
setBreadcrumb={setBreadcrumb}
unifiedJobTemplate={template}
loadSchedules={this.loadSchedules}
loadScheduleOptions={this.loadScheduleOptions}
/>
)}
/>
)}
<Route
key="not-found"
path="*"
render={() => (
<ContentError isNotFound>
{match.params.id && (
<Link
to={`/templates/workflow_job_template/${match.params.id}/details`}
>
{i18n._(`View Template Details`)}
</Link>
)}
</ContentError>
)}
/>
</Switch>
</Card>
</PageSection>
);
}
}
export { WorkflowJobTemplate as _WorkflowJobTemplate };
export default withI18n()(withRouter(WorkflowJobTemplate));
| 29.861842 | 88 | 0.523023 | false | true | true | false |
d001433ce3ac511b8eea06d4c703f44eddc4f30b | 2,212 | jsx | JSX | person/src/container/bossinfo/bossinfo.jsx | zhangshuaidan/-App | 593c62acd15fc8fd00e5ffbd7c33b4207862e7f9 | [
"MIT"
] | null | null | null | person/src/container/bossinfo/bossinfo.jsx | zhangshuaidan/-App | 593c62acd15fc8fd00e5ffbd7c33b4207862e7f9 | [
"MIT"
] | 6 | 2020-09-04T23:20:47.000Z | 2021-03-09T10:28:12.000Z | person/src/container/bossinfo/bossinfo.jsx | zhangshuaidan/-App | 593c62acd15fc8fd00e5ffbd7c33b4207862e7f9 | [
"MIT"
] | null | null | null | import React from "react";
import { NavBar, InputItem, TextareaItem, Button } from 'antd-mobile';
import { Redirect } from 'react-router-dom'
import AvatarSelector from '../../component/avatar-selector/avatar-selector'
import {connect} from 'react-redux'
import { update} from '../../redux/user.redux'
@connect(
state=>state.user,
{update}
)
class BossInfo extends React.Component{
constructor(props){
super(props)
this.state={
title:"",
desc:"",
company:"",
money:''
}
}
onChange(key,val){
this.setState({
[key]:val
})
}
render(){
const path =this.props.location.pathname
const redirect = this.props.redirectTo
return(
<div>
{redirect && redirect!==path? <Redirect to={this.props.redirectTo} /> : null}
{/* {this.props.redirectTo ? <Redirect to={this.props.redirectTto}> </Redirect>:null} */}
<NavBar mode="dark">BOSS完善信息页面</NavBar>
<AvatarSelector
selectAvatar={(imgname)=>{
this.setState({
avatar:imgname
})
}}
// selectAvatar={5}
></AvatarSelector>
<InputItem onChange={(v)=>this.onChange('title',v)}>
招聘职位
</InputItem>
<InputItem onChange={(v) => this.onChange('company', v)}>
公司名称
</InputItem>
<InputItem onChange={(v) => this.onChange('money', v)}>
职位薪资
</InputItem>
<TextareaItem
rows={3}
autoHeight
title="职位要求"
onChange={(v) => this.onChange('desc', v)}>
</TextareaItem>
<Button type="primary"
onClick={()=>{
this.props.update(this.state)
}}
>保存</Button>
</div>
)
}
}
export default BossInfo | 32.529412 | 106 | 0.445298 | false | true | true | false |
d0014fdc6f667864c0b15a9aecf62036b0633a5f | 2,067 | jsx | JSX | app/components/explorer/treefolderexplorer/folderCreateItem.jsx | learning-layers/LivingDocumentsClient | ff4ae0502957b1fafb07ecf0098ba5c108aaedd0 | [
"Apache-2.0"
] | null | null | null | app/components/explorer/treefolderexplorer/folderCreateItem.jsx | learning-layers/LivingDocumentsClient | ff4ae0502957b1fafb07ecf0098ba5c108aaedd0 | [
"Apache-2.0"
] | null | null | null | app/components/explorer/treefolderexplorer/folderCreateItem.jsx | learning-layers/LivingDocumentsClient | ff4ae0502957b1fafb07ecf0098ba5c108aaedd0 | [
"Apache-2.0"
] | null | null | null | "use strict";
import React from "react";
import jQuery from "jquery";
import FolderActions from "../../../reflux/folder/folderActions";
let Input = require("react-bootstrap").Input;
let FolderCreateItem = React.createClass({
getInitialState() {
return {
createFolderName: ""
};
},
reset() {
this.setState({
createFolderName: ""
});
},
componentDidMount: function() {
jQuery(document.body).on("keydown", this.handleKeyDown);
},
componentWillUnmount: function() {
jQuery(document.body).off("keydown", this.handleKeyDown);
},
changeCreateFolder(event) {
this.state.createFolderName = event.target.value;
this.setState({});
},
submit() {
let value = React.findDOMNode(this.refs.folderNameInput).childNodes[0].value;
console.info("current value=" + value);
// https://api.learnenv.com:9000/api/folders
//{name: "Test2"}
let newFolder = {name: value};
jQuery.post(
global.config.endpoint +
"/api/folders",
JSON.stringify(newFolder)
).then((data) => {
console.log(data);
FolderActions.newFolderCreated(data);
});
},
handleKeyDown: function(e) {
var ENTER = 13;
if( e.keyCode === ENTER ) {
this.submit();
}
},
render: function() {
let folderIcon = <span className="glyphicon glyphicon-folder-close"></span>;
let btnClasses = "btn-default";
return (
<li className="folder-item">
<button className={"btn btn-fab btn-fab-mini btn-raised btn-sm " + btnClasses}>
{folderIcon}
<div className="ripple-wrapper"></div>
</button>
<Input ref="folderNameInput" type="text" placeholder={this.props.folder} value={this.state.createFolderName} onChange={this.changeCreateFolder} />
</li>
);
}
});
export default FolderCreateItem; | 30.850746 | 162 | 0.562651 | false | true | false | true |
d0017763eae4b8df6209a88626e4d96ff3f7e144 | 5,605 | jsx | JSX | src/views/SignIn/index.jsx | sheunglaili/react-dashboard-template-with-firebase-login | e85f58c215374e284d792156053a4e7f5837ba23 | [
"MIT"
] | 8 | 2020-07-09T15:33:21.000Z | 2022-01-15T07:16:47.000Z | src/views/SignIn/index.jsx | sheunglaili/react-dashboard-template-with-firebase-login | e85f58c215374e284d792156053a4e7f5837ba23 | [
"MIT"
] | 2 | 2020-09-01T08:13:43.000Z | 2022-02-10T18:04:17.000Z | src/views/SignIn/index.jsx | sheunglaili/react-dashboard-template-with-firebase-login | e85f58c215374e284d792156053a4e7f5837ba23 | [
"MIT"
] | 8 | 2020-06-26T20:41:28.000Z | 2022-03-14T23:43:37.000Z | import React, { Component } from 'react';
import { Link, withRouter } from 'react-router-dom';
// Externals
import PropTypes from 'prop-types';
import compose from 'recompose/compose';
import validate from 'validate.js';
import _ from 'underscore';
// Material helpers
import { withStyles } from '@material-ui/core/styles/index';
// Material components
import Grid from '@material-ui/core/Grid/index';
import Button from '@material-ui/core/Button/index';
import CircularProgress from '@material-ui/core/CircularProgress/index';
import IconButton from '@material-ui/core/IconButton/index';
import TextField from '@material-ui/core/TextField/index';
import Typography from '@material-ui/core/Typography/index';
import ArrowBackIcon from '@material-ui/icons/ArrowBack';
// Shared components
import FacebookIcon from 'icons/Facebook';
import GoogleIcon from 'icons/Google';
// Component styles
import styles from './styles';
// Form validation schema
import schema from './schema';
import * as firebase from 'firebase/app'
import { connect } from 'react-redux';
import { auth } from '../../redux/modules/auth/action'
// Service methods
const signIn = () => {
return new Promise(resolve => {
setTimeout(() => {
resolve(true);
}, 1500);
});
};
class SignIn extends Component {
state = {
values: {
email: '',
password: ''
},
touched: {
email: false,
password: false
},
errors: {
email: null,
password: null
},
isValid: false,
isLoading: false,
submitError: null
};
componentWillMount() {
firebase.auth().useDeviceLanguage();
}
handleBack = () => {
const { history } = this.props;
history.goBack();
};
validateForm = _.debounce(() => {
const { values } = this.state;
const newState = { ...this.state };
const errors = validate(values, schema);
newState.errors = errors || {};
newState.isValid = errors ? false : true;
this.setState(newState);
}, 300);
handleFieldChange = (field, value) => {
const newState = { ...this.state };
newState.submitError = null;
newState.touched[field] = true;
newState.values[field] = value;
this.setState(newState, this.validateForm);
};
handleSignIn = async () => {
const provider = new firebase.auth.GoogleAuthProvider();
provider.addScope('https://www.googleapis.com/auth/documents');
provider.addScope('https://www.googleapis.com/auth/drive');
this.props.dispatch(auth(provider));
};
render() {
const { classes } = this.props;
const {
values,
touched,
errors,
isValid,
submitError,
isLoading
} = this.state;
const showEmailError = touched.email && errors.email;
const showPasswordError = touched.password && errors.password;
return (
<div className={classes.root}>
<Grid
className={classes.grid}
container
>
<Grid
className={classes.quoteWrapper}
item
lg={5}
>
<div className={classes.quote}>
<div className={classes.quoteInner}>
<Typography
className={classes.quoteText}
variant="h1"
>
Hella narwhal Cosby sweater McSweeney's, salvia kitsch before
they sold out High Life.
</Typography>
<div className={classes.person}>
<Typography
className={classes.name}
variant="body1"
>
Takamaru Ayako
</Typography>
<Typography
className={classes.bio}
variant="body2"
>
Manager at inVision
</Typography>
</div>
</div>
</div>
</Grid>
<Grid
className={classes.content}
item
lg={7}
xs={12}
>
<div className={classes.content}>
<div className={classes.contentHeader}>
<IconButton
className={classes.backButton}
onClick={this.handleBack}
>
<ArrowBackIcon />
</IconButton>
</div>
<div className={classes.contentBody}>
<form className={classes.form}>
<Typography
className={classes.title}
variant="h2"
>
Sign in
</Typography>
<Typography
className={classes.subtitle}
variant="body1"
>
Sign in with Google
</Typography>
<Button
className={classes.googleButton}
onClick={this.handleSignIn}
size="large"
variant="contained"
>
<GoogleIcon className={classes.googleIcon} />
Login with Google
</Button>
</form>
</div>
</div>
</Grid>
</Grid>
</div>
);
}
}
SignIn.propTypes = {
className: PropTypes.string,
classes: PropTypes.object.isRequired,
history: PropTypes.object.isRequired
};
export default compose(
withRouter,
withStyles(styles)
)(connect()(SignIn));
| 25.593607 | 79 | 0.532917 | false | true | true | false |
d0017e2ada3924d5b659224eb64f7cf1e7451d3a | 1,632 | jsx | JSX | templates/demo-store/src/components/ProductOptions.client.jsx | Shopify/hydrogen | effc509cbfc9ddf4bf8df9f8dff17daa47362dbb | [
"MIT"
] | 2,156 | 2021-11-06T02:52:37.000Z | 2022-03-31T23:54:13.000Z | templates/demo-store/src/components/ProductOptions.client.jsx | Shopify/hydrogen | effc509cbfc9ddf4bf8df9f8dff17daa47362dbb | [
"MIT"
] | 492 | 2021-11-07T06:38:58.000Z | 2022-03-31T16:20:43.000Z | templates/demo-store/src/components/ProductOptions.client.jsx | Shopify/hydrogen | effc509cbfc9ddf4bf8df9f8dff17daa47362dbb | [
"MIT"
] | 129 | 2021-11-07T09:54:08.000Z | 2022-03-30T06:10:18.000Z | import {useProductOptions} from '@shopify/hydrogen';
/**
* A client component that tracks a selected variant and/or selling plan state, as well as callbacks for modifying the state
*/
export default function ProductOptions() {
const {options, setSelectedOption, selectedOptions} = useProductOptions();
return (
<>
{options.map(({name, values}) => {
return (
<fieldset key={name} className="mt-8">
<legend className="mb-4 text-xl font-medium text-gray-900">
{name}
</legend>
<div className="flex items-center flex-wrap gap-4">
{values.map((value) => {
const checked = selectedOptions[name] === value;
const id = `option-${name}-${value}`;
return (
<label key={id} htmlFor={id}>
<input
className="sr-only"
type="radio"
id={id}
name={`option[${name}]`}
value={value}
checked={checked}
onChange={() => setSelectedOption(name, value)}
/>
<div
className={`p-2 border cursor-pointer rounded text-sm md:text-md ${
checked ? 'bg-gray-900 text-white' : 'text-gray-900'
}`}
>
{value}
</div>
</label>
);
})}
</div>
</fieldset>
);
})}
</>
);
}
| 32.64 | 124 | 0.433211 | false | true | false | true |
d00186671d0c1d2ca712dd5600b1ff6fc53d0549 | 2,920 | jsx | JSX | superset-frontend/spec/javascripts/views/CRUD/csstemplates/CssTemplateModal_spec.jsx | vinaybabunaidu/incubator-superset | 6c6ded139b80fd2799eb028f1421137c86096170 | [
"Apache-2.0"
] | 3 | 2021-02-19T01:43:50.000Z | 2021-08-14T04:56:41.000Z | superset-frontend/spec/javascripts/views/CRUD/csstemplates/CssTemplateModal_spec.jsx | vinaybabunaidu/incubator-superset | 6c6ded139b80fd2799eb028f1421137c86096170 | [
"Apache-2.0"
] | 39 | 2019-07-28T09:49:37.000Z | 2022-03-31T09:37:13.000Z | superset-frontend/spec/javascripts/views/CRUD/csstemplates/CssTemplateModal_spec.jsx | vinaybabunaidu/incubator-superset | 6c6ded139b80fd2799eb028f1421137c86096170 | [
"Apache-2.0"
] | 1 | 2020-12-07T12:24:49.000Z | 2020-12-07T12:24:49.000Z | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF 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 thunk from 'redux-thunk';
import configureStore from 'redux-mock-store';
import fetchMock from 'fetch-mock';
import CssTemplateModal from 'src/views/CRUD/csstemplates/CssTemplateModal';
import Modal from 'src/common/components/Modal';
import waitForComponentToPaint from 'spec/helpers/waitForComponentToPaint';
import { CssEditor } from 'src/components/AsyncAceEditor';
import { styledMount as mount } from 'spec/helpers/theming';
const mockData = { id: 1, template_name: 'test' };
const FETCH_CSS_TEMPLATE_ENDPOINT = 'glob:*/api/v1/css_template/*';
const CSS_TEMPLATE_PAYLOAD = { result: mockData };
fetchMock.get(FETCH_CSS_TEMPLATE_ENDPOINT, CSS_TEMPLATE_PAYLOAD);
const mockStore = configureStore([thunk]);
const store = mockStore({});
const mockedProps = {
addDangerToast: () => {},
onCssTemplateAdd: jest.fn(() => []),
onHide: () => {},
show: true,
cssTemplate: mockData,
};
async function mountAndWait(props = mockedProps) {
const mounted = mount(<CssTemplateModal show {...props} />, {
context: { store },
});
await waitForComponentToPaint(mounted);
return mounted;
}
describe('CssTemplateModal', () => {
let wrapper;
beforeAll(async () => {
wrapper = await mountAndWait();
});
it('renders', () => {
expect(wrapper.find(CssTemplateModal)).toExist();
});
it('renders a Modal', () => {
expect(wrapper.find(Modal)).toExist();
});
it('renders add header when no css template is included', async () => {
const addWrapper = await mountAndWait({});
expect(
addWrapper.find('[data-test="css-template-modal-title"]').text(),
).toEqual('Add CSS Template');
});
it('renders edit header when css template prop is included', () => {
expect(
wrapper.find('[data-test="css-template-modal-title"]').text(),
).toEqual('Edit CSS Template Properties');
});
it('renders input elements for template name', () => {
expect(wrapper.find('input[name="template_name"]')).toExist();
});
it('renders css editor for css', () => {
expect(wrapper.find(CssEditor)).toExist();
});
});
| 32.087912 | 76 | 0.697603 | false | true | false | true |
d0018f95982f4531527f472a879908b888c9966d | 1,200 | jsx | JSX | front/www/src/pages/ProfilePage.jsx | MattCo23/Project-Flanders | e9aef2ad5a5ea88644a7cab06b27fe95237d7b29 | [
"MIT",
"Unlicense"
] | 4 | 2020-11-26T03:25:12.000Z | 2021-08-29T19:49:27.000Z | front/www/src/pages/ProfilePage.jsx | MattCo23/Project-Flanders | e9aef2ad5a5ea88644a7cab06b27fe95237d7b29 | [
"MIT",
"Unlicense"
] | 12 | 2020-11-26T11:55:48.000Z | 2021-03-06T22:11:08.000Z | front/www/src/pages/ProfilePage.jsx | MattCo23/Project-Flanders | e9aef2ad5a5ea88644a7cab06b27fe95237d7b29 | [
"MIT",
"Unlicense"
] | null | null | null | import React from 'react';
import { Profile } from '../components/Profile/Profile';
import { ProfileData } from '../components/Profile/Subsections/ProfileData';
import { ProfilePass } from '../components/Profile/Subsections/ProfilePass';
import { ProfileContainer } from '../components/Profile/Subsections/ProfileContainer';
import { ProfileBookings } from '../components/Profile/Subsections/ProfileBookings';
export const ProfilePage = (props) => {
const { profile_data, profile_pass, profile_bookings, dispatch } = props;
return (
<>
{!(profile_data || profile_pass || profile_bookings) && <Profile {...props} />}
{profile_data && (
<ProfileContainer props={[{ profile_data: profile_data }, dispatch]}>
{<ProfileData {...props} />}
</ProfileContainer>
)}
{profile_pass && (
<ProfileContainer props={[{ profile_pass: profile_pass }, dispatch]}>
{<ProfilePass {...props} />}
</ProfileContainer>
)}
{profile_bookings && (
<ProfileContainer props={[{ profile_bookings: profile_bookings }, dispatch]}>
{<ProfileBookings {...props} />}
</ProfileContainer>
)}
</>
);
};
| 36.363636 | 86 | 0.640833 | false | true | false | true |
d00190949571005d82bd3ab924ba05559465d265 | 622 | jsx | JSX | packages/terra-notification-dialog/tests/jest/_ContentLayoutAsList.test.jsx | kschuste/terra-framework | c1e8afc2d38a2ef6505541ca8218b23fd37fc650 | [
"Apache-2.0"
] | 65 | 2017-11-16T20:32:58.000Z | 2021-06-01T16:46:48.000Z | packages/terra-notification-dialog/tests/jest/_ContentLayoutAsList.test.jsx | kschuste/terra-framework | c1e8afc2d38a2ef6505541ca8218b23fd37fc650 | [
"Apache-2.0"
] | 987 | 2017-10-23T19:46:57.000Z | 2022-03-29T14:41:37.000Z | packages/terra-notification-dialog/tests/jest/_ContentLayoutAsList.test.jsx | kschuste/terra-framework | c1e8afc2d38a2ef6505541ca8218b23fd37fc650 | [
"Apache-2.0"
] | 64 | 2018-01-30T16:08:46.000Z | 2022-03-02T15:43:45.000Z | import React from 'react';
/* eslint-disable import/no-extraneous-dependencies */
import { shallowWithIntl } from 'terra-enzyme-intl';
import ContentLayoutAsList from '../../src/_ContentLayoutAsList';
describe('Content Layout As List', () => {
it('shallow renders layout with no items', () => {
const list = shallowWithIntl(
<ContentLayoutAsList items={[]} />,
);
expect(list).toMatchSnapshot();
});
it('shallow renders layout with items', () => {
const list = shallowWithIntl(
<ContentLayoutAsList items={['item 1', 'item2']} />,
);
expect(list).toMatchSnapshot();
});
});
| 27.043478 | 65 | 0.646302 | false | true | false | true |
d001a72997b282e7c0640dafafe20792bcdeafbd | 320 | jsx | JSX | components/Image/index.jsx | tyrro/react-survey | 2615f2c7bf9c6df486a13d1a8fcd8c6b227a454d | [
"MIT"
] | 6 | 2022-03-07T07:30:19.000Z | 2022-03-16T10:38:14.000Z | components/Image/index.jsx | tyrro/react-survey | 2615f2c7bf9c6df486a13d1a8fcd8c6b227a454d | [
"MIT"
] | 46 | 2022-03-11T09:43:01.000Z | 2022-03-30T02:14:04.000Z | components/Image/index.jsx | tyrro/react-survey | 2615f2c7bf9c6df486a13d1a8fcd8c6b227a454d | [
"MIT"
] | null | null | null | import NextImage from 'next/image';
import PropTypes from 'prop-types';
const Image = ({ src, alt, ...attributes }) => <NextImage src={src} alt={alt} {...attributes} />;
Image.propTypes = {
src: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
alt: PropTypes.string.isRequired,
};
export default Image;
| 26.666667 | 97 | 0.7 | false | true | false | true |
d001b174b3ddf9cbd7ae149ab1fda61595b76411 | 2,320 | jsx | JSX | src/Components/JsonConfigComponent/ConfigCheckbox.jsx | ioBroker/adapter-react-v5 | 927b438392fe5b955a0cbe7b14f6509debdaec87 | [
"MIT"
] | 1 | 2022-03-30T08:11:30.000Z | 2022-03-30T08:11:30.000Z | src/Components/JsonConfigComponent/ConfigCheckbox.jsx | ioBroker/adapter-react-v5 | 927b438392fe5b955a0cbe7b14f6509debdaec87 | [
"MIT"
] | null | null | null | src/Components/JsonConfigComponent/ConfigCheckbox.jsx | ioBroker/adapter-react-v5 | 927b438392fe5b955a0cbe7b14f6509debdaec87 | [
"MIT"
] | null | null | null | import React from 'react';
import PropTypes from 'prop-types';
import { withStyles } from '@mui/styles';
import FormControlLabel from '@mui/material/FormControlLabel';
import Checkbox from '@mui/material/Checkbox';
import FormHelperText from '@mui/material/FormHelperText';
import FormControl from '@mui/material/FormControl';
import ConfigGeneric from './ConfigGeneric';
import I18n from '../../i18n';
const styles = theme => ({
error: {
color: 'red'
}
});
class ConfigCheckbox extends ConfigGeneric {
renderItem(error, disabled) {
const value = ConfigGeneric.getValue(this.props.data, this.props.attr);
let isIndeterminate = Array.isArray(value);
return <FormControl className={this.props.classes.fullWidth} variant="standard">
<FormControlLabel
onClick={e => {
e.preventDefault();
e.stopPropagation();
this.onChange(this.props.attr, !value);
}}
control={<Checkbox
indeterminate={isIndeterminate}
checked={!!value}
onChange={e => {
if (isIndeterminate) {
this.onChange(this.props.attr, true);
} else {
this.onChange(this.props.attr, e.target.checked);
}
}}
disabled={!!disabled}
/>}
label={this.getText(this.props.schema.label)}
/>
<FormHelperText className={this.props.classes.error}>{
error ? (this.props.schema.validatorErrorText ? I18n.t(this.props.schema.validatorErrorText) : I18n.t('ra_Error')) :
null}</FormHelperText>
{this.props.schema.help ? <FormHelperText>{this.renderHelp(this.props.schema.help, this.props.schema.helpLink, this.props.schema.noTranslation)}</FormHelperText> : null}
</FormControl>
}
}
ConfigCheckbox.propTypes = {
socket: PropTypes.object.isRequired,
themeType: PropTypes.string,
themeName: PropTypes.string,
style: PropTypes.object,
className: PropTypes.string,
data: PropTypes.object.isRequired,
schema: PropTypes.object,
onError: PropTypes.func,
onChange: PropTypes.func,
};
export default withStyles(styles)(ConfigCheckbox); | 35.692308 | 177 | 0.615948 | false | true | false | true |
d001bd29a68c86b46cbb299cb25cb8be5aafb8c0 | 2,487 | jsx | JSX | src/components/result/DidResult.jsx | sighttviewliu/universal-resolver-frontend | 771450453eff8d1d2270af1d284b06f9f8ba1a31 | [
"Apache-2.0"
] | 2 | 2018-12-05T12:45:48.000Z | 2019-06-27T12:08:08.000Z | src/components/result/DidResult.jsx | sighttviewliu/universal-resolver-frontend | 771450453eff8d1d2270af1d284b06f9f8ba1a31 | [
"Apache-2.0"
] | null | null | null | src/components/result/DidResult.jsx | sighttviewliu/universal-resolver-frontend | 771450453eff8d1d2270af1d284b06f9f8ba1a31 | [
"Apache-2.0"
] | null | null | null | import React, { Component } from 'react';
import { Card, Divider } from 'semantic-ui-react'
import DidReference from './DidReference';
import Service from './Service';
import PublicKey from './PublicKey';
export class DidResult extends Component {
render() {
var didDocumentServices;
if (Array.isArray(this.props.didDocument.service)) didDocumentServices = this.props.didDocument.service;
else if (typeof this.props.didDocument.service === 'object') didDocumentServices = Array.of(this.props.didDocument.service);
else didDocumentServices = Array.of();
const services = didDocumentServices.map((didDocumentService, i) =>
<Service key={i} name={didDocumentService.name} type={didDocumentService.type} serviceEndpoint={didDocumentService.serviceEndpoint} selected={this.props.resolverMetadata.selectedServices ? this.props.resolverMetadata.selectedServices.includes(i) : null} />
);
var didDocumentPublicKeys;
if (Array.isArray(this.props.didDocument.publicKey)) didDocumentPublicKeys = this.props.didDocument.publicKey;
else if (typeof this.props.didDocument.publicKey === 'object') didDocumentPublicKeys = Array.of(this.props.didDocument.publicKey);
else if (typeof this.props.didDocument.authentication === 'object' && Array.isArray(this.props.didDocument.authentication.publicKey)) didDocumentPublicKeys = this.props.didDocument.authentication.publicKey;
else if (typeof this.props.didDocument.authentication === 'object' && typeof this.props.didDocument.authentication.publicKey === 'object') didDocumentPublicKeys = Array.of(this.props.didDocument.authentication.publicKey);
else didDocumentPublicKeys = Array.of();
const publicKeys = didDocumentPublicKeys.map((didDocumentPublicKey, i) =>
<PublicKey key={i} type={didDocumentPublicKey.type} publicKeyBase64={didDocumentPublicKey.publicKeyBase64} publicKeyBase58={didDocumentPublicKey.publicKeyBase58} publicKeyPem={didDocumentPublicKey.publicKeyPem} publicKeyHex={didDocumentPublicKey.publicKeyHex} ethereumAddress={didDocumentPublicKey.ethereumAddress} address={didDocumentPublicKey.address} />
);
return (
<div className='did-result'>
<DidReference didReference={this.props.didReference} />
<Divider />
<Card.Group>
{services}
</Card.Group>
<Divider />
<Card.Group>
{publicKeys}
</Card.Group>
</div>
);
}
}
export default DidResult;
| 55.266667 | 359 | 0.739043 | true | false | true | false |
d001bf4483d72b928bbd27aebc004c0b1b1cbf09 | 883 | jsx | JSX | app/components/ProductsTable.jsx | char-lie/react-products-list | f53b3866caa51c445368d1010152153aa7d50363 | [
"MIT"
] | null | null | null | app/components/ProductsTable.jsx | char-lie/react-products-list | f53b3866caa51c445368d1010152153aa7d50363 | [
"MIT"
] | null | null | null | app/components/ProductsTable.jsx | char-lie/react-products-list | f53b3866caa51c445368d1010152153aa7d50363 | [
"MIT"
] | null | null | null | import React from 'react';
import PropTypes from 'prop-types';
import { Table, TableHead, TableRow, TableCell } from 'react-toolbox/lib/table';
import ProductModel from '../models/Product';
const ProductsTable = props => (
<Table selectable={false}>
<TableHead>
<TableCell>
Name
</TableCell>
<TableCell>
Color
</TableCell>
</TableHead>
{props.products.map(product => (
<TableRow>
<TableCell>
{product.name}
</TableCell>
<TableCell>
{product.color.toLowerCase()}
</TableCell>
</TableRow>
))}
</Table>
);
ProductsTable.propTypes = Object.freeze({
products: PropTypes.arrayOf(PropTypes.shape({
name: PropTypes.string.isRequired,
color: PropTypes.oneOf(ProductModel.AVAILABLE_COLORS).isRequired,
})).isRequired,
});
export default ProductsTable;
| 22.641026 | 80 | 0.631937 | false | true | false | true |
d001d36562f6f81b5127e9fb217d871c686eb665 | 297 | jsx | JSX | src/Footer.jsx | gallantry007/my-new-react-pr | 93b62968498bba3baeba8bca14781ef0694538c5 | [
"MIT"
] | null | null | null | src/Footer.jsx | gallantry007/my-new-react-pr | 93b62968498bba3baeba8bca14781ef0694538c5 | [
"MIT"
] | null | null | null | src/Footer.jsx | gallantry007/my-new-react-pr | 93b62968498bba3baeba8bca14781ef0694538c5 | [
"MIT"
] | null | null | null | import React from "react";
const Footer=()=>{
return(
<>
<footer className="bg-light text-center">
<p>
2022 Gallantry .All Right Reserved / Terms and Conditions Apply
</p>
</footer>
</>
)
}
export default Footer; | 16.5 | 79 | 0.498316 | false | true | false | true |
d001dddb2db90a72b356e977eda0d0e408792a7c | 2,824 | jsx | JSX | src/views/Login/index.jsx | KirillYoYo/Banks | 1c133f30cb54f05863fed5aaa195e1edebc69e33 | [
"MIT"
] | null | null | null | src/views/Login/index.jsx | KirillYoYo/Banks | 1c133f30cb54f05863fed5aaa195e1edebc69e33 | [
"MIT"
] | null | null | null | src/views/Login/index.jsx | KirillYoYo/Banks | 1c133f30cb54f05863fed5aaa195e1edebc69e33 | [
"MIT"
] | null | null | null | import React from 'react'
import PropTypes from 'prop-types'
import {Form, Input, Button, Row, Col, Icon, message} from 'antd'
import {bindActionCreators} from 'redux'
import {connect} from 'react-redux'
import {withRouter} from 'react-router-dom';
import {login} from '../../actions/auth'
const FormItem = Form.Item
import './index.sass'
const propTypes = {
user: PropTypes.object,
loggingIn: PropTypes.bool,
loginErrors: PropTypes.string
};
class Login extends React.Component {
constructor(props) {
super(props);
this.state = {
loading: false
}
}
componentWillReceiveProps(nextProps) {
if (nextProps.user !== this.props.user) {
if (nextProps.user) {
localStorage.setItem('uid', nextProps.user.uid);
this.props.history.replace('/main');
}
}
}
componentWillMount () {
if (localStorage.getItem('uid')) {
this.props.history.replace('/main');
}
}
shouldComponentUpdate () {
return !localStorage.getItem('uid')
}
handleSubmit(e) {
e.preventDefault();
this.setState({
loading: true
});
const data = this.props.form.getFieldsValue()
this.props.login(data.user, data.password)
this.setState({
loading: false
});
}
toRegister() {
this.props.history.replace('/register');
}
render() {
const {getFieldDecorator} = this.props.form
return (
<Row className="login-row" type="flex" justify="space-around" align="middle">
<Col span="8">
<Form layout="horizontal" onSubmit={this.handleSubmit.bind(this)} className="login-form">
<h2 className="logo"><span>logo</span></h2>
<FormItem>
{getFieldDecorator('user')(
<Input prefix={<Icon type="user" style={{fontSize: 13}}/>} placeholder='admin'/>
)}
</FormItem>
<FormItem>
{getFieldDecorator('password')(
<Input prefix={<Icon type="lock" style={{fontSize: 13}}/>} type='password'
placeholder='123456'/>
)}
</FormItem>
<p>
<Button className="btn-login" type='primary' size="large" icon="poweroff"
loading={this.state.loading} htmlType='submit'>Log</Button>
</p>
<p>
<Button className="btn-register" size="large" icon="right-square-o" htmlType='button'
onClick={this.toRegister.bind(this)}>Registration</Button>
</p>
</Form>
</Col>
</Row>
)
}
}
Login.propTypes = propTypes;
Login = Form.create()(Login);
function mapStateToProps(state) {
const {auth} = state;
if (auth.user) {
return {user: auth.user, loggingIn: auth.loggingIn, loginErrors: ''};
}
return {user: null, loggingIn: auth.loggingIn, loginErrors: auth.loginErrors};
}
function mapDispatchToProps(dispatch) {
return {
login: bindActionCreators(login, dispatch)
}
}
export default withRouter(connect(mapStateToProps, mapDispatchToProps)(Login))
| 24.136752 | 94 | 0.652975 | true | false | true | false |
d001f1ae731005741a7845a49216f8622320f157 | 1,927 | jsx | JSX | src/components/MediaComponents/MediaItem.jsx | PlayXman/reactapp-showcase | 269205e46f810074004694ea1b287bf47a470234 | [
"MIT"
] | null | null | null | src/components/MediaComponents/MediaItem.jsx | PlayXman/reactapp-showcase | 269205e46f810074004694ea1b287bf47a470234 | [
"MIT"
] | 34 | 2018-06-17T20:49:19.000Z | 2021-12-24T05:54:24.000Z | src/components/MediaComponents/MediaItem.jsx | PlayXman/app-msa | 269205e46f810074004694ea1b287bf47a470234 | [
"MIT"
] | null | null | null | import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import withStyles from '@material-ui/core/styles/withStyles';
import Grid from '@material-ui/core/Grid/Grid';
import OwnageBtn from '../Item/actions/OwnageBtn';
import Labels from '../Item/labels/Labels';
import SubMenu from '../Item/submenu/SubMenu';
import Item from '../Item/Item';
const style = {
cont: {
width: 158,
},
};
/**
* Main item component.
*/
class MediaItem extends PureComponent {
state = {
openSubmenu: false,
};
handleSubmenuOpen = () => {
this.setState({
openSubmenu: true,
});
};
handleSubmenuClose = () => {
this.setState({
openSubmenu: false,
});
};
render() {
const {
id,
itemId,
title,
releaseDate,
imageUrl,
isReleased,
ownageStatus,
labels,
children,
classes,
} = this.props;
const { openSubmenu } = this.state;
return (
<Grid item className={classes.cont} id={id}>
<Item
title={title}
releaseDate={releaseDate}
imageUrl={imageUrl}
isReleased={isReleased}
onClick={this.handleSubmenuOpen}
highlight={openSubmenu}
>
<OwnageBtn
released={isReleased}
ownageStatus={ownageStatus}
itemKey={itemId}
/>
<Labels labels={labels} />
</Item>
<SubMenu
open={openSubmenu}
onClose={this.handleSubmenuClose}
itemID={itemId}
itemTitle={title}
labels={labels}
>
{children}
</SubMenu>
</Grid>
);
}
}
MediaItem.propTypes = {
id: PropTypes.string,
itemId: PropTypes.string.isRequired,
title: PropTypes.string,
imageUrl: PropTypes.string,
releaseDate: PropTypes.string,
isReleased: PropTypes.bool,
ownageStatus: PropTypes.oneOf(['DEFAULT', 'DOWNLOADABLE', 'OWNED']),
labels: PropTypes.array,
children: PropTypes.oneOfType([PropTypes.element, PropTypes.arrayOf(PropTypes.element)]),
};
export default withStyles(style)(MediaItem);
| 20.284211 | 90 | 0.659056 | true | false | false | true |
d0020ce0723ee2e863d0ac191f58d872cba2a660 | 364 | jsx | JSX | src/components/Header.jsx | Quarzizus/curso-redux | 565c687da145d41de8083a2a1502818e3cacde7b | [
"MIT"
] | 1 | 2021-06-24T14:51:56.000Z | 2021-06-24T14:51:56.000Z | src/components/Header.jsx | Quarzizus/curso-redux | 565c687da145d41de8083a2a1502818e3cacde7b | [
"MIT"
] | null | null | null | src/components/Header.jsx | Quarzizus/curso-redux | 565c687da145d41de8083a2a1502818e3cacde7b | [
"MIT"
] | null | null | null | import React from "react";
import { Link } from "react-router-dom";
import "./styles/Header.scss";
const Header = () => {
return (
<header className="Header">
<Link to="/" className="Link">
<h2>Home</h2>
</Link>
<Link to="/users" className="Link">
<h2>Users</h2>
</Link>
</header>
);
};
export default Header;
| 19.157895 | 41 | 0.552198 | false | true | false | true |
d0020ed08e3a5ac6a483cdac5c8d0081df789a03 | 1,301 | jsx | JSX | app/components/pages/HCHelpPage.jsx | Connoropolous/HC-Admin | eff4385ef9ed2e62be4ca57b64164a4c01158747 | [
"MIT"
] | 3 | 2019-02-11T17:51:53.000Z | 2019-07-05T09:21:11.000Z | app/components/pages/HCHelpPage.jsx | Connoropolous/HC-Admin | eff4385ef9ed2e62be4ca57b64164a4c01158747 | [
"MIT"
] | 4 | 2019-02-09T03:29:21.000Z | 2019-04-30T05:47:37.000Z | app/components/pages/HCHelpPage.jsx | holochain/HC-Admin | 1d76faaf60155038ff0576e08017efc09585ed1e | [
"MIT"
] | 1 | 2019-02-07T13:28:42.000Z | 2019-02-07T13:28:42.000Z | import * as React from 'react';
import classNames from 'classnames';
import { Theme } from '@material-ui/core/styles/createMuiTheme';
import withStyles, { WithStyles } from '@material-ui/core/styles/withStyles';
import createStyles from '@material-ui/core/styles/createStyles';
import Typography from '@material-ui/core/Typography';
import QueueAnim from 'rc-queue-anim';
import Dashboard from "../page-components/Dashboard"
import styles from '../styles/page-styles/DefaultPageMuiStyles';
class HCHelpPage extends React.Component<WithStyles<typeof styles>, any> {
constructor(props: any) {
super(props);
this.state = {
open: true,
}
};
render() {
const { classes } = this.props;
const gutterBottom : boolean = true;
return (
<Dashboard>
<main className={classes.content}>
<div className={classes.appBarSpacer} />
<Typography className={classes.mainHeader} style={{color:"#e4e4e4"}} variant="display1" gutterBottom={gutterBottom} component="h2" >
Q&A Help Page + Administrator Settings
</Typography>
<br/>
<div className={classes.tableContainer}>
<Settings/>
</div>
</main>
</Dashboard>
);
}
}
export default withStyles(styles)(HCHelpPage);
| 30.255814 | 142 | 0.660261 | false | true | true | false |
d00211d290e0450c0b64e8b628e0f89487ab5967 | 417 | jsx | JSX | src/components/pages/Home/Home.jsx | Eazybee/Video-Album | 91990bf01dc4b83ec6ee74c6e5b5a39983c7b68d | [
"MIT"
] | null | null | null | src/components/pages/Home/Home.jsx | Eazybee/Video-Album | 91990bf01dc4b83ec6ee74c6e5b5a39983c7b68d | [
"MIT"
] | 5 | 2021-06-28T19:28:23.000Z | 2022-02-26T19:07:46.000Z | src/components/pages/Home/Home.jsx | Eazybee/Video-Album | 91990bf01dc4b83ec6ee74c6e5b5a39983c7b68d | [
"MIT"
] | null | null | null | import React, { useContext } from 'react';
import PageLayout from '../../ui/layout/PageLayout';
import Video from '<organisms>/Video/Video';
import VideoContext from '<context>/video';
const Homepage = () => {
const [videos] = useContext(VideoContext);
return (
<PageLayout>
{videos.map((videoData, key) => <Video key={key} {...videoData}/>)}
</PageLayout>
);
};
export default Homepage;
| 24.529412 | 75 | 0.647482 | false | true | false | true |
d002333595e82f0a03375b93fddcc17aa9acd563 | 423 | jsx | JSX | icons/jsx/SignalWifi0Bar.jsx | openedx/paragon | 370b558a906d5f1f451c204a0b1f653feccc24ac | [
"Apache-2.0"
] | 5 | 2022-02-16T17:22:51.000Z | 2022-03-29T13:50:03.000Z | icons/jsx/SignalWifi0Bar.jsx | arizzitano/excalibur | 5dc4acfaa731e7d7a4e9f13b492f73891f8ae970 | [
"Apache-2.0"
] | 196 | 2022-01-12T19:25:24.000Z | 2022-03-31T17:12:27.000Z | icons/jsx/SignalWifi0Bar.jsx | arizzitano/excalibur | 5dc4acfaa731e7d7a4e9f13b492f73891f8ae970 | [
"Apache-2.0"
] | 2 | 2022-01-20T11:50:25.000Z | 2022-01-26T17:25:41.000Z | import * as React from "react";
function SvgSignalWifi0Bar(props) {
return (
<svg
xmlns="http://www.w3.org/2000/svg"
width={24}
height={24}
viewBox="0 0 24 24"
{...props}
>
<path d="M12 4C7.31 4 3.07 5.9 0 8.98L12 21 24 8.98A16.88 16.88 0 0012 4zM2.92 9.07C5.51 7.08 8.67 6 12 6s6.49 1.08 9.08 3.07L12 18.17l-9.08-9.1z" />
</svg>
);
}
export default SvgSignalWifi0Bar;
| 23.5 | 155 | 0.586288 | false | true | false | true |
d00234a45cd4c2729aeb43b8c58eb74e77a65aa9 | 3,414 | jsx | JSX | src/components/search/HeaderSearch.jsx | LD4P/sinopia_editor | 28f433875b280be6ea28583f1a33faa069595fea | [
"Apache-2.0"
] | 24 | 2019-07-09T18:26:33.000Z | 2022-02-19T22:15:46.000Z | src/components/search/HeaderSearch.jsx | LD4P/sinopia_editor | 28f433875b280be6ea28583f1a33faa069595fea | [
"Apache-2.0"
] | 2,150 | 2018-09-26T17:30:33.000Z | 2022-03-31T10:16:49.000Z | src/components/search/HeaderSearch.jsx | LD4P/sinopia_editor | 28f433875b280be6ea28583f1a33faa069595fea | [
"Apache-2.0"
] | 6 | 2018-12-14T17:57:46.000Z | 2021-02-13T18:12:26.000Z | // Copyright 2019 Stanford University see LICENSE for license
import React, { useRef, useEffect, useState } from "react"
import { useSelector } from "react-redux"
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"
import { faSearch, faInfoCircle } from "@fortawesome/free-solid-svg-icons"
import { Popover } from "bootstrap"
import searchConfig from "../../../static/searchConfig.json"
import { sinopiaSearchUri } from "utilities/authorityConfig"
import useSearch from "hooks/useSearch"
import { selectSearchQuery } from "selectors/search"
const HeaderSearch = () => {
const [uri, setUri] = useState(sinopiaSearchUri)
const lastQueryString = useSelector((state) =>
selectSearchQuery(state, "resource")
)
const [query, setQuery] = useState("")
const popoverRef = useRef()
const { fetchNewSearchResults } = useSearch()
const options = searchConfig.map((config) => (
<option key={config.uri} value={config.uri}>
{config.label}
</option>
))
useEffect(() => {
if (lastQueryString) setQuery(lastQueryString)
}, [lastQueryString])
useEffect(() => {
const popover = new Popover(popoverRef.current, {
content:
'Sinopia search: use * as wildcard; default operator for multiple terms is AND; use | (pipe) as OR operator; use quotation marks for exact match. For more details see <a href="https://github.com/LD4P/sinopia/wiki/Searching-in-Sinopia">Searching in Sinopia</a>',
html: true,
})
return () => popover.hide
}, [popoverRef])
const handleQueryChange = (event) => {
setQuery(event.target.value)
event.preventDefault()
}
const handleUriChange = (event) => {
setUri(event.target.value)
event.preventDefault()
}
const handleSearchClick = (event) => {
event.preventDefault()
if (query === "") {
return
}
fetchNewSearchResults(query, uri)
}
const handleKeyPress = (event) => {
if (event.key === "Enter" && query !== "") {
fetchNewSearchResults(query, uri)
event.preventDefault()
}
}
return (
<div className="flex-grow-1">
<div className="input-group mb-2">
<label htmlFor="search" className="col-form-label pe-1 ms-5">
Search
</label>
<a
href="#tooltip"
className="tooltip-heading pt-2"
tabIndex="0"
data-bs-toggle="popover"
data-bs-trigger="focus"
ref={popoverRef}
>
<FontAwesomeIcon className="info-icon" icon={faInfoCircle} />
</a>
<select
className="flex-grow-0 form-select"
id="searchType"
value={uri}
onChange={handleUriChange}
onBlur={handleUriChange}
>
<option value={sinopiaSearchUri}>Sinopia</option>
{options}
</select>
<input
className="flex-grow-1 form-control"
type="search"
id="search"
onChange={handleQueryChange}
onBlur={handleQueryChange}
onKeyPress={handleKeyPress}
value={query}
/>
<button
className="btn btn-outline-secondary"
type="button"
aria-label="Submit search"
data-testid="Submit search"
onClick={handleSearchClick}
>
<FontAwesomeIcon icon={faSearch} />
</button>
</div>
</div>
)
}
export default HeaderSearch
| 29.179487 | 269 | 0.615407 | false | true | false | true |
d00240546a16457dee93184e1100802971d8bf92 | 453 | jsx | JSX | botfront/imports/ui/components/utils/Utils.jsx | thomas779/botfront | ba120f98d8b9877a136aa07284808392ce34381a | [
"Apache-2.0"
] | 737 | 2019-05-08T15:29:35.000Z | 2022-03-31T07:13:04.000Z | botfront/imports/ui/components/utils/Utils.jsx | thomas779/botfront | ba120f98d8b9877a136aa07284808392ce34381a | [
"Apache-2.0"
] | 367 | 2019-05-09T20:44:19.000Z | 2021-05-04T19:38:25.000Z | botfront/imports/ui/components/utils/Utils.jsx | thomas779/botfront | ba120f98d8b9877a136aa07284808392ce34381a | [
"Apache-2.0"
] | 303 | 2019-05-11T18:44:27.000Z | 2022-03-31T07:44:27.000Z | import React from 'react';
import PropTypes from 'prop-types';
import { Loader, Popup } from 'semantic-ui-react';
export function Loading({ loading, children }) {
return !loading ? children : <Loader active inline='centered' />;
}
export function tooltipWrapper(trigger, tooltip) {
return (
<Popup size='mini' inverted content={tooltip} trigger={trigger} />
);
}
Loading.propTypes = {
loading: PropTypes.bool.isRequired,
};
| 22.65 | 74 | 0.684327 | false | true | false | true |
d0024d02867c54efe1ac52688c358deda8d87070 | 2,560 | jsx | JSX | client/containers/ActivitiesContainer.jsx | LordRegis22/voyajour-travel | 367f75a5bb63663bd54b171f7d69a28730ebe455 | [
"MIT"
] | 1 | 2020-10-18T05:38:41.000Z | 2020-10-18T05:38:41.000Z | client/containers/ActivitiesContainer.jsx | LordRegis22/voyajour-travel | 367f75a5bb63663bd54b171f7d69a28730ebe455 | [
"MIT"
] | null | null | null | client/containers/ActivitiesContainer.jsx | LordRegis22/voyajour-travel | 367f75a5bb63663bd54b171f7d69a28730ebe455 | [
"MIT"
] | null | null | null | /* eslint-disable import/extensions */
import React, { useState } from 'react';
import { connect } from 'react-redux';
import { Button } from 'react-bootstrap';
import Activity from '../components/Activity.jsx';
import ActivityFormModal from '../components/AddActivityModal.jsx';
import * as actions from '../actions/actions';
const mapDispatchToProps = (dispatch) => ({
handleFormInput: (newState) => dispatch(actions.activityFormInput(newState)),
handleFormSubmit: (newState) =>
dispatch(actions.activityFormSubmit(newState)),
addToActivitiesArray: (activity, userId) =>
dispatch(actions.storeNewActivity(activity, userId)),
});
const mapStateToProps = (state) => ({
description: state.form.newActivity.description,
notes: state.form.newActivity.notes,
address: state.form.newActivity.address,
link: state.form.newActivity.link,
completed: state.form.newActivity.completed,
userId: state.form.activeUser.userId,
activities: state.trips.activities,
activeLocationId: state.trips.activeLocationId,
});
const ActivitiesContainer = (props) => {
// note, this is the use of React Hooks below. Typically, we wouldn't use
// hooks in a redux application, because we want all state in the store.
// however, we chose to use a hook here for this one piece of the application
const [showModal, setShowModal] = useState(false);
const {
description,
notes,
address,
link,
completed,
userId,
handleFormInput,
handleFormSubmit,
addToActivitiesArray,
activities,
activeLocationId,
} = props;
return (
<div id='large-activity-container'>
<ActivityFormModal
show={showModal}
onHide={() => setShowModal(false)}
description={description}
notes={notes}
address={address}
link={link}
userId={userId}
handleFormInput={handleFormInput}
handleFormSubmit={handleFormSubmit}
addActivity={addToActivitiesArray}
activeLocationId={activeLocationId}
/>
<h1>Activities: </h1>
<div id='all-activities'>
<Button onClick={() => setShowModal(true)}>Add Activity</Button>
{activities.map((el, i) => (
<Activity
key={`activity${i}`}
description={el.description}
notes={el.notes}
address={el.address}
link={el.link}
locationId={el.location_id}
/>
))}
</div>
</div>
);
};
export default connect(
mapStateToProps,
mapDispatchToProps
)(ActivitiesContainer);
| 30.47619 | 79 | 0.663672 | false | true | false | true |
d00250d309a72db7085c443b4f5982363b782288 | 1,628 | jsx | JSX | src/views/ComingSoonScreen.jsx | adimute/dvir-dashboard | 23a08556c4f98151ab992bf7e7971e17a22ae156 | [
"MIT"
] | 1 | 2020-02-22T18:44:46.000Z | 2020-02-22T18:44:46.000Z | src/views/ComingSoonScreen.jsx | adimute/dvir-dashboard | 23a08556c4f98151ab992bf7e7971e17a22ae156 | [
"MIT"
] | 1 | 2022-02-10T21:16:59.000Z | 2022-02-10T21:16:59.000Z | src/views/ComingSoonScreen.jsx | adimute/dvir-dashboard | 23a08556c4f98151ab992bf7e7971e17a22ae156 | [
"MIT"
] | null | null | null | /*!
=========================================================
* Paper Dashboard React - v1.1.0
=========================================================
* Product Page: https://www.creative-tim.com/product/paper-dashboard-react
* Copyright 2019 Creative Tim (https://www.creative-tim.com)
* Licensed under MIT (https://github.com/creativetimofficial/paper-dashboard-react/blob/master/LICENSE.md)
* Coded by Creative Tim
=========================================================
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*/
import React from "react";
// reactstrap components
import {
Card,
CardHeader,
CardBody,
CardTitle,
Table,
Row,
Col
} from "reactstrap";
class ComingSoonScreen extends React.Component {
render() {
return (
<>
<div className="content">
<Row>
<Col md="12">
<Card>
<CardHeader>
<CardTitle tag="h4">Coming Soon Screen</CardTitle>
</CardHeader>
<CardBody>
</CardBody>
</Card>
</Col>
<Col md="12">
<Card className="card-plain">
<CardHeader>
<CardTitle tag="h4"></CardTitle>
<p className="card-category">
</p>
</CardHeader>
<CardBody>
</CardBody>
</Card>
</Col>
</Row>
</div>
</>
);
}
}
export default ComingSoonScreen;
| 24.298507 | 128 | 0.468673 | false | true | true | false |
d0029051ff84b9a5e5e6fc605573ef6932971795 | 187 | jsx | JSX | section_15_react_router_w_hooks/project_1/src/Redux.jsx | Kubixii/React | 2bd831fb8f39f19eaf8b1d0d391f9e2870db6a40 | [
"MIT"
] | null | null | null | section_15_react_router_w_hooks/project_1/src/Redux.jsx | Kubixii/React | 2bd831fb8f39f19eaf8b1d0d391f9e2870db6a40 | [
"MIT"
] | null | null | null | section_15_react_router_w_hooks/project_1/src/Redux.jsx | Kubixii/React | 2bd831fb8f39f19eaf8b1d0d391f9e2870db6a40 | [
"MIT"
] | null | null | null | import React from 'react'
const Redux = () => {
return (
<article>
<h2>
Redux
</h2>
</article>
);
}
export default Redux; | 14.384615 | 25 | 0.411765 | false | true | false | true |
d002925e8d33eb33df1321798408a78e940c90a2 | 1,794 | jsx | JSX | client/src/components/Chat/Chat/Dialog/Dialog.jsx | gabivlj/R | 582faecf6f24429859d467f6e5859837dcd71a8d | [
"MIT"
] | 7 | 2019-08-18T10:53:10.000Z | 2020-08-25T00:32:13.000Z | client/src/components/Chat/Chat/Dialog/Dialog.jsx | gabivlj/R | 582faecf6f24429859d467f6e5859837dcd71a8d | [
"MIT"
] | 4 | 2019-11-22T00:31:34.000Z | 2022-01-22T09:56:36.000Z | client/src/components/Chat/Chat/Dialog/Dialog.jsx | gabivlj/R | 582faecf6f24429859d467f6e5859837dcd71a8d | [
"MIT"
] | 1 | 2020-05-31T01:39:55.000Z | 2020-05-31T01:39:55.000Z | import React, { useEffect, useRef } from 'react';
import ReactDOM from 'react-dom';
import {
Dialog,
DialogTitle,
DialogContent,
DialogContentText,
DialogActions,
Button,
CircularProgress,
} from '@material-ui/core';
export default function DialogMe({
open,
handleClose,
title,
Render,
propsRender,
renderActions,
image,
handleBack,
isLoading,
handleFriend,
titleButton,
scrollableGeneral,
onScroll,
}) {
return (
<div>
<Dialog
open={open}
onScroll={onScroll || function() {}}
onClose={handleClose}
scroll={scrollableGeneral ? 'body' : 'paper'}
aria-labelledby="scroll-dialog-title"
fullWidth
maxWidth="md"
>
<DialogTitle
id="scroll-dialog-title"
style={{ borderBottom: '1px solid #dce7f2' }}
>
{image}
{title}
<Button
onClick={handleFriend}
className="ml-3"
type="button"
color="primary"
>
{titleButton}
</Button>
<Button
onClick={handleClose}
className="ml-3"
type="button"
color="secondary"
>
Close
</Button>
</DialogTitle>
<DialogContent modal="false" dividers="true">
{isLoading ? (
<div style={{ padding: '10% 10% 10% 50%' }}>
<CircularProgress />
</div>
) : (
<Render {...propsRender} />
)}
</DialogContent>
<DialogActions
disableActionSpacing
style={{ borderTop: '1px solid #dce7f2', overflowX: 'hidden' }}
>
{renderActions}
</DialogActions>
</Dialog>
</div>
);
}
| 21.878049 | 73 | 0.513378 | false | true | false | true |
d00293f04c6094aa3a154597ba83b10ab3f290dd | 2,012 | jsx | JSX | webapp/components/admin_console/admin_console.jsx | realrolfje/mattermost-platform | 1397798f1763b0848957a8672c8d40b6243764d5 | [
"Apache-2.0"
] | null | null | null | webapp/components/admin_console/admin_console.jsx | realrolfje/mattermost-platform | 1397798f1763b0848957a8672c8d40b6243764d5 | [
"Apache-2.0"
] | null | null | null | webapp/components/admin_console/admin_console.jsx | realrolfje/mattermost-platform | 1397798f1763b0848957a8672c8d40b6243764d5 | [
"Apache-2.0"
] | 1 | 2020-09-18T02:17:38.000Z | 2020-09-18T02:17:38.000Z | // Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
import React from 'react';
import 'bootstrap';
import ErrorBar from 'components/error_bar.jsx';
import AdminStore from 'stores/admin_store.jsx';
import * as AsyncClient from 'utils/async_client.jsx';
import AdminSidebar from './admin_sidebar.jsx';
export default class AdminConsole extends React.Component {
static get propTypes() {
return {
children: React.PropTypes.node.isRequired
};
}
constructor(props) {
super(props);
this.handleConfigChange = this.handleConfigChange.bind(this);
this.state = {
config: AdminStore.getConfig()
};
}
componentWillMount() {
AdminStore.addConfigChangeListener(this.handleConfigChange);
AsyncClient.getConfig();
}
componentWillUnmount() {
AdminStore.removeConfigChangeListener(this.handleConfigChange);
}
handleConfigChange() {
this.setState({
config: AdminStore.getConfig()
});
}
render() {
const config = this.state.config;
if (!config) {
return <div/>;
}
if (config && Object.keys(config).length === 0 && config.constructor === 'Object') {
return (
<div className='admin-console__wrapper'>
<ErrorBar/>
<div className='admin-console'/>
</div>
);
}
// not every page in the system console will need the config, but the vast majority will
const children = React.cloneElement(this.props.children, {
config: this.state.config
});
return (
<div className='admin-console__wrapper'>
<ErrorBar/>
<div className='admin-console'>
<AdminSidebar/>
{children}
</div>
</div>
);
}
}
| 27.189189 | 96 | 0.567097 | false | true | true | false |
d00295d4cabb840c28fba53287dc574646e645fa | 487 | jsx | JSX | src/components/Input/Input.jsx | YanaDerevianko/matrix-creator | 84a8e1c4c8814747c1235e75dddf77e56d1e7417 | [
"MIT"
] | null | null | null | src/components/Input/Input.jsx | YanaDerevianko/matrix-creator | 84a8e1c4c8814747c1235e75dddf77e56d1e7417 | [
"MIT"
] | null | null | null | src/components/Input/Input.jsx | YanaDerevianko/matrix-creator | 84a8e1c4c8814747c1235e75dddf77e56d1e7417 | [
"MIT"
] | null | null | null | import React from "react";
import store from "../../redux/store";
import shortid from 'shortid';
export const Input = ({ inputLabel, inputHandler, value }) => {
const setValueHandler = (param) => store.dispatch(inputHandler(param));
return (
<label htmlFor={shortid.generate()}>
{inputLabel}
<input
id={shortid.generate()}
type="number"
onChange={(e) => setValueHandler(+e.target.value)}
value={value}
/>
</label>
);
}; | 24.35 | 73 | 0.601643 | false | true | false | true |
d002ab53567f5b9a746e294e305ab2a217c488c6 | 477 | jsx | JSX | src/components/startpage/serviceitem.jsx | dominikhofmanpl/mwcollective-gatsby-wordpress-site | c266325f32eecc8df625e3044cdd5fbab8d739de | [
"RSA-MD"
] | null | null | null | src/components/startpage/serviceitem.jsx | dominikhofmanpl/mwcollective-gatsby-wordpress-site | c266325f32eecc8df625e3044cdd5fbab8d739de | [
"RSA-MD"
] | null | null | null | src/components/startpage/serviceitem.jsx | dominikhofmanpl/mwcollective-gatsby-wordpress-site | c266325f32eecc8df625e3044cdd5fbab8d739de | [
"RSA-MD"
] | null | null | null | import React from 'react'
const ServiceItem = ({serviceIcon, serviceTitle, serviceDescription}) => {
return (
<div className="flex flex-col py-4 md:mr-4">
<img src={serviceIcon} alt="" srcset="" style={{
width: `4rem`
}} className="my-3"/>
<h3 className="mont-semi my-1">{serviceTitle}</h3>
<p className="inriasans-reg my-3">{serviceDescription}</p>
</div>
)
}
export default ServiceItem | 31.8 | 74 | 0.572327 | false | true | false | true |
d002adcb2d63e54b1fb80cf2dd820a39426fcd43 | 739 | jsx | JSX | src/components/porfolio-page.jsx | HenKyubi666/HenKyubi666.github.io | c1cf7a60b27067c363ac83ee88a4291ccf04f4c0 | [
"RSA-MD"
] | null | null | null | src/components/porfolio-page.jsx | HenKyubi666/HenKyubi666.github.io | c1cf7a60b27067c363ac83ee88a4291ccf04f4c0 | [
"RSA-MD"
] | null | null | null | src/components/porfolio-page.jsx | HenKyubi666/HenKyubi666.github.io | c1cf7a60b27067c363ac83ee88a4291ccf04f4c0 | [
"RSA-MD"
] | null | null | null | import React from "react"
const PorfolioPage = ({ imgPage, altImgPage, title, description, urlPage }) => (
<div className="h-100 w-100 card d-flex flex-column porfolio-slide">
<div className="my-auto">
<div className="d-flex justify-content-center">
<img className="img-portfolio" src={imgPage} alt={altImgPage} />
</div>
<div className="card-body">
<h5 className="fs-2 fw-bold text-center">{title}</h5>
<p className="fs-6 text-center">{description}</p>
<div className="d-flex justify-content-center">
<a href={urlPage} className="btn-porfolio-page text-center">
Go
</a>
</div>
</div>
</div>
</div>
)
export default PorfolioPage
| 32.130435 | 80 | 0.607578 | false | true | false | true |
d002c36c6eaf4a1f801106f9bf96bda2c36d123f | 1,786 | jsx | JSX | example/src/containers/Topbar.jsx | ryo-channel/ui-neumorphism | 497e3457cbab55294d07969881fafad73fcf6924 | [
"MIT"
] | 516 | 2020-06-11T20:27:01.000Z | 2022-03-29T18:23:00.000Z | example/src/containers/Topbar.jsx | bottlehs/ui-neumorphism | 1b09f20a6bd16eb8813a7ad50775845a4699862e | [
"MIT"
] | 12 | 2020-06-11T20:27:00.000Z | 2022-02-21T15:35:04.000Z | example/src/containers/Topbar.jsx | saeedkefayati/ui-neumorphism | 197a3c3c7b160342f10b9eac8c82796ae349cf8f | [
"MIT"
] | 41 | 2020-06-23T08:10:17.000Z | 2022-03-30T16:32:11.000Z | import React, { createElement } from 'react'
import Icon from '@mdi/react'
import {
mdiNpm,
mdiMenu,
mdiGithub,
mdiLightbulb,
mdiLightbulbOutline
} from '@mdi/js'
import { H2, H6, Card, IconButton, ToggleButton } from 'ui-neumorphism'
const npmUrl = 'https://www.npmjs.com/package/ui-neumorphism'
const githubUrl = 'https://github.com/AKAspanion/ui-neumorphism'
class Topbar extends React.Component {
open(url) {
window.open(url, '_blank')
}
render() {
const { dark, onClick, onMenuClick, size } = this.props
const isSmall = size === 'sm' || size === 'xs'
const menuButton = isSmall ? (
<IconButton onClick={onMenuClick}>
<Icon path={mdiMenu} size={1} />
</IconButton>
) : null
const title = createElement(
isSmall ? H6 : H2,
{ style: { color: 'var(--primary)' }, className: 'topbar-title' },
'UI-Neumorphism'
)
return (
<Card flat dark={dark} className={`main-topbar`}>
<Card flat className='d-flex align-center topbar-headline'>
{menuButton}
{title}
</Card>
<Card flat className='d-flex align-center topbar-actions'>
<IconButton
className='topbar-action mr-1'
onClick={() => this.open(npmUrl)}
>
<Icon path={mdiNpm} size={1.4} />
</IconButton>
<IconButton
className='topbar-action'
onClick={() => this.open(githubUrl)}
>
<Icon path={mdiGithub} size={1} />
</IconButton>
<ToggleButton className='topbar-action' onChange={onClick}>
<Icon path={dark ? mdiLightbulbOutline : mdiLightbulb} size={1} />
</ToggleButton>
</Card>
</Card>
)
}
}
export default Topbar
| 27.476923 | 78 | 0.578387 | false | true | true | false |
d002c37ddfa0cc36f0e55bed0af44a903e02f22b | 5,257 | jsx | JSX | src/components/editor/InterfaceList.jsx | zpkweb/rap2-dolores | 75730036d55be8503415d3ba1f3aaee79ae0f3f0 | [
"MIT"
] | null | null | null | src/components/editor/InterfaceList.jsx | zpkweb/rap2-dolores | 75730036d55be8503415d3ba1f3aaee79ae0f3f0 | [
"MIT"
] | 14 | 2020-07-17T03:44:23.000Z | 2022-03-03T22:19:59.000Z | src/components/editor/InterfaceList.jsx | zpkweb/rap2-dolores | 75730036d55be8503415d3ba1f3aaee79ae0f3f0 | [
"MIT"
] | null | null | null | import React, { Component } from 'react'
import { PropTypes, connect, Link, replace, StoreStateRouterLocationURI } from '../../family'
import { RModal, RSortable } from '../utils'
import InterfaceForm from './InterfaceForm'
import { GoPencil, GoTrashcan, GoRocket, GoLock } from 'react-icons/lib/go'
import { getCurrentInterface } from '../../selectors/interface'
class Interface extends Component {
static contextTypes = {
store: PropTypes.object.isRequired,
onDeleteInterface: PropTypes.func.isRequired
}
static propTypes = {
auth: PropTypes.object.isRequired,
repository: PropTypes.object.isRequired,
mod: PropTypes.object.isRequired,
itf: PropTypes.object.isRequired,
active: PropTypes.bool.isRequired,
curItf: PropTypes.object
}
constructor (props) {
super(props)
this.state = { update: false }
}
render () {
let { store } = this.context
let { auth, repository, mod, itf } = this.props
let selectHref = StoreStateRouterLocationURI(store).setSearch('itf', itf.id).href()
let isOwned = repository.owner.id === auth.id
let isJoined = repository.members.find(itme => itme.id === auth.id)
return (
<div className='Interface clearfix'>
{/* 这层 name 包裹的有点奇怪,name 应该直接加到 a 上 */}
{/* TODO 2.3 <a> 的范围应该扩大至整个 Interface,否则只有点击到 <a> 才能切换,现在不容易点击到 <a> */}
<span className='name'>
{itf.locker ? <span className='locked mr5'><GoLock /></span> : null}
<Link to={selectHref} onClick={(e) => {
if (this.props.curItf && this.props.curItf.locker && !window.confirm('编辑模式下切换接口,会导致编辑中的资料丢失,是否确定切换接口?')) {
e.preventDefault()
}
}}><span>{itf.name}</span></Link>
</span>
{isOwned || isJoined
? <div className='toolbar'>
{/* DONE 2.2 X 支持双击修改 */}
{!itf.locker || itf.locker.id === auth.id
? <span className='fake-link' onClick={e => this.setState({ update: true })}><GoPencil /></span>
: null
}
<RModal when={this.state.update} onClose={e => this.setState({ update: false })} onResolve={this.handleUpdate}>
<InterfaceForm title='修改接口' repository={repository} mod={mod} itf={itf} />
</RModal>
{!itf.locker
? <Link to='' onClick={e => this.handleDelete(e, itf)}><GoTrashcan /></Link>
: null
}
</div>
: null
}
</div>
)
}
handleDelete = (e, itf) => {
e.preventDefault()
let message = `接口被删除后不可恢复!\n确认继续删除『#${itf.id} ${itf.name}』吗?`
if (window.confirm(message)) {
let { onDeleteInterface } = this.context
onDeleteInterface(itf.id, () => {
let { store } = this.context
let uri = StoreStateRouterLocationURI(store)
let deleteHref = this.props.active ? uri.removeSearch('itf').href() : uri.href()
store.dispatch(replace(deleteHref))
})
}
}
handleUpdate = (e) => {
}
}
class InterfaceList extends Component {
static contextTypes = {
store: PropTypes.object.isRequired,
onSortInterfaceList: PropTypes.func.isRequired
}
static propTypes = {
auth: PropTypes.object.isRequired,
repository: PropTypes.object.isRequired,
mod: PropTypes.object.isRequired,
itfs: PropTypes.array,
itf: PropTypes.object,
curItf: PropTypes.object
}
constructor (props) {
super(props)
this.state = { create: false }
}
render () {
let { auth, repository, mod, itfs = [], itf, curItf } = this.props
if (!mod.id) return null
let isOwned = repository.owner.id === auth.id
let isJoined = repository.members.find(itme => itme.id === auth.id)
return (
<article className='InterfaceList'>
<RSortable onChange={this.handleSort} disabled={!isOwned && !isJoined}>
<ul className='body'>
{itfs.map(item =>
<li key={item.id} className={item.id === itf.id ? 'active sortable' : 'sortable'} data-id={item.id}>
<Interface repository={repository} mod={mod} itf={item} active={item.id === itf.id} auth={auth} curItf={curItf} />
</li>
)}
</ul>
</RSortable>
{isOwned || isJoined
? <div className='footer'>
{/* DONE 2.2 反复 setState() 还是很繁琐,需要提取一个类似 DialogController 的组件 */}
{/* DONE 2.2 如何重构为高阶组件 */}
<span className='fake-link' onClick={e => this.setState({ create: true })}>
<span className='fontsize-14'><GoRocket /></span> 新建接口
</span>
<RModal when={this.state.create} onClose={e => this.setState({ create: false })} onResolve={this.handleCreate}>
<InterfaceForm title='新建接口' repository={repository} mod={mod} />
</RModal>
</div>
: null}
</article>
)
}
handleCreate = (e) => {
}
handleSort = (e, sortable) => {
let { onSortInterfaceList } = this.context
onSortInterfaceList(sortable.toArray())
}
}
const mapStateToProps = (state) => ({
auth: state.auth,
curItf: getCurrentInterface(state)
})
const mapDispatchToProps = ({})
export default connect(
mapStateToProps,
mapDispatchToProps
)(InterfaceList)
| 35.761905 | 130 | 0.596158 | false | true | true | false |
d002ca1786717976c811eaec1108c0f7478d7a76 | 271 | jsx | JSX | src/components/Button.jsx | Soulfull/jeeves | 7867ef6eae8872bfe1ec40911ee1ba723d2f57a4 | [
"Apache-2.0"
] | null | null | null | src/components/Button.jsx | Soulfull/jeeves | 7867ef6eae8872bfe1ec40911ee1ba723d2f57a4 | [
"Apache-2.0"
] | null | null | null | src/components/Button.jsx | Soulfull/jeeves | 7867ef6eae8872bfe1ec40911ee1ba723d2f57a4 | [
"Apache-2.0"
] | null | null | null | import React from 'react';
import { Link } from 'framework7-react';
const Button = (props) => (
<Link
className={`${props.className ? props.className : 'app-button'}`}
href={props.href}
>
{props.children}
</Link>
);
export default Button;
| 19.357143 | 71 | 0.605166 | false | true | false | true |
d002d129ba3076156d3bf0af39167dfc6707c5b2 | 1,329 | jsx | JSX | src/components/layouts/BoxedLayout/index.jsx | Scot3004/gatsby-atomic-tested-starter | 63534fe69efab84beeb1143cb0f9695931ec5c69 | [
"MIT"
] | 3 | 2019-02-04T12:54:09.000Z | 2021-02-20T16:40:24.000Z | src/components/layouts/BoxedLayout/index.jsx | Scot3004/gatsby-atomic-tested-starter | 63534fe69efab84beeb1143cb0f9695931ec5c69 | [
"MIT"
] | 48 | 2019-02-03T14:05:23.000Z | 2019-07-05T03:49:28.000Z | src/components/layouts/BoxedLayout/index.jsx | Scot3004/gatsby-atomic-tested-starter | 63534fe69efab84beeb1143cb0f9695931ec5c69 | [
"MIT"
] | 2 | 2019-02-03T14:37:21.000Z | 2019-02-06T23:42:34.000Z | import React from 'react';
import PropTypes from 'prop-types';
import { Helmet } from 'react-helmet';
import { ThemeProvider } from 'styled-components';
import Container from '../../atoms/Container';
import MainContainer from '../../atoms/MainContainer';
import PageGrid from '../../atoms/PageGrid';
import Navigation from '../../organisms/Navigation';
import GlobalStyle from '../../atoms/GlobalStyle';
import theme from '../../../theme';
import Profile from '../../organisms/Profile';
import Sidebar from '../../atoms/Sidebar';
export const BoxedLayout = ({ title, menuLinks, avatar, children }) => (
<ThemeProvider theme={theme}>
<>
<Helmet>
<title>{title}</title>
</Helmet>
<GlobalStyle />
<Container>
<PageGrid>
<Navigation menuLinks={menuLinks} />
<Sidebar>
<Profile name={title} avatar={avatar} />
</Sidebar>
<MainContainer>{children}</MainContainer>
</PageGrid>
</Container>
</>
</ThemeProvider>
);
BoxedLayout.propTypes = {
title: PropTypes.string.isRequired,
menuLinks: PropTypes.arrayOf(PropTypes.node).isRequired,
avatar: PropTypes.string.isRequired,
children: PropTypes.oneOfType([
PropTypes.arrayOf(PropTypes.node),
PropTypes.node
]).isRequired
};
export default BoxedLayout;
| 29.533333 | 72 | 0.654628 | false | true | false | true |
d002d63b7873b000e2b921ad06e03f92d34cbeeb | 496 | jsx | JSX | src/App.jsx | jenwill/jpiper-takehome | 74b7b0d1a05188a7ea507a2dfa783cb0d4559784 | [
"MIT"
] | null | null | null | src/App.jsx | jenwill/jpiper-takehome | 74b7b0d1a05188a7ea507a2dfa783cb0d4559784 | [
"MIT"
] | null | null | null | src/App.jsx | jenwill/jpiper-takehome | 74b7b0d1a05188a7ea507a2dfa783cb0d4559784 | [
"MIT"
] | null | null | null | import React, { Component, Fragment } from 'react';
import { hot } from 'react-hot-loader';
import Header from './components/header/header.jsx';
import Breadcrumbs from './components/breadcrumbs/breadcrumbs.jsx';
import './styles/main.scss';
class App extends Component {
constructor(props) {
super(props);
this.state = {};
}
render() {
return (
<Fragment>
<Header title="J. Piper" />
<Breadcrumbs />
</Fragment>
);
}
}
export default hot(module)(App);
| 20.666667 | 67 | 0.647177 | false | true | true | false |
d002d6e6026fe2cc64e42bf42d617c20ba8eb3cc | 2,347 | jsx | JSX | src/components/Footer/Footer.jsx | Abhinav1923/covilive | 56e447943c78a700775d3c3539a6150cb84ace1d | [
"MIT"
] | null | null | null | src/components/Footer/Footer.jsx | Abhinav1923/covilive | 56e447943c78a700775d3c3539a6150cb84ace1d | [
"MIT"
] | null | null | null | src/components/Footer/Footer.jsx | Abhinav1923/covilive | 56e447943c78a700775d3c3539a6150cb84ace1d | [
"MIT"
] | null | null | null | import { Stack, Typography, Link } from '@mui/material'
import { Box } from '@mui/system'
import React from 'react'
import IconButton from '@mui/material/IconButton';
import GitHubIcon from '@mui/icons-material/GitHub';
import LinkedInIcon from '@mui/icons-material/LinkedIn';
import { Dribbble } from '../../assets/images';
import { makeStyles } from '@mui/styles';
const useStyles = makeStyles(() => ({
iconButton: {
'&:hover': {
backgroundColor: 'initial !important'
}
},
github: {
color: 'grey',
'&:hover': {
color: 'black'
}
},
linkedin: {
color: 'grey',
'&:hover': {
color: '#43A4FF'
}
},
dribbble: {
fill: 'grey',
width: '26px',
'&:hover': {
fill: '#ea4c89'
}
},
}))
export default function Footer() {
const classes = useStyles();
return (
<>
<Box py={3} sx={{ textAlign: 'center' }}>
<Typography variant='body2' gutterBottom sx={{ color: '#000000' }}>
Designed & Developed by Abhinav Gupta
</Typography>
<Stack direction='row' spacing={2} sx={{ justifyContent: 'center', marginTop: 1 }}>
<IconButton disableRipple aria-label="github" color='secondary' className={classes.iconButton}>
<Link href="https://github.com/Abhinav1923">
<GitHubIcon className={classes.github} />
</Link>
</IconButton>
<IconButton disableFocusRipple disableRipple aria-label="linkedin" color="secondary" className={classes.iconButton}>
<Link href="https://www.linkedin.com/in/abhinav-gupta2319/">
<LinkedInIcon className={classes.linkedin} />
</Link>
</IconButton>
<IconButton disableRipple color="secondary" aria-label="dribbble" className={classes.iconButton}>
<Link href="https://dribbble.com/Abhinav_19">
<Dribbble className={classes.dribbble} />
</Link>
</IconButton>
</Stack>
</Box>
</>
)
}
| 34.514706 | 136 | 0.505326 | false | true | false | true |
d002dced7a91ef12d95201b4d8405abf06b84cc8 | 434 | jsx | JSX | src/views/MessageDetail.jsx | Huierc/gallery-by-react | 08781ca6120a235b76b4ba0c18752b6e1b40bff3 | [
"MIT"
] | 2 | 2018-07-03T02:14:43.000Z | 2018-07-27T06:15:46.000Z | src/views/MessageDetail.jsx | Huierc/gallery-by-react | 08781ca6120a235b76b4ba0c18752b6e1b40bff3 | [
"MIT"
] | null | null | null | src/views/MessageDetail.jsx | Huierc/gallery-by-react | 08781ca6120a235b76b4ba0c18752b6e1b40bff3 | [
"MIT"
] | null | null | null | import React from 'react';
const message = [
{
id:1,
msg:'msg01',
msgdet:'首先它不用去判断渲染哪个'
},
{
id:2,
msg:'msg02',
msgdet:'首先它不用去判断渲染哪个2'
},
{
id:3,
msg:'msg03',
msgdet:'首先它不用去判断渲染哪个3'
}
]
export default function MessageDetail(props){
const {id} = props.match.params;
const con = message.find((m) => m.id===id*1)
return(
<div>
<li>
id:{con.id}
{con.msg}
{con.msgdet}
</li>
</div>
)
} | 12.764706 | 45 | 0.569124 | true | false | false | true |
d002e143bbc6e4d94da06d67264a482cccababa0 | 1,257 | jsx | JSX | src/components/CrearPost.jsx | Hernanarica/frontend | 0db4947ebc22ea64f664d4e208b20d7c790b43d5 | [
"MIT"
] | null | null | null | src/components/CrearPost.jsx | Hernanarica/frontend | 0db4947ebc22ea64f664d4e208b20d7c790b43d5 | [
"MIT"
] | null | null | null | src/components/CrearPost.jsx | Hernanarica/frontend | 0db4947ebc22ea64f664d4e208b20d7c790b43d5 | [
"MIT"
] | null | null | null | import { useState } from "react";
function CreatePost(props) {
const [ title, setTitle ] = useState("");
const [ text, setText ] = useState("");
function onCreatePostSubmit(e) {
e.preventDefault();
fetch('http://localhost:9001/user/api-post', {
method: "POST", headers: {
'Content-Type': 'application/json'
}, body: JSON.stringify({
title, text
})
})
.then(function (res) {
return res.json();
})
.then(function (data) {
console.log(data);
})
.catch(function (err) {
console.log(err);
});
}
return (
<section className="registro container">
<h2 className="registro__h2">
Crea un Post
</h2>
<form onSubmit={ (e) => onCreatePostSubmit(e) } action="" className="sectionLogin__form">
<div className="sectionLogin__labels">
<label htmlFor="">Titulo</label>
<input type="text" value={ title } onChange={ (e) => setTitle(e.target.value) }/>
</div>
<div className="sectionLogin__labels">
<label htmlFor="">Texto</label>
<textarea value={ text } onChange={ (e) => setText(e.target.value) }></textarea>
</div>
<button className="sectionLogin__btn">Crear</button>
</form>
</section>);
}
export default CreatePost; | 26.1875 | 93 | 0.607001 | true | false | false | true |
d002e8a71be02092f3e35f9e86dbb09f07f5695f | 2,072 | jsx | JSX | server/web/layouts/default.jsx | bitdivine/aqua | 3a00d782d4c053583ef0a4e1a481ee6d49f2eac3 | [
"MIT"
] | null | null | null | server/web/layouts/default.jsx | bitdivine/aqua | 3a00d782d4c053583ef0a4e1a481ee6d49f2eac3 | [
"MIT"
] | null | null | null | server/web/layouts/default.jsx | bitdivine/aqua | 3a00d782d4c053583ef0a4e1a481ee6d49f2eac3 | [
"MIT"
] | null | null | null | 'use strict';
const Navbar = require('./navbar.jsx');
const React = require('react');
const propTypes = {
activeTab: React.PropTypes.string,
children: React.PropTypes.node,
feet: React.PropTypes.node,
neck: React.PropTypes.node,
title: React.PropTypes.string
};
class DefaultLayout extends React.Component {
render() {
const year = new Date().getFullYear();
return (
<html>
<head>
<title>{this.props.title}</title>
<meta charSet="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="/public/core.min.css" />
<link rel="stylesheet" href="/public/layouts/default.min.css" />
<link rel="shortcut icon" href="/public/media/favicon.ico" />
{this.props.neck}
</head>
<body>
<Navbar activeTab={this.props.activeTab} />
<div className="page">
<div className="container">
{this.props.children}
</div>
</div>
<div className="footer">
<div className="container">
<span className="copyright pull-right">
© {year} Acme, Inc.
</span>
<ul className="links">
<li><a href="/">Home</a></li>
<li><a href="/contact">Contact</a></li>
</ul>
<div className="clearfix"></div>
</div>
</div>
<script src="/public/core.min.js"></script>
{this.props.feet}
</body>
</html>
);
}
}
DefaultLayout.propTypes = propTypes;
module.exports = DefaultLayout;
| 33.967213 | 92 | 0.433398 | false | true | true | false |
d002fb86b53f6f3cc8b38a29376381ee9e26a33e | 864 | jsx | JSX | ui/oce/corruption-risk/contracts/single/donuts/percent-pe-spending/popup.jsx | devgateway/oc-explorer | a7da0113ce07b701dc6d67cf5cc5655b046b1ae5 | [
"MIT"
] | 6 | 2016-05-18T20:10:35.000Z | 2017-09-22T21:41:56.000Z | ui/oce/corruption-risk/contracts/single/donuts/percent-pe-spending/popup.jsx | devgateway/ocua | ee4da36c2b26f0d03a826e118bfd0ca1bb3f6560 | [
"MIT"
] | 8 | 2017-01-12T19:21:12.000Z | 2021-06-04T22:02:18.000Z | ui/oce/corruption-risk/contracts/single/donuts/percent-pe-spending/popup.jsx | devgateway/ocua | ee4da36c2b26f0d03a826e118bfd0ca1bb3f6560 | [
"MIT"
] | 1 | 2018-12-18T03:21:16.000Z | 2018-12-18T03:21:16.000Z | // eslint-disable-next-line no-unused-vars
const POPUP_WIDTH = 300;
const POPUP_HEIGHT = 90;
class PercentPEPopup extends React.Component {
render() {
const { x, y, points, data } = this.props;
const total = data.get('total');
const { v, label } = points[0];
const left = x - (POPUP_WIDTH / 2) + 30;
const top = y - POPUP_HEIGHT - 12;
const value = v / total * 100;
const formattedValue = Math.round(value) === value ?
value :
value.toFixed(2);
return (
<div
className="crd-popup donut-popup text-center"
style={{
width: POPUP_WIDTH,
height: POPUP_HEIGHT,
left,
top,
color: 'white',
}}
>
{label.replace(/\$#\$/g, formattedValue)}
<div className="arrow" />
</div>
);
}
}
export default PercentPEPopup;
| 24 | 56 | 0.556713 | false | true | true | false |
d00306cf2aef443d3db72860362f65a6bc526f81 | 147 | jsx | JSX | t/run/199.template-arg-namespace/a.jsx | monkpit/JSX | a554cd42ea8cd414b1b4e01eb30381a4b1dcdc28 | [
"MIT"
] | 1,104 | 2015-01-01T03:03:50.000Z | 2022-03-31T05:20:14.000Z | t/run/199.template-arg-namespace/a.jsx | monkpit/JSX | a554cd42ea8cd414b1b4e01eb30381a4b1dcdc28 | [
"MIT"
] | 24 | 2015-02-06T15:39:37.000Z | 2021-02-07T11:27:02.000Z | t/run/199.template-arg-namespace/a.jsx | monkpit/JSX | a554cd42ea8cd414b1b4e01eb30381a4b1dcdc28 | [
"MIT"
] | 95 | 2015-01-30T19:41:51.000Z | 2021-10-23T00:37:15.000Z | import "common.jsx";
class Klass {
static function doit() : void {
Template.<Klass>.doit();
}
static function say() : void {
log "a";
}
}
| 13.363636 | 32 | 0.605442 | true | false | false | true |
d00308e41106fcbb9e82b0ed04593425f5dec2c1 | 1,276 | jsx | JSX | test/main/smoketest.spec.jsx | UmerMIB/WikiEduDashboard | cba3a3c4f47f38ce3671cfc0f1ae04713a97bc59 | [
"MIT"
] | 359 | 2015-01-30T03:39:20.000Z | 2022-03-27T10:27:22.000Z | test/main/smoketest.spec.jsx | UmerMIB/WikiEduDashboard | cba3a3c4f47f38ce3671cfc0f1ae04713a97bc59 | [
"MIT"
] | 3,140 | 2015-01-13T06:25:43.000Z | 2022-03-31T22:02:11.000Z | test/main/smoketest.spec.jsx | UmerMIB/WikiEduDashboard | cba3a3c4f47f38ce3671cfc0f1ae04713a97bc59 | [
"MIT"
] | 596 | 2015-01-24T06:18:15.000Z | 2022-03-31T21:28:32.000Z | import React from 'react';
import { mount } from 'enzyme';
import { MemoryRouter, Route } from 'react-router-dom';
import '../testHelper';
import { Course } from '../../app/assets/javascripts/components/course/course.jsx';
describe('top-level course component', () => {
it('loads without an error', () => {
global.Features = { enableGetHelpButton: true };
const course = {
title: 'this_course',
description: '',
school: 'this_school'
};
const user = {
role: 0,
username: 'Ragesoss',
admin: true
};
const props = {
course, current_user: user
};
const fns = {
fetchCourse: sinon.stub(),
fetchUsers: sinon.stub(),
fetchTimeline: sinon.stub(),
fetchCampaigns: sinon.stub(),
persistCourse: sinon.stub(),
updateCourse: sinon.stub()
};
const testCourse = mount(
<MemoryRouter initialEntries={['/courses/this_school/this_course']}>
<Route
exact
path="/courses/:course_school/:course_title"
render={location => (
<Course
{...location}
{...props}
{...fns}
/>
)}
/>
</MemoryRouter>
);
expect(testCourse).toExist;
});
});
| 25.52 | 83 | 0.549373 | false | true | false | true |
d00309f8cf00dd19dc7f8b94b96018c755ca72d5 | 1,232 | jsx | JSX | docs/components/ColorsCollection.jsx | magnetis/astro | 2aa1aeb9dd1ef0ecf0db1c5fa3d122c8f56169d8 | [
"Apache-2.0"
] | 100 | 2019-01-22T17:08:54.000Z | 2022-03-10T14:25:27.000Z | docs/components/ColorsCollection.jsx | magnetis/astro | 2aa1aeb9dd1ef0ecf0db1c5fa3d122c8f56169d8 | [
"Apache-2.0"
] | 171 | 2019-01-29T12:37:40.000Z | 2022-02-26T09:55:32.000Z | docs/components/ColorsCollection.jsx | magnetis/astro | 2aa1aeb9dd1ef0ecf0db1c5fa3d122c8f56169d8 | [
"Apache-2.0"
] | 12 | 2019-04-11T15:34:47.000Z | 2022-03-10T14:25:26.000Z | import React from 'react';
import '../css/colors-collection.css';
const tints = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000];
const getTextColor = (tint, lightTextStart) =>
tint < lightTextStart ? 'var(--color-moon-1000)' : 'var(--color-space-100)';
const ColorSwatch = ({ family, tint, textColor }) => (
<div
className='color-palette__swatch'
style={{
backgroundColor: `var(--color-${family}-${tint})`,
color: textColor
}}
>
<span>{tint}</span>
</div>
);
export const ColorPalette = ({ family, lightTextStart }) => (
<div className='color-palette'>
{tints.map(tint => (
<ColorSwatch
key={`${family}${tint}`}
family={family}
tint={tint}
textColor={getTextColor(tint, lightTextStart)}
/>
))}
</div>
);
export const GradientSwatch = ({ gradient, darkText = false }) => (
<div
className='gradient-collection__swatch'
style={{
backgroundImage: `var(--gradient-${gradient})`,
color: darkText ? 'var(--color-moon-900)' : 'var(--color-space-100)'
}}
>
<span>{gradient}</span>
</div>
);
export const GradientCollection = ({ children }) => (
<div className='gradient-collection'>{children}</div>
);
| 24.64 | 78 | 0.598214 | false | true | false | true |
d0030aaae9ca24ffcf00aea39573b918131247e7 | 835 | jsx | JSX | src/components/Home.jsx | 3DPrintable/3DPrintable-Landing-Page | 3e0be4798d098766ae853e05186116a9ee26b43c | [
"MIT"
] | null | null | null | src/components/Home.jsx | 3DPrintable/3DPrintable-Landing-Page | 3e0be4798d098766ae853e05186116a9ee26b43c | [
"MIT"
] | null | null | null | src/components/Home.jsx | 3DPrintable/3DPrintable-Landing-Page | 3e0be4798d098766ae853e05186116a9ee26b43c | [
"MIT"
] | null | null | null | import React from "react";
// Imported Images (Need to change these images to desired ones)
import background from './images/bg/bg_3.png'; // Background image
const Home = () => {
return (
<body>
{/* Start Hero */}
<section class="bg-half-260 w-100 " style={{backgroundImage: "url(" + background + ")"}}>
<div class="bg-overlay bg-gradient-primary opacity-6"></div>
<div class="container">
<div class="row align-items-center mt-5">
<div class="col-lg-5 col-md-6">
<div class="title-heading">
<h4 class="display-4 fw-bold text-white title-dark mb-4">3DPrintable:</h4>
<p class="text-white-50 para-desc">A Web3 Gateway for 3D Printing</p>
</div>
</div>
</div>
</div>
</section>
{/* End Hero */}
</body>
);
}
export default Home; | 26.935484 | 93 | 0.588024 | true | false | false | true |
d0031cb30ecdd40725e31c8df006038fafc0ea12 | 6,561 | jsx | JSX | awx/ui_next/src/screens/Organization/OrganizationList/OrganizationList.jsx | austlane/awx | 5d5838fbab0f32539e03182927e09924db543644 | [
"Apache-2.0"
] | null | null | null | awx/ui_next/src/screens/Organization/OrganizationList/OrganizationList.jsx | austlane/awx | 5d5838fbab0f32539e03182927e09924db543644 | [
"Apache-2.0"
] | null | null | null | awx/ui_next/src/screens/Organization/OrganizationList/OrganizationList.jsx | austlane/awx | 5d5838fbab0f32539e03182927e09924db543644 | [
"Apache-2.0"
] | 3 | 2019-10-12T07:28:48.000Z | 2020-03-13T07:23:51.000Z | import React, { Component, Fragment } from 'react';
import { withRouter } from 'react-router-dom';
import { withI18n } from '@lingui/react';
import { t } from '@lingui/macro';
import { Card, PageSection } from '@patternfly/react-core';
import { OrganizationsAPI } from '@api';
import AlertModal from '@components/AlertModal';
import DataListToolbar from '@components/DataListToolbar';
import ErrorDetail from '@components/ErrorDetail';
import PaginatedDataList, {
ToolbarAddButton,
ToolbarDeleteButton,
} from '@components/PaginatedDataList';
import { getQSConfig, parseQueryString } from '@util/qs';
import OrganizationListItem from './OrganizationListItem';
const QS_CONFIG = getQSConfig('organization', {
page: 1,
page_size: 20,
order_by: 'name',
});
class OrganizationsList extends Component {
constructor(props) {
super(props);
this.state = {
hasContentLoading: true,
contentError: null,
deletionError: null,
organizations: [],
selected: [],
itemCount: 0,
actions: null,
};
this.handleSelectAll = this.handleSelectAll.bind(this);
this.handleSelect = this.handleSelect.bind(this);
this.handleOrgDelete = this.handleOrgDelete.bind(this);
this.handleDeleteErrorClose = this.handleDeleteErrorClose.bind(this);
this.loadOrganizations = this.loadOrganizations.bind(this);
}
componentDidMount() {
this.loadOrganizations();
}
componentDidUpdate(prevProps) {
const { location } = this.props;
if (location !== prevProps.location) {
this.loadOrganizations();
}
}
handleSelectAll(isSelected) {
const { organizations } = this.state;
const selected = isSelected ? [...organizations] : [];
this.setState({ selected });
}
handleSelect(row) {
const { selected } = this.state;
if (selected.some(s => s.id === row.id)) {
this.setState({ selected: selected.filter(s => s.id !== row.id) });
} else {
this.setState({ selected: selected.concat(row) });
}
}
handleDeleteErrorClose() {
this.setState({ deletionError: null });
}
async handleOrgDelete() {
const { selected } = this.state;
this.setState({ hasContentLoading: true });
try {
await Promise.all(selected.map(org => OrganizationsAPI.destroy(org.id)));
} catch (err) {
this.setState({ deletionError: err });
} finally {
await this.loadOrganizations();
}
}
async loadOrganizations() {
const { location } = this.props;
const { actions: cachedActions } = this.state;
const params = parseQueryString(QS_CONFIG, location.search);
let optionsPromise;
if (cachedActions) {
optionsPromise = Promise.resolve({ data: { actions: cachedActions } });
} else {
optionsPromise = OrganizationsAPI.readOptions();
}
const promises = Promise.all([
OrganizationsAPI.read(params),
optionsPromise,
]);
this.setState({ contentError: null, hasContentLoading: true });
try {
const [
{
data: { count, results },
},
{
data: { actions },
},
] = await promises;
this.setState({
actions,
itemCount: count,
organizations: results,
selected: [],
});
} catch (err) {
this.setState({ contentError: err });
} finally {
this.setState({ hasContentLoading: false });
}
}
render() {
const {
actions,
itemCount,
contentError,
hasContentLoading,
deletionError,
selected,
organizations,
} = this.state;
const { match, i18n } = this.props;
const canAdd =
actions && Object.prototype.hasOwnProperty.call(actions, 'POST');
const isAllSelected = selected.length === organizations.length;
return (
<Fragment>
<PageSection>
<Card>
<PaginatedDataList
contentError={contentError}
hasContentLoading={hasContentLoading}
items={organizations}
itemCount={itemCount}
pluralizedItemName="Organizations"
qsConfig={QS_CONFIG}
toolbarColumns={[
{
name: i18n._(t`Name`),
key: 'name',
isSortable: true,
isSearchable: true,
},
{
name: i18n._(t`Modified`),
key: 'modified',
isSortable: true,
isNumeric: true,
},
{
name: i18n._(t`Created`),
key: 'created',
isSortable: true,
isNumeric: true,
},
]}
renderToolbar={props => (
<DataListToolbar
{...props}
showSelectAll
isAllSelected={isAllSelected}
onSelectAll={this.handleSelectAll}
qsConfig={QS_CONFIG}
additionalControls={[
<ToolbarDeleteButton
key="delete"
onDelete={this.handleOrgDelete}
itemsToDelete={selected}
pluralizedItemName="Organizations"
/>,
canAdd ? (
<ToolbarAddButton key="add" linkTo={`${match.url}/add`} />
) : null,
]}
/>
)}
renderItem={o => (
<OrganizationListItem
key={o.id}
organization={o}
detailUrl={`${match.url}/${o.id}`}
isSelected={selected.some(row => row.id === o.id)}
onSelect={() => this.handleSelect(o)}
/>
)}
emptyStateControls={
canAdd ? (
<ToolbarAddButton key="add" linkTo={`${match.url}/add`} />
) : null
}
/>
</Card>
</PageSection>
<AlertModal
isOpen={deletionError}
variant="danger"
title={i18n._(t`Error!`)}
onClose={this.handleDeleteErrorClose}
>
{i18n._(t`Failed to delete one or more organizations.`)}
<ErrorDetail error={deletionError} />
</AlertModal>
</Fragment>
);
}
}
export { OrganizationsList as _OrganizationsList };
export default withI18n()(withRouter(OrganizationsList));
| 28.402597 | 80 | 0.542295 | false | true | true | false |
d003398a1f4361b8c462c60e07c4195fb3535695 | 278 | jsx | JSX | src/main/js/EditorRoutes.jsx | reshma01/pipeline-editor | c0b9e82c7c2e10b70a60d9ad05c7a7bff474b0f6 | [
"MIT"
] | null | null | null | src/main/js/EditorRoutes.jsx | reshma01/pipeline-editor | c0b9e82c7c2e10b70a60d9ad05c7a7bff474b0f6 | [
"MIT"
] | null | null | null | src/main/js/EditorRoutes.jsx | reshma01/pipeline-editor | c0b9e82c7c2e10b70a60d9ad05c7a7bff474b0f6 | [
"MIT"
] | null | null | null | // @flow
import React from 'react';
import { Route } from 'react-router';
import { EditorPage } from './EditorPage';
export default
<Route>
<Route path="/organizations/:organization/pipeline-editor/(:pipeline/)(:branch/)" component={EditorPage} />
</Route>
;
| 23.166667 | 115 | 0.661871 | false | true | false | true |
d0033fa5b9fe269648409e7564a341aba75702a0 | 605 | jsx | JSX | src/components/Header/header.jsx | JoshMDiaz/diazre | 056c8a44b57934ca9c548f98795ccded004674e4 | [
"MIT"
] | null | null | null | src/components/Header/header.jsx | JoshMDiaz/diazre | 056c8a44b57934ca9c548f98795ccded004674e4 | [
"MIT"
] | null | null | null | src/components/Header/header.jsx | JoshMDiaz/diazre | 056c8a44b57934ca9c548f98795ccded004674e4 | [
"MIT"
] | null | null | null | import React from 'react'
import NavButton from '../Nav/NavButton'
import navContent from '../Nav/nav-content'
import Slide from 'react-reveal/Slide'
import Scroll from 'react-scroll'
const ScrollLink = Scroll.Link
const Header = () => (
<header className="padding">
<Slide down>
<NavButton />
<div className="desktop-nav">
{ navContent.map((e, i) => (
<ScrollLink key={i} to={e.section} spy={true} smooth={true} duration={450}>
<span>{e.name}</span>
</ScrollLink>
))}
</div>
</Slide>
</header>
)
export default Header
| 25.208333 | 85 | 0.6 | false | true | false | true |
d00347d99898771b893711b8f5195a24bfa2c185 | 3,324 | jsx | JSX | superset/assets/javascripts/components/CopyToClipboard.jsx | wxdublin/wxsplunk | 0b996d164b272bfc5d0f356635a14c8a4e8842bc | [
"Apache-2.0"
] | 1 | 2019-05-09T08:59:54.000Z | 2019-05-09T08:59:54.000Z | superset/assets/javascripts/components/CopyToClipboard.jsx | wxdublin/wxsplunk | 0b996d164b272bfc5d0f356635a14c8a4e8842bc | [
"Apache-2.0"
] | null | null | null | superset/assets/javascripts/components/CopyToClipboard.jsx | wxdublin/wxsplunk | 0b996d164b272bfc5d0f356635a14c8a4e8842bc | [
"Apache-2.0"
] | null | null | null | import React from 'react';
import PropTypes from 'prop-types';
import { Tooltip, OverlayTrigger, MenuItem } from 'react-bootstrap';
import { t } from '../locales';
const propTypes = {
copyNode: PropTypes.node,
getText: PropTypes.func,
onCopyEnd: PropTypes.func,
shouldShowText: PropTypes.bool,
text: PropTypes.string,
inMenu: PropTypes.bool,
tooltipText: PropTypes.string,
};
const defaultProps = {
copyNode: <span>Copy</span>,
onCopyEnd: () => {},
shouldShowText: true,
inMenu: false,
tooltipText: t('Copy to clipboard'),
};
export default class CopyToClipboard extends React.Component {
constructor(props) {
super(props);
this.state = {
hasCopied: false,
};
// bindings
this.copyToClipboard = this.copyToClipboard.bind(this);
this.resetTooltipText = this.resetTooltipText.bind(this);
this.onMouseOut = this.onMouseOut.bind(this);
}
onMouseOut() {
// delay to avoid flash of text change on tooltip
setTimeout(this.resetTooltipText, 200);
}
onClick() {
if (this.props.getText) {
this.props.getText((d) => { this.copyToClipboard(d); });
} else {
this.copyToClipboard(this.props.text);
}
}
resetTooltipText() {
this.setState({ hasCopied: false });
}
copyToClipboard(textToCopy) {
const textArea = document.createElement('textarea');
textArea.style.position = 'fixed';
textArea.style.left = '-1000px';
textArea.value = textToCopy;
document.body.appendChild(textArea);
textArea.select();
try {
if (!document.execCommand('copy')) {
throw new Error(t('Not successful'));
}
} catch (err) {
window.alert(t('Sorry, your browser does not support copying. Use Ctrl / Cmd + C!')); // eslint-disable-line
}
document.body.removeChild(textArea);
this.setState({ hasCopied: true });
this.props.onCopyEnd();
}
tooltipText() {
if (this.state.hasCopied) {
return t('Copied!');
}
return this.props.tooltipText;
}
renderLink() {
return (
<span>
{this.props.shouldShowText &&
<span>
{this.props.text}
</span>
}
<OverlayTrigger
placement="top"
style={{ cursor: 'pointer' }}
overlay={this.renderTooltip()}
trigger={['hover']}
bsStyle="link"
onClick={this.onClick.bind(this)}
onMouseOut={this.onMouseOut}
>
{this.props.copyNode}
</OverlayTrigger>
</span>
);
}
renderInMenu() {
return (
<OverlayTrigger placement="top" overlay={this.renderTooltip()} trigger={['hover']}>
<MenuItem>
<span
onClick={this.onClick.bind(this)}
onMouseOut={this.onMouseOut}
>
{this.props.copyNode}
</span>
</MenuItem>
</OverlayTrigger>
);
}
renderTooltip() {
return (
<Tooltip id="copy-to-clipboard-tooltip">
{this.tooltipText()}
</Tooltip>
);
}
render() {
let html;
if (this.props.inMenu) {
html = this.renderInMenu();
} else {
html = this.renderLink();
}
return html;
}
}
CopyToClipboard.propTypes = propTypes;
CopyToClipboard.defaultProps = defaultProps;
| 23.083333 | 114 | 0.597473 | false | true | true | false |
d0035ccf7b44e742efc5a54086fd3a859ae5733b | 1,024 | jsx | JSX | src/components/manage/Widgets/CheckboxWidget.stories.jsx | MarcoCouto/volto | e3076634d8776c0fa2350f1b1db16950a47e6257 | [
"MIT"
] | null | null | null | src/components/manage/Widgets/CheckboxWidget.stories.jsx | MarcoCouto/volto | e3076634d8776c0fa2350f1b1db16950a47e6257 | [
"MIT"
] | null | null | null | src/components/manage/Widgets/CheckboxWidget.stories.jsx | MarcoCouto/volto | e3076634d8776c0fa2350f1b1db16950a47e6257 | [
"MIT"
] | null | null | null | import React from 'react';
import CheckboxWidget from './CheckboxWidget';
import Wrapper from '@plone/volto/storybook';
const CheckboxWidgetComponent = ({ children, ...args }) => {
const [value, setValue] = React.useState(false);
const onChange = (block, value) => setValue(value);
return (
<Wrapper location={{ pathname: '/folder2/folder21/doc212' }}>
<div className="ui segment form attached" style={{ width: '400px' }}>
<CheckboxWidget
{...args}
id="field"
title="Checkbox"
block="testBlock"
value={value}
onChange={onChange}
/>
</div>
<pre>Value: {JSON.stringify(value, null, 4)}</pre>
</Wrapper>
);
};
export const Checkbox = CheckboxWidgetComponent.bind({});
export default {
title: 'Widgets/Checkbox',
component: CheckboxWidget,
decorators: [
(Story) => (
<div className="ui segment form attached" style={{ width: '400px' }}>
<Story />
</div>
),
],
argTypes: {},
};
| 26.25641 | 75 | 0.592773 | false | true | false | true |
d00363175d366ce1f4a774c1179fc0fd423120db | 1,292 | jsx | JSX | src/components/landing/Goodreads/index.jsx | LizFedak/portfolio-site | b6e086a87894fc9f09dc71e11a89a45c8345ac68 | [
"MIT"
] | null | null | null | src/components/landing/Goodreads/index.jsx | LizFedak/portfolio-site | b6e086a87894fc9f09dc71e11a89a45c8345ac68 | [
"MIT"
] | null | null | null | src/components/landing/Goodreads/index.jsx | LizFedak/portfolio-site | b6e086a87894fc9f09dc71e11a89a45c8345ac68 | [
"MIT"
] | null | null | null | import React from 'react'
import { useStaticQuery, graphql } from 'gatsby'
import { Container, Card } from 'Common'
import { Header } from 'Theme'
import { Wrapper, Grid, Item, Content } from './styles'
export const Goodreads = () => {
const {allGoodreadsShelf} = useStaticQuery(graphql`
query shelfList {
allGoodreadsShelf {
edges {
node {
id
shelfName
reviews {
reviewID
rating
votes
spoilerFlag
spoilersState
dateAdded
dateUpdated
book {
bookID
title
titleWithoutSeries
imageUrl
}
}
}
}
}
}
`)
return (
<div>
<Header />
<Wrapper as={Container} id="goodreads">
<h2>Check out what I've been reading lately 📚</h2>
<Grid>
{allGoodreadsShelf.edges[0].node.reviews.map((review) => (
<Item
key={review.reviewID}>
<Card>
<Content>
<h4>{review.book.title} - {review.rating} stars</h4>
<div>
<img src={review.book.imageUrl}/>
</div>
</Content>
</Card>
</Item>
))}
</Grid>
<br></br>
<p>Built with the <a href="https://www.goodreads.com/api">Goodreads API</a> 📖</p>
</Wrapper>
</div>
)
}
| 19.283582 | 85 | 0.528638 | true | false | false | true |
d0036ac5de2a50f596c57f04bbf212c8747ef0fd | 1,594 | jsx | JSX | frontend/src/components/counter/Counter.jsx | larsreed/training-react | 919b2b5d6afcb5fa234446b5ed4dcdc09e1a0b13 | [
"MIT"
] | null | null | null | frontend/src/components/counter/Counter.jsx | larsreed/training-react | 919b2b5d6afcb5fa234446b5ed4dcdc09e1a0b13 | [
"MIT"
] | null | null | null | frontend/src/components/counter/Counter.jsx | larsreed/training-react | 919b2b5d6afcb5fa234446b5ed4dcdc09e1a0b13 | [
"MIT"
] | null | null | null | import React, { Component } from "react";
import PropTypes from "prop-types";
import "./Counter.css";
export class Counter extends Component {
constructor() {
super();
this.state = {
counter: 0,
};
this.increment = this.increment.bind(this);
this.reset = this.reset.bind(this);
}
increment(by) {
this.setState((prevState) => {
return { counter: prevState.counter + by };
});
}
reset() {
this.setState({ counter: 0 });
}
// render= () => {
render() {
// const style= { fontSize: "50px" }
return (
<div className="counter">
<CounterButton incrementMethod={this.increment} />
<CounterButton incBy={5} incrementMethod={this.increment} />
<CounterButton incBy={10} incrementMethod={this.increment} />
<span
className="count"
// style={{fontSize: "50px"}}
// style = {style}
>
{this.state.counter}
</span>
<div>
<button className="reset" onClick={this.reset}>
Reset
</button>
</div>
</div>
);
}
}
class CounterButton extends Component {
render() {
return (
<div className="counterButton">
<button onClick={() => this.props.incrementMethod(this.props.incBy)}>+{this.props.incBy}</button>
<button onClick={() => this.props.incrementMethod(-this.props.incBy)}>-{this.props.incBy}</button>
</div>
);
}
}
CounterButton.defaultProps = {
incBy: 1,
};
CounterButton.propTypes = {
incBy: PropTypes.number,
};
export default Counter;
| 22.771429 | 106 | 0.572773 | false | true | true | false |
d003749e57928a085e4ef16ee5affd19d614e214 | 4,775 | jsx | JSX | webapp/javascript/components/DateRangePicker.jsx | geoah/pyroscope | 79d563ecd2b7fd62beff1ffa6117ce22a4c215bb | [
"Apache-2.0"
] | null | null | null | webapp/javascript/components/DateRangePicker.jsx | geoah/pyroscope | 79d563ecd2b7fd62beff1ffa6117ce22a4c215bb | [
"Apache-2.0"
] | null | null | null | webapp/javascript/components/DateRangePicker.jsx | geoah/pyroscope | 79d563ecd2b7fd62beff1ffa6117ce22a4c215bb | [
"Apache-2.0"
] | null | null | null | import React, { useState } from "react";
import { useDispatch, useSelector } from "react-redux";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faClock } from "@fortawesome/free-solid-svg-icons";
import DatePicker from "react-datepicker";
import OutsideClickHandler from "react-outside-click-handler";
import { setDateRange } from "../redux/actions";
import humanReadableRange from "../util/formatDate";
const defaultPresets = [
[
{ label: "Last 5 minutes", from: "now-5m", until: "now" },
{ label: "Last 15 minutes", from: "now-15m", until: "now" },
{ label: "Last 30 minutes", from: "now-30m", until: "now" },
{ label: "Last 1 hour", from: "now-1h", until: "now" },
{ label: "Last 3 hours", from: "now-3h", until: "now" },
{ label: "Last 6 hours", from: "now-6h", until: "now" },
{ label: "Last 12 hours", from: "now-12h", until: "now" },
{ label: "Last 24 hours", from: "now-24h", until: "now" },
],
[
{ label: "Last 2 days", from: "now-2d", until: "now" },
{ label: "Last 7 days", from: "now-7d", until: "now" },
{ label: "Last 30 days", from: "now-30d", until: "now" },
{ label: "Last 90 days", from: "now-90d", until: "now" },
{ label: "Last 6 months", from: "now-6M", until: "now" },
{ label: "Last 1 year", from: "now-1y", until: "now" },
{ label: "Last 2 years", from: "now-2y", until: "now" },
{ label: "Last 5 years", from: "now-5y", until: "now" },
],
];
function DateRangePicker() {
const dispatch = useDispatch();
const from = useSelector((state) => state.from);
const until = useSelector((state) => state.until);
const [opened, setOpened] = useState(false);
const readableDateForm = humanReadableRange(until, from);
const updateFrom = (from) => {
dispatch(setDateRange(from, until));
};
const updateUntil = (until) => {
dispatch(setDateRange(from, until));
};
const updateDateRange = () => {
dispatch(setDateRange(from, until));
};
const toggleDropdown = () => {
setOpened(!opened);
};
const hideDropdown = () => {
setOpened(false);
};
const selectPreset = ({ from, until }) => {
dispatch(setDateRange(from, until));
setOpened(false);
};
return (
<div className={opened ? "drp-container opened" : "drp-container"}>
<OutsideClickHandler onOutsideClick={hideDropdown}>
<button
type="button"
className="btn drp-button"
onClick={toggleDropdown}
>
<FontAwesomeIcon icon={faClock} />
<span>{readableDateForm.range}</span>
</button>
<div className="drp-dropdown">
<h4>Quick Presets</h4>
<div className="drp-presets">
{defaultPresets.map((arr, i) => (
<div key={`preset-${i + 1}`} className="drp-preset-column">
{arr.map((x) => (
<button
type="button"
className={`drp-preset ${
x.label === readableDateForm.range ? "active" : ""
}`}
key={x.label}
onClick={() => selectPreset(x)}
>
{x.label}
</button>
))}
</div>
))}
</div>
<h4>Custom Date Range</h4>
<div className="drp-label">From</div>
<div className="drp-calendar-input-group">
<DatePicker
className="followed-by-btn"
showTimeSelect
dateFormat="MMM d, yyyy h:mm aa"
onChange={(date) => updateFrom(date / 1000)}
onBlur={() => updateDateRange()}
selected={readableDateForm.from}
/>
<button
type="button"
className="drp-calendar-btn btn"
onClick={updateDateRange}
>
<FontAwesomeIcon icon={faClock} />
Update
</button>
</div>
<div className="drp-label">To</div>
<div className="drp-calendar-input-group">
<DatePicker
className="followed-by-btn"
showTimeSelect
dateFormat="MMM d, yyyy h:mm aa"
onChange={(date) => updateUntil(date / 1000)}
onBlur={() => updateDateRange()}
selected={readableDateForm.until}
/>
<button
type="button"
className="drp-calendar-btn btn"
onClick={updateDateRange}
>
<FontAwesomeIcon icon={faClock} />
Update
</button>
</div>
</div>
</OutsideClickHandler>
</div>
);
}
export default DateRangePicker;
| 33.626761 | 73 | 0.525864 | false | true | false | true |
d003892dace9e4e8a0ed4c37af9cc7bd106acd6e | 1,662 | jsx | JSX | packages/dx-react-scheduler-material-ui/src/templates/appointment-form/common/boolean-editor.test.jsx | Krijovnick/devextreme-reactive | a8686e49b76db88a086ab9378e08276bac30b8ba | [
"Apache-2.0"
] | 1,955 | 2017-05-16T12:16:27.000Z | 2022-03-27T17:29:41.000Z | packages/dx-react-scheduler-material-ui/src/templates/appointment-form/common/boolean-editor.test.jsx | Krijovnick/devextreme-reactive | a8686e49b76db88a086ab9378e08276bac30b8ba | [
"Apache-2.0"
] | 1,812 | 2017-05-17T07:33:28.000Z | 2022-03-24T00:11:06.000Z | packages/dx-react-scheduler-material-ui/src/templates/appointment-form/common/boolean-editor.test.jsx | Krijovnick/devextreme-reactive | a8686e49b76db88a086ab9378e08276bac30b8ba | [
"Apache-2.0"
] | 395 | 2017-05-16T11:01:00.000Z | 2022-03-15T05:47:50.000Z | import * as React from 'react';
import { createMount, createShallow } from '@devexpress/dx-testing';
import Checkbox from '@mui/material/Checkbox';
import { BooleanEditor } from './boolean-editor';
describe('AppointmentForm common', () => {
let mount;
let shallow;
const defaultProps = {
label: 'label',
onValueChange: jest.fn(),
};
beforeAll(() => {
shallow = createShallow({ dive: true });
});
beforeEach(() => {
mount = createMount();
});
afterEach(() => {
mount.cleanUp();
});
describe('BooleanEditor', () => {
it('should pass rest props to the root element', () => {
const tree = shallow((
<BooleanEditor {...defaultProps} className="custom-class" />
));
expect(tree.is('.custom-class'))
.toBeTruthy();
});
it('should render checkbox as boolean editor', () => {
const tree = mount((
<BooleanEditor {...defaultProps} className="custom-class" />
));
expect(tree.find(Checkbox).exists())
.toBeTruthy();
});
it('should handle checkbox change', () => {
const valueChangeMock = jest.fn();
const { onChange } = mount((
<BooleanEditor
label="label"
onValueChange={valueChangeMock}
/>
)).find(Checkbox).props();
onChange({ target: { checked: true } });
expect(valueChangeMock).toBeCalledWith(true);
});
it('should be disabled depending on readonly', () => {
const tree = shallow((
<BooleanEditor
{...defaultProps}
readOnly
/>
));
expect(tree.prop('disabled'))
.toBeTruthy();
});
});
});
| 25.181818 | 68 | 0.561372 | false | true | false | true |
d0038fb0fece7d2ec64f22775f3c1502ab904fa3 | 231 | jsx | JSX | src/containers/TodoListView.jsx | dollars0427/redux-study | 92cf589246488e0d7f993e4d4712d6dcdd343e59 | [
"MIT"
] | null | null | null | src/containers/TodoListView.jsx | dollars0427/redux-study | 92cf589246488e0d7f993e4d4712d6dcdd343e59 | [
"MIT"
] | null | null | null | src/containers/TodoListView.jsx | dollars0427/redux-study | 92cf589246488e0d7f993e4d4712d6dcdd343e59 | [
"MIT"
] | null | null | null | import { connect } from 'react-redux'
import TodoList from './TodoList'
const mapStateToProps = (state) => {
return { todos: state.todos }
}
const TodoListView = connect(mapStateToProps)(TodoList);
export default TodoListView;
| 23.1 | 56 | 0.74026 | false | true | false | true |
d003958eb95034ac461269555c84bd03689e7abe | 367 | jsx | JSX | src/components/common/ChooseButton/ChooseButton.jsx | sanzhardanybayev/ataEnd | f1f9f0ca1efc825d3fd25149e4ac7fc951f8adb5 | [
"MIT"
] | null | null | null | src/components/common/ChooseButton/ChooseButton.jsx | sanzhardanybayev/ataEnd | f1f9f0ca1efc825d3fd25149e4ac7fc951f8adb5 | [
"MIT"
] | null | null | null | src/components/common/ChooseButton/ChooseButton.jsx | sanzhardanybayev/ataEnd | f1f9f0ca1efc825d3fd25149e4ac7fc951f8adb5 | [
"MIT"
] | null | null | null | import React from 'react';
import styles from './style.scss';
class ChooseButton extends React.Component{
constructor(props){
super(props);
this.state = {
};
}
render(){
return(
<a className={styles.Choose} onClick={this.props.click} > Выбрать </a>
);
}
}
export default ChooseButton;
| 12.233333 | 82 | 0.561308 | false | true | true | false |
d003a518949735079ad86460dcee69e91380bb25 | 1,262 | jsx | JSX | src/pages/HomePage/HomePage.jsx | prometheas/hesiod | 72d92658727264bac5f1eaf8810c0742eecf7689 | [
"MIT"
] | null | null | null | src/pages/HomePage/HomePage.jsx | prometheas/hesiod | 72d92658727264bac5f1eaf8810c0742eecf7689 | [
"MIT"
] | 7 | 2018-05-30T04:50:28.000Z | 2018-09-24T19:03:44.000Z | src/pages/HomePage/HomePage.jsx | prometheas/hesiod | 72d92658727264bac5f1eaf8810c0742eecf7689 | [
"MIT"
] | null | null | null | import React from 'react';
import PropTypes from 'prop-types';
class HomePage extends React.Component {
render() {
const { data } = this.props;
return (
<React.Fragment>
<header>
Some stuff
</header>
<div>
{data.posts && data.posts.length ?
(
<React.Fragment>
{data.posts.map(post => (
<article>
<header>
<h1>
{post.title}
</h1>
</header>
<footer>
<span>Published {post.dates.published}</span>
</footer>
</article>
))}
</React.Fragment>
) : (
<React.Fragment>
<p>No posts, I fear!</p>
<pre>
{JSON.stringify(this.props)}
</pre>
</React.Fragment>
)
}
</div>
<footer>
<pre>
{JSON.stringify(this.props.data)}
</pre>
</footer>
</React.Fragment>
);
}
}
HomePage.propTypes = {
data: PropTypes.object,
};
export default HomePage;
| 22.945455 | 67 | 0.385103 | false | true | true | false |
d003ad8b2c1f351a2a1b696e81160d44d3f8f5fa | 502 | jsx | JSX | src/editor/toolBar/blockSelectorControls.jsx | JumpLao/react-lz-editor | 02deab4b270ff33b376e20953e41d2a59b88209a | [
"MIT"
] | 1,029 | 2017-01-03T05:23:13.000Z | 2022-03-25T11:09:58.000Z | src/editor/toolBar/blockSelectorControls.jsx | WHKFZYX-Tool/react-lz-editor-whkfzyx | 72e72ed433d9346ba414d9b2bec1b97f8eb1d439 | [
"MIT"
] | 180 | 2017-02-20T02:35:27.000Z | 2022-02-10T15:43:50.000Z | src/editor/toolBar/blockSelectorControls.jsx | WHKFZYX-Tool/react-lz-editor-whkfzyx | 72e72ed433d9346ba414d9b2bec1b97f8eb1d439 | [
"MIT"
] | 214 | 2017-01-18T02:57:55.000Z | 2021-12-31T09:27:35.000Z | import React, {Component} from 'react';
import {Popconfirm,Icon} from 'antd';
class RemoveStyleControls extends Component {
constructor(props) {
super(props);
}
render() {
let className = 'RichEditor-styleButton';
return (
<div className="RichEditor-controls">
<span className={className} onClick= {this.props.onToggle}>
<Icon key="empty_style" type="editor_select_block" />
</span>
</div>
)
}
}
module.exports = RemoveStyleControls;
| 26.421053 | 69 | 0.645418 | false | true | true | false |
d003af8b2251ca339f03ff8ee5587590298e1b4b | 3,814 | jsx | JSX | geonode_mapstore_client/client/js/components/Menu/DropdownList.jsx | MuhweziDeo/geonode-mapstore-client | e8093e617035b3809065b0315800bee2aa170de2 | [
"BSD-2-Clause-FreeBSD"
] | null | null | null | geonode_mapstore_client/client/js/components/Menu/DropdownList.jsx | MuhweziDeo/geonode-mapstore-client | e8093e617035b3809065b0315800bee2aa170de2 | [
"BSD-2-Clause-FreeBSD"
] | null | null | null | geonode_mapstore_client/client/js/components/Menu/DropdownList.jsx | MuhweziDeo/geonode-mapstore-client | e8093e617035b3809065b0315800bee2aa170de2 | [
"BSD-2-Clause-FreeBSD"
] | null | null | null | /*
* Copyright 2021, GeoSolutions Sas.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*/
import React from 'react';
import PropTypes from 'prop-types';
import Message from '@mapstore/framework/components/I18N/Message';
import { Dropdown, Badge } from 'react-bootstrap-v1';
import isNil from 'lodash/isNil';
import { createPortal } from 'react-dom';
const isValidBadgeValue = value => !!(value !== '' && !isNil(value));
/**
* DropdownList component
* @name DropdownList
* @memberof components.Menu.DropdownList
* @prop {number} id to apply to toogle
* @prop {array} items list od items of Dropdown
* @prop {string} label label to apply to toogle
* @prop {string} labelId alternative to label
* @prop {string} labelId alternative to labe
* @prop {object} toogleStyle inline style to apply to toogle comp
* @prop {string} toogleImage image to apply to toogle comp
* @prop {string} dropdownClass the css class to apply to the comp
* @prop {number} tabIndex define navigation order
* @prop {number} badgeValue to apply the value to the item in list
* @prop {node} containerNode the node to append the child element into a DOM
* @example
* <DropdownList
* id={id}
* items={items}
* label={label}
* labelId={labelId}
* toogleStyle={style}
* toogleImage={image}
* state={state}
* dropdownClass={classItem}
* tabIndex={tabIndex}
* badgeValue={badgeValue}
* containerNode={containerNode}
* />
*
*/
const DropdownList = ({
id,
items,
label,
labelId,
toogleStyle,
toogleImage,
dropdownClass,
tabIndex,
badgeValue,
containerNode,
size,
alignRight
}) => {
const dropdownItems = items
.map((itm, idx) => {
if (itm.type === 'divider') {
return <Dropdown.Divider key={idx} />;
}
return (
<Dropdown.Item
key={idx}
href={itm.href}
style={itm.style}
>
{itm.labelId && <Message msgId={itm.labelId} /> || itm.label}
{isValidBadgeValue(itm.badge) && <Badge>{itm.badge}</Badge>}
</Dropdown.Item>
);
});
const DropdownToogle = (
<Dropdown.Toggle
id={'gn-toggle-dropdown-' + id}
variant="default"
tabIndex={tabIndex}
style={toogleStyle}
size={size}
>
{toogleImage
? <img src={toogleImage} />
: null
}
{labelId && <Message msgId={labelId} /> || label}
{isValidBadgeValue(badgeValue) && <Badge>{badgeValue}</Badge>}
</Dropdown.Toggle>
);
return (
<Dropdown
className={`${dropdownClass}`}
alignRight={alignRight}
>
{DropdownToogle}
{containerNode
? createPortal(<Dropdown.Menu>
{dropdownItems}
</Dropdown.Menu>, containerNode.parentNode)
: <Dropdown.Menu>
{dropdownItems}
</Dropdown.Menu>}
</Dropdown>
);
};
DropdownList.propTypes = {
id: PropTypes.number,
items: PropTypes.array.isRequired,
label: PropTypes.string,
labelId: PropTypes.string,
toogleStyle: PropTypes.object,
toogleImage: PropTypes.string,
state: PropTypes.object,
dropdownClass: PropTypes.string,
tabIndex: PropTypes.number,
badgeValue: PropTypes.number,
containerNode: PropTypes.element
};
export default DropdownList;
| 27.839416 | 81 | 0.570792 | false | true | false | true |
d003b00def8b0955bc466d3d48e4eb677f9cb02d | 5,042 | jsx | JSX | src/views/Adicionar_Pedido.jsx | KelvinGomes/NotaMais_Front | 78c4f6a2f51495023c89de6ad191b3e781c5fbf6 | [
"MIT"
] | null | null | null | src/views/Adicionar_Pedido.jsx | KelvinGomes/NotaMais_Front | 78c4f6a2f51495023c89de6ad191b3e781c5fbf6 | [
"MIT"
] | null | null | null | src/views/Adicionar_Pedido.jsx | KelvinGomes/NotaMais_Front | 78c4f6a2f51495023c89de6ad191b3e781c5fbf6 | [
"MIT"
] | null | null | null | import React from "react";
import axios from 'axios';
// reactstrap components
import {
Card, CardHeader, CardBody, Row, Col, Form, FormGroup, Input, Button, CardFooter
}
from "reactstrap";
class Adicionar_Pedido extends React.Component {
constructor(props) {
super(props);
this.state = {
order: {
subject: '',
description: '',
educationLevel: '',
studyArea: '',
dueDate: '',
status: 1
}
};
this.atribuirValor = this.atribuirValor.bind(this);
this.submeter = this.submeter.bind(this);
}
atribuirValor(event) {
let order = this.state.order;
order[event.target.name] = event.target.value;
this.setState({ order: order });
}
async submeter(event) {
event.preventDefault();
let order = this.state.order;
let token = await localStorage.getItem('token');
axios.defaults.headers.common = { 'Authorization': `bearer ${token}` }
await axios.post(`https://notamais-backend01.herokuapp.com/orders`, order)
.then(res => {
window.alert("Pedido gerado com sucesso!");
window.location.href = "/admin/pedidos";
})
.catch((error) => {
window.alert("Erro: todos os campos são de preechimento obrigatório!");
});
}
render() {
return (
<>
<div className="content">
<Card>
<CardHeader style={{
backgroundColor: "rgb(58, 132, 177)", borderTopLeftRadius: "10px",
borderTopRightRadius: "10px", textAlign: "center"
}}>
<h6>Para gerar seu pedido preencha o questionário</h6>
</CardHeader>
<CardBody>
<Form>
<Row style={{ margin: "10px" }}>
<Col className="pr-1" md="12">
<p>Qual o assunto da atividade? *</p>
<FormGroup>
<Input
name="subject"
type="texto"
value={this.state.order.subject} onChange={this.atribuirValor}
maxLength="80"
/>
</FormGroup>
</Col>
</Row>
<Row style={{ margin: "10px" }}>
<Col className="pr-1" md="4">
<p>Qual o grau de instrução necessário? *</p>
<FormGroup>
<Input name="educationLevel" type="select" id="exampleSelect" value={this.state.order.educationLevel} onChange={this.atribuirValor}>
<option value="0">Todos</option>
<option value="1">Ensino médio</option>
<option value="2">Ensino Técnico</option>
<option value="3">Ensino superior</option>
</Input>
</FormGroup>
</Col>
<Col className="pr-1" md="4">
<p>Em qual área se enquadra? *</p>
<FormGroup>
<Input name="studyArea" type="select" id="exampleSelect" value={this.state.order.studyArea} onChange={this.atribuirValor}>
<option value="0">Todos</option>
<option value="1">Ciências Exatas</option>
<option value="2">Ciencias Humanas</option>
<option value="3">Ciências Biológicas</option>
<option value="4">Linguagens e Códigos</option>
</Input>
</FormGroup>
</Col>
<Col className="pr-1" md="4">
<p>Para quando? *</p>
<FormGroup>
<Input
value={this.state.order.dueDate} onChange={this.atribuirValor}
name="dueDate"
type="date"
/>
</FormGroup>
</Col>
</Row>
<Row style={{ margin: "10px" }}>
<Col className="pr-1" md="12">
<p>Descrição *</p>
<FormGroup>
<Input
name="description"
type="textarea"
value={this.state.order.description} onChange={this.atribuirValor}
maxLength="450"
/>
</FormGroup>
</Col>
</Row>
<Row>
<Button style={{ backgroundColor: " rgb(58, 132, 177)" }}
className="update ml-auto mr-auto" color="primary" onClick={this.submeter}>
Gerar pedido
</Button>
</Row>
</Form>
</CardBody>
<CardFooter>
</CardFooter>
</Card>
</div>
</>
);
}
}
export default Adicionar_Pedido;
| 35.758865 | 154 | 0.454383 | false | true | true | false |
d003c09a2b9a663820db3e53d47f247e41950932 | 447 | jsx | JSX | src/widgets/notification/Notification.jsx | alexkolov/erp-view-example | ec4e804618b90189451eaecdab4edc4d10984ffa | [
"MIT"
] | null | null | null | src/widgets/notification/Notification.jsx | alexkolov/erp-view-example | ec4e804618b90189451eaecdab4edc4d10984ffa | [
"MIT"
] | null | null | null | src/widgets/notification/Notification.jsx | alexkolov/erp-view-example | ec4e804618b90189451eaecdab4edc4d10984ffa | [
"MIT"
] | null | null | null | import React from 'react';
import Alert from '@material-ui/lab/Alert';
import './notification.scss';
export const Notifications = ({ notifications }) => {
return (
<div className='notifications'>
{
notifications.map(
(el, index) => (
<Alert
severity='error'
key={ index }
>
{ el }
</Alert>
)
)
}
</div>
)
};
| 19.434783 | 53 | 0.451902 | false | true | false | true |
d003c19f3c661694acba1c7745f925fbb619542b | 20,034 | jsx | JSX | app/js/components/crime.jsx | codeforkansascity/n-hood | 2ed447240137712a88da947d7cd0261ee010a708 | [
"MIT"
] | 21 | 2015-06-06T15:40:08.000Z | 2020-12-04T14:48:56.000Z | app/js/components/crime.jsx | codeforkansascity/n-hood | 2ed447240137712a88da947d7cd0261ee010a708 | [
"MIT"
] | 154 | 2015-06-09T03:51:05.000Z | 2020-12-31T00:35:52.000Z | app/js/components/crime.jsx | codeforkansascity/n-hood | 2ed447240137712a88da947d7cd0261ee010a708 | [
"MIT"
] | 10 | 2015-06-06T23:15:24.000Z | 2018-10-15T22:09:49.000Z | import React from 'react';
import { render } from 'react-dom';
import axios from 'axios';
import Datetime from 'react-datetime';
import { toast } from 'react-toastify';
import 'react-datetime/css/react-datetime.css';
import CrimeStatisticsTable from './crime_statistics_table';
import '../modernizr-bundle';
import moment from 'moment';
const formatCoordinates = (point) => {
return '' + point[0] + point[1];
};
const formatResponse = (response) => {
// aggregate crimes for a particular "address"
// (to help protect privacy, KCMO locates a crime at the nearest intersection)
var aggregatedCrimes = response.data.reduce(function(addresses, incident) {
let crime_location = formatCoordinates(incident.geometry.coordinates);
if (crime_location in addresses) {
addresses[crime_location].properties.disclosure_attributes.push(
incident.properties.disclosure_attributes[0] + ' - ' + incident.properties.disclosure_attributes[2]
);
} else {
// initialize a new location
var address = {};
address.address = incident.address;
address.properties = {};
address.properties.color = incident.properties.color;
address.properties.disclosure_attributes = [];
address.properties.disclosure_attributes.push(incident.address);
address.properties.disclosure_attributes.push(
incident.properties.disclosure_attributes[0] + ' - ' + incident.properties.disclosure_attributes[2]
);
address.description = incident.description;
address.geometry = incident.geometry;
address.ibrs = incident.ibrs;
addresses[crime_location] = address;
}
return addresses;
}, {});
console.dir(aggregatedCrimes);
// transform into array
const crimeLocationArray = [];
for (var crimeLocation in aggregatedCrimes) {
crimeLocationArray.push(aggregatedCrimes[crimeLocation]);
}
// build markers that include a count of crimes at the location
var markers = crimeLocationArray.map(function(dataPoint) {
return {
type: 'marker',
position: {
lat: dataPoint.geometry.coordinates[1],
lng: dataPoint.geometry.coordinates[0]
},
icon: {
path: 'M 0,0 C -2,-20 -10,-22 -10,-30 A 10,10 0 1,1 10,-30 C 10,-22 2,-20 0,0 z ',
fillColor: dataPoint.properties.color,
fillOpacity: 1,
labelOrigin: new google.maps.Point(0, -30),
strokeColor: '#000',
strokeWeight: 2,
scale: 1
},
label: { text: `${dataPoint.properties.disclosure_attributes.length - 1}`, color: 'white' },
defaultAnimation: 2,
windowContent: dataPoint.properties.disclosure_attributes.map((attribute) => (
<div dangerouslySetInnerHTML={{ __html: attribute }} />
))
};
});
return { markers: markers, polygons: [] };
};
const CRIME_CODES = {
ARSON: '200',
ASSAULT: '13',
ASSAULT_AGGRAVATED: '13A',
ASSAULT_SIMPLE: '13B',
ASSAULT_INTIMIDATION: '13C',
BRIBERY: '510',
BURGLARY: '220',
FORGERY: '250',
VANDALISM: '290',
DRUG: '35',
DRUG_NARCOTIC: '35A',
DRUG_EQUIPMENT: '35B',
EMBEZZLEMENT: '270',
EXTORTION: '210',
FRAUD: '26',
FRAUD_SWINDLE: '26A',
FRAUD_CREDIT_CARD: '26B',
FRAUD_IMPERSONATION: '26C',
FRAUD_WELFARE: '26D',
FRAUD_WIRE: '26E',
GAMBLING: '39',
GAMBLING_BETTING: '39A',
GAMBLING_OPERATING: '39B',
GAMBLING_EQUIPMENT_VIOLATIONS: '39C',
GAMBLING_TAMPERING: '39D',
HOMICIDE: '09',
HOMICIDE_NONNEGLIGENT_MANSLAUGHTER: '09A',
HOMICIDE_NEGLIGENT_MANSLAUGHTER: '09B',
HUMAN_TRAFFICKING: '64',
HUMAN_TRAFFICKING_SEX_ACTS: '64A',
HUMAN_TRAFFICKING_INVOLUNTARY_SERVITUDE: '64B',
KIDNAPPING: '100',
THEFT: '23',
THEFT_POCKET_PICKING: '23A',
THEFT_PURSE_SNATCHING: '23B',
THEFT_SHOPLIFTING: '23C',
THEFT_FROM_BUILDING: '23D',
THEFT_FROM_THEFT_COINOPERATED_DEVICE: '23E',
THEFT_MOTOR_VEHICLE: '23F',
THEFT_MOTOR_VEHICLE_PARTS: '23G',
THEFT_OTHER: '23H',
MOTOR_VEHICLE_THEFT: '240',
PORNOGRAPHY: '370',
PROSTITUTION: '40',
PROSTITUTION_BASE: '40A',
PROSTITUTION_ASSISTANCE: '40B',
PROSTITUTION_PURCHASING: '40C',
ROBBERY: '120',
SEX_OFFENSE: '11',
SEX_OFFENSE_RAPE: '11A',
SEX_OFFENSE_SODOMY: '11B',
SEX_OFFENSE_ASSAULT_WITH_OBJECT: '11C',
SEX_OFFENSE_FONDLING: '11D',
SEX_OFFENSE_NONFORCIBLE: '36',
SEX_OFFENSE_NONFORCIBLE_INCEST: '36A',
SEX_OFFENSE_NONFORCIBLE_STATUATORY_RAPE: '36B',
STOLEN_PROPERTY: '280',
WEAPON_LAW_VIOLATIONS: '520',
BAD_CHECKS: '90A',
CURFEW: '90B',
DISORDERLY_CONDUCT: '90C',
DRIVING_UNDER_INFLUENCE: '90D',
DRUNKENNESS: '90E',
FAMILY_OFFENSES_NON_VIOLENT: '90F',
LIQUOR_LAW_VIOLATIONS: '90G',
PEEPING_TOM: '90H',
RUNAWAY: '90I',
TRESSPASSING: '90J',
OTHER: '90Z'
};
const CrimeCodeGroups = (code) => {
switch (code) {
case CRIME_CODES.ASSAULT:
return [ CRIME_CODES.ASSAULT_AGGRAVATED, CRIME_CODES.ASSAULT_SIMPLE, CRIME_CODES.ASSAULT_INTIMIDATION ];
case CRIME_CODES.DRUG:
return [ CRIME_CODES.DRUG_NARCOTIC ];
case CRIME_CODES.FRAUD:
return [
CRIME_CODES.FRAUD_SWINDLE,
CRIME_CODES.FRAUD_CREDIT_CARD,
CRIME_CODES.FRAUD_IMPERSONATION,
CRIME_CODES.FRAUD_WELFARE,
CRIME_CODES.FRAUD_WIRE
];
case CRIME_CODES.GAMBLING:
return [
CRIME_CODES.GAMBLING_BETTING,
CRIME_CODES.GAMBLING_OPERATING,
CRIME_CODES.GAMBLING_EQUIPMENT_VIOLATIONS,
CRIME_CODES.GAMBLING_TAMPERING
];
case CRIME_CODES.HOMICIDE:
return [ CRIME_CODES.HOMICIDE_NONNEGLIGENT_MANSLAUGHTER, CRIME_CODES.HOMICIDE_NEGLIGENT_MANSLAUGHETER ];
case CRIME_CODES.HUMAN_TRAFFICKING:
return [ CRIME_CODES.HUMAN_TRAFFICKING_SEX_ACTS, CRIME_CODES.HUMAN_TRAFFICKING_INVOLUNTARY_SERVITUDE ];
case CRIME_CODES.THEFT:
return [
CRIME_CODES.THEFT_POCKET_PICKING,
CRIME_CODES.THEFT_PURSE_SNATCHING,
CRIME_CODES.THEFT_SHOPLIFTING,
CRIME_CODES.THEFT_FROM_BUILDING,
CRIME_CODES.THEFT_FROM_THEFT_COINOPERATED_DEVICE,
CRIME_CODES.THEFT_MOTOR_VEHICLE,
CRIME_CODES.THEFT_MOTOR_VEHICLE_PARTS,
CRIME_CODES.THEFT_OTHER,
CRIME_CODES.MOTOR_VEHICLE_THEFT
];
case CRIME_CODES.PROSTITUTION:
return [
CRIME_CODES.PROSTITUTION_BASE,
CRIME_CODES.PROSTITUTION_ASSISTANCE,
CRIME_CODES.PROSTITUTION_PURCHASING
];
case CRIME_CODES.SEX_OFFENSE_NONFORCIBLE:
return [
CRIME_CODES.SEX_OFFENSE_NONFORCIBLE,
CRIME_CODES.SEX_OFFENSE_NONFORCIBLE_INCEST,
CRIME_CODES.SEX_OFFENSE_NONFORCIBLE_STATUATORY_RAPE
];
case CRIME_CODES.SEX_OFFENSE:
return [
CRIME_CODES.SEX_OFFENSE_RAPE,
CRIME_CODES.SEX_OFFENSE_SODOMY,
CRIME_CODES.SEX_OFFENSE_ASSAULT_WITH_OBJECT,
CRIME_CODES.SEX_OFFENSE_FONDLING
];
default:
return [ code ];
}
};
class Crime extends React.Component {
constructor(props) {
super(props);
this.state = {
filters: [],
filtersViewable: true,
reportInformation: null,
viewingReport: false
};
this.handleFilterChange = this.handleFilterChange.bind(this);
this.toggleFilters = this.toggleFilters.bind(this);
this.queryDataset = this.queryDataset.bind(this);
this.toggleReport = this.toggleReport.bind(this);
this.updateStartDate = this.updateStartDate.bind(this);
this.updateEndDate = this.updateEndDate.bind(this);
}
componentWillMount() {
this.updateReport(this.props.params.neighborhoodId);
}
componentWillReceiveProps(nextProps) {
if (this.props.params.neighborhoodId !== nextProps.params.neighborhoodId) {
this.updateReport(nextProps.params.neighborhoodId);
}
}
updateReport(neighborhoodId) {
var _this = this;
_this.setState({
reportInformation: null,
viewingReport: false
});
axios
.get('/api/neighborhood/' + neighborhoodId + '/crime/grouped_totals')
.then(function(response) {
_this.setState({
..._this.state,
reportInformation: response.data
});
console.log('== Crime component - crime totals retrieved ==');
console.dir(response.data);
})
.then(function(error) {
console.log(error);
});
}
toggleFilters() {
this.setState({
...this.state,
filtersViewable: !this.state.filtersViewable
});
}
handleFilterChange(event) {
var currentFilters = this.state.filters,
crimeCodes = CrimeCodeGroups(event.currentTarget.value),
filterIsActive = event.currentTarget.checked;
crimeCodes.forEach(function(code) {
if (filterIsActive) {
currentFilters.push(code);
} else {
var filterIndex = currentFilters.indexOf(code);
currentFilters.splice(filterIndex, 1);
}
});
}
filterInputs(groups, crimeObject) {
return (
<div className="row">
{groups.map(function(group, index) {
var groupRows = group.map(function(currentFilter) {
return (
<label>
<input
type="checkbox"
value={currentFilter.value}
onChange={crimeObject.handleFilterChange}
/>
{currentFilter.label}
</label>
);
});
return <div className="col-md-6">{groupRows}</div>;
})}
</div>
);
}
personCrimes() {
return (
<div className="col-md-2">
<h2>Person</h2>
<label>
<input type="checkbox" value={CRIME_CODES.ASSAULT} onChange={this.handleFilterChange} />
Assault
</label>
<label>
<input type="checkbox" value={CRIME_CODES.HOMICIDE} onChange={this.handleFilterChange} />
Homicide
</label>
<label>
<input type="checkbox" value={CRIME_CODES.SEX_OFFENSE} onChange={this.handleFilterChange} />
Sex Offense, Forcible
</label>
<label>
<input
type="checkbox"
value={CRIME_CODES.SEX_OFFENSE_NONFORCIBLE}
onChange={this.handleFilterChange}
/> Sex Offense, Non Forcible
</label>
</div>
);
}
propertyCrimes() {
var _this = this;
var groups = [
[
{ value: CRIME_CODES.ARSON, label: 'Arson' },
{ value: CRIME_CODES.BURGLARY, label: 'Burglary' },
{ value: CRIME_CODES.FORGERY, label: 'Forgery/Counterfeiting' },
{ value: CRIME_CODES.EMBEZZLEMENT, label: 'Embezzlement' },
{ value: CRIME_CODES.EXTORTION, label: 'Extortion' },
{ value: CRIME_CODES.FRAUD, label: 'Fraud' }
],
[
{ value: CRIME_CODES.MOTOR_VEHICLE_THEFT, label: 'Motor Vehicle Theft' },
{ value: CRIME_CODES.ROBBERY, label: 'Robbery' },
{ value: CRIME_CODES.STOLEN_PROPERTY, label: 'Stolen Property' },
{ value: CRIME_CODES.THEFT, label: 'Theft' },
{ value: CRIME_CODES.VANDALISM, label: 'Vandalism' }
]
];
return (
<div className="col-md-5">
<h2>Property</h2>
{this.filterInputs(groups, _this)}
</div>
);
}
societyCrimes() {
var _this = this;
var groups = [
[
{ value: CRIME_CODES.BAD_CHECKS, label: 'Bad Checks' },
{ value: CRIME_CODES.CURFEW, label: 'Curfew & Loitering' },
{ value: CRIME_CODES.DISORDERLY_CONDUCT, label: 'Disorderly Conduct' },
{ value: CRIME_CODES.DUI, label: 'DUI' },
{ value: CRIME_CODES.DRUNKNESS, label: 'Drunkenness' },
{ value: CRIME_CODES.FAMILY_OFFENSES_NON_VIOLENT, label: 'Domestic Nonviolent' }
],
[
{ value: CRIME_CODES.GAMBLING, label: 'Gambling' },
{ value: CRIME_CODES.PORNOGRAPHY, label: 'Pornography' },
{ value: CRIME_CODES.LIQUOR_LAW_VIOLATIONS, label: 'Liquor Law Violation' },
{ value: CRIME_CODES.TRESSPASSING, label: 'Trespassing' }
]
];
return (
<div className="col-md-5">
<h2>Society</h2>
{this.filterInputs(groups, _this)}
</div>
);
}
filtersFooter() {
return (
<div>
<div className="map-filter-actions pull-right">
<button className="btn btn-primary" type="button">
Reset
</button>
<button className="btn btn-primary" onClick={this.queryDataset}>
Apply
</button>
</div>
</div>
);
}
queryDataset() {
var _this = this;
this.setState({
...this.state,
loading: true,
filtersViewable: false
});
var queryString =
'crime_codes[]=' +
this.state.filters.join('&crime_codes[]=') +
'&start_date=' +
this.state.startDate +
'&end_date=' +
this.state.endDate;
axios
.get('/api/neighborhood/' + this.props.params.neighborhoodId + '/crime?' + queryString)
.then(function(response) {
var legend = `<ul>
<li><span class="legend-element" style="background-color: #626AB2;"></span>Person</li>
<li><span class="legend-element" style="background-color: #313945;"></span>Property</li>
<li><span class="legend-element" style="background-color: #6B7D96;"></span>Society</li>
<li><span class="legend-element" style="border: #000 solid 1px; background-color: #FFFFFF;"></span>Uncategorized</li>
</ul>`;
_this.setState({
..._this.state,
loading: false
});
console.log('== Crime filters query response ==');
console.dir(response.data);
_this.props.updateMap(formatResponse(response));
_this.props.updateLegend(legend);
})
.catch(function(error) {
console.log('error retrieving or setting crime pins');
console.log(error);
_this.setState({
loading: false
});
toast(
<p>
We're sorry, but the application could not process your request. Please try again later.
</p>,
{
type: toast.TYPE.INFO
}
);
});
}
toggleReport() {
this.setState({
...this.state,
viewingReport: !this.state.viewingReport
});
}
filtersTooltip() {
var className = 'map-filters';
if (!this.state.filtersViewable) {
className += ' hide';
}
return (
<div className={className}>
<form className="form-inline col-md-12">
<div className="form-group">
{this.outputDatetimePicker(this.updateStartDate)}
<label>Start Date</label>
</div>
<div className="form-group">
{this.outputDatetimePicker(this.updateEndDate)}
<label>End Date</label>
</div>
</form>
{this.personCrimes()}
{this.propertyCrimes()}
{this.societyCrimes()}
{this.filtersFooter()}
</div>
);
}
loadingIndicator() {
return (
<span className="filters-loading">
<i className="fa fa-refresh fa-large fa-spin" />
</span>
);
}
filtersActivationButton() {
return (
<button className="btn btn btn-success filters-action" type="button" onClick={this.toggleFilters}>
Filters
</button>
);
}
renderingReport() {
if (!this.state.reportInformation) {
return null;
} else if (this.state.viewingReport) {
return (
<a role="tab" onClick={this.toggleReport}>
Close Report
</a>
);
} else {
return (
<a role="tab" onClick={this.toggleReport}>
Open Report
</a>
);
}
}
updateStartDate(e) {
var date;
if (e._isAMomentObject) {
date = e.format();
} else {
date = e.currentTarget.value;
}
this.setState({
...this.state,
startDate: date
});
}
updateEndDate(e) {
var date;
if (e._isAMomentObject) {
date = e.format();
} else {
date = e.currentTarget.value;
}
this.setState({
...this.state,
endDate: date
});
}
outputDatetimePicker(onChangeFunction) {
if (Modernizr.inputtypes.date) {
return <input type="date" className="form-control" onChange={onChangeFunction} />;
} else {
console.log('datetime');
return (
<Datetime
inputProps={{ placeholder: 'mm/dd/yyyy' }}
timeFormat={false}
input={true}
onChange={onChangeFunction}
/>
);
}
}
render() {
return (
<div>
<div className="toolbar">
{this.renderingReport()}
{this.state.loading ? this.loadingIndicator() : this.filtersActivationButton()}
{this.filtersTooltip()}
</div>
{this.state.viewingReport && (
<div className="statistics-panel">
<CrimeStatisticsTable data={this.state.reportInformation} />
</div>
)}
</div>
);
}
}
export default Crime;
| 33.614094 | 127 | 0.526405 | false | true | true | false |
d003c7efafea2052be95514143dadceb4d8ec974 | 1,793 | jsx | JSX | src/containers/tips-library.jsx | FeatureToggleStudy/code4maus | 6cb4a8707998ec399b2c17b096082de44e68617b | [
"BSD-3-Clause"
] | null | null | null | src/containers/tips-library.jsx | FeatureToggleStudy/code4maus | 6cb4a8707998ec399b2c17b096082de44e68617b | [
"BSD-3-Clause"
] | null | null | null | src/containers/tips-library.jsx | FeatureToggleStudy/code4maus | 6cb4a8707998ec399b2c17b096082de44e68617b | [
"BSD-3-Clause"
] | null | null | null | import bindAll from 'lodash.bindall';
import PropTypes from 'prop-types';
import React from 'react';
import decksLibraryContent from '../lib/libraries/decks/index.jsx';
import LibraryComponent from '../components/library/library.jsx';
import { connect } from 'react-redux';
import {
closeTipsLibrary,
} from '../reducers/modals';
import {
activateDeck,
} from '../reducers/cards';
class TipsLibrary extends React.PureComponent {
constructor(props) {
super(props);
bindAll(this, [ 'handleItemSelect' ]);
}
handleItemSelect(item) {
this.props.onActivateDeck(item.id);
}
render() {
const decksLibraryThumbnailData = Object.keys(decksLibraryContent).map((id) => ({
rawURL: decksLibraryContent[id].img,
id: id,
name: decksLibraryContent[id].name,
featured: true,
}));
if (!this.props.visible) {
return null;
}
return (
<LibraryComponent
data={decksLibraryThumbnailData}
filterable={false}
title="How-Tos"
visible={this.props.visible}
onItemSelected={this.handleItemSelect}
onRequestClose={this.props.onRequestClose}
/>
);
}
}
TipsLibrary.propTypes = {
onActivateDeck: PropTypes.func.isRequired,
onRequestClose: PropTypes.func,
visible: PropTypes.bool,
};
const mapStateToProps = (state) => ({
visible: state.scratchGui.modals.tipsLibrary,
});
const mapDispatchToProps = (dispatch) => ({
onActivateDeck: (id) => dispatch(activateDeck(id)),
onRequestClose: () => dispatch(closeTipsLibrary()),
});
export default connect(
mapStateToProps,
mapDispatchToProps
)(TipsLibrary);
| 25.614286 | 89 | 0.620747 | false | true | false | true |
d003e484dbaae3bce3c9c78196eb455ff68689d8 | 1,599 | jsx | JSX | app/javascript/src/javascript/PatientFilter.jsx | glinesbdev/patient-tracker | cd21f42bb72c2fc872da8b1f3024cedf051ee84a | [
"MIT"
] | null | null | null | app/javascript/src/javascript/PatientFilter.jsx | glinesbdev/patient-tracker | cd21f42bb72c2fc872da8b1f3024cedf051ee84a | [
"MIT"
] | 5 | 2021-03-10T18:02:05.000Z | 2022-02-13T13:08:08.000Z | app/javascript/src/javascript/PatientFilter.jsx | glinesbdev/patient-tracker | cd21f42bb72c2fc872da8b1f3024cedf051ee84a | [
"MIT"
] | null | null | null | import React, { useRef, useEffect } from 'react';
import { useDispatch, useSelector } from 'react-redux';
import { setCurrentPatients, setFilter } from './store';
const PatientFilter = () => {
const dispatch = useDispatch();
const btnGroupRef = useRef();
const store = useSelector(state => ({
page: state.patients.page,
filter: state.patients.filter
}));
useEffect(() => {
Array.from(btnGroupRef.current.children).forEach(el => {
if (el.innerText.toLowerCase() === store.filter) {
el.classList.add('active');
return;
}
});
}, [store]);
const handleClick = (e) => {
Array.from(btnGroupRef.current.children).forEach(el => {
el.classList.remove('active');
});
e.target.classList.add('active');
const filter = e.target.innerText.toLowerCase();
dispatch(setFilter(filter));
fetch(`/patients/filter/${filter}.json?page=${store.page}`)
.then(response => response.json())
.then(data => dispatch(setCurrentPatients(data.patients)))
.catch(error => console.error(error));
};
return (
<div className="w-100 p-2 d-flex justify-content-end filter-bar">
<div ref={btnGroupRef} className="btn-group" role="group" aria-label="Filter buttons">
<button type="button" onClick={handleClick} className="btn btn-light">All</button>
<button type="button" onClick={handleClick} className="btn btn-light">Archived</button>
<button type="button" onClick={handleClick} className="btn btn-light">Pending</button>
</div>
</div>
);
};
export default PatientFilter;
| 31.98 | 95 | 0.646029 | false | true | false | true |
d003ee4445288f0cb4a0d4866e56bcf9ccae2f44 | 752 | jsx | JSX | examples/benchmark/client/view.jsx | npmmirror/beidou | 4e2a2fbb8e8879e3983b3a36673effc27222c2da | [
"MIT"
] | 2,922 | 2017-06-13T09:42:37.000Z | 2022-03-23T07:51:05.000Z | examples/benchmark/client/view.jsx | npmmirror/beidou | 4e2a2fbb8e8879e3983b3a36673effc27222c2da | [
"MIT"
] | 281 | 2017-12-16T16:31:57.000Z | 2022-03-01T13:10:58.000Z | examples/benchmark/client/view.jsx | npmmirror/beidou | 4e2a2fbb8e8879e3983b3a36673effc27222c2da | [
"MIT"
] | 346 | 2017-07-17T13:16:08.000Z | 2022-03-31T09:11:37.000Z | import 'babel-polyfill';
import React from 'react';
import Recursive from './recursive';
export default class View extends React.Component {
static doctype = '<!DOCTYPE html>';
render() {
const { helper, ctx } = this.props;
const { depth = 3, breadth = 10, repeat = 1 } = ctx.query;
return (
<html>
<head>
<title>benchmark demo</title>
<meta viewport="" />
<link rel="stylesheet" href={helper.asset('index.css')} />
</head>
<body>
<div className="demo">
{[...new Array(parseInt(repeat, 10))].map((v, i) => (
<Recursive key={i} depth={depth} breadth={breadth} />
))}
</div>
</body>
</html>
);
}
}
| 25.931034 | 68 | 0.515957 | false | true | true | false |
d003f56b10b059abea55ba2973c61fdb8c51f1be | 7,286 | jsx | JSX | nmr/js/nmrsignal.jsx | NPellet/jsGraph | 84356748c45205cc246f16774a9fb37aaf350e57 | [
"MIT"
] | 24 | 2015-08-19T12:01:28.000Z | 2020-04-06T13:50:40.000Z | nmr/js/nmrsignal.jsx | NPellet/jsGraph | 84356748c45205cc246f16774a9fb37aaf350e57 | [
"MIT"
] | 247 | 2015-01-08T13:57:53.000Z | 2022-01-25T11:54:19.000Z | nmr/js/nmrsignal.jsx | NPellet/jsGraph | 84356748c45205cc246f16774a9fb37aaf350e57 | [
"MIT"
] | 10 | 2015-12-03T01:22:23.000Z | 2017-12-17T01:14:17.000Z | import React from "react";
import Graph from "../../src/graph";
import PropTypes from 'prop-types';
import Assignment from './assignment.js'
import FormCoupling from './forms/form_coupling/formcoupling.jsx'
import FormArea from './formarea.jsx'
import extend from 'extend';
var levelHeight = 12;
var colors=[ '#ca072c','#9507ca','#0727ca','#07cac8', '#08a538' ];
// Example for 400MHz
var hzToPoint = 10**6 / 400e6;
var width = 100;
var yShift = 1;
var currentColor;
var highlight = 1;
function getMultiplicity(string) {
switch (string) {
case 's':
return 1;
case 'd':
return 2;
case 't':
return 3;
case 'q':
return 4;
case 'quint':
return 5;
case 'hex':
case 'sex':
return 6;
case 'hept':
case 'hepta':
return 7;
case 'oct':
case 'octa':
return 8;
case 'non':
case 'nona':
return 9;
}
}
function getPascal(n) {
var line=[1];
for (var i=0; i<(n-1); i++) {
line.push(line[i]*(n-i-1)/(i+1))
}
return line;
}
function makePeakLine(x, y, height, color) {
if (! height) height=levelHeight;
return makeLine (x, y, x, y+height, color, 2);
}
function makeDiagonalLine(x1, y1, x2, y2, color) {
return makeLine (x1, y1, x2, y2, color, 0.4);
}
function makeLine(xFrom, yFrom, xTo, yTo, color, width) {
return {
"properties": {
"position": [
{
"y": (yFrom + yShift)+"px",
"x": xFrom
},
{
"y": (yTo + yShift)+"px",
"x": xTo
}
],
"strokeColor": [ color ],
"strokeWidth": [ width ]
},
"type": "line",
}
}
class NMRSignal extends React.Component {
constructor( props, context ) {
super( props );
this.graph = context.graph;
this.currentLevel;
this.assignment = context.assignment;
this.reactFormArea = context.formArea;
this.editCoupling = this.editCoupling.bind( this );
}
componentWillUnmount() {
this.removeAll();
this.assignment.removeGraphShape( this.props.id );
}
removeAll() {
if( this._jsGraphShapes ) {
this._jsGraphShapes.map( shape => shape.kill() );
}
this._jsGraphShapes = [];
}
componentDidMount() {
this.updateSignalDrawing();
}
appendLevel( multiplicity, coupling ) {
this.currentLevel={
multiplicity: multiplicity, coupling: coupling, peaks: []
};
this.allLevels.push( this.currentLevel );
this.currentColor = colors[ ( this.allLevels.length - 1 ) % colors.length ];
var previousPeaks = this.previousLevel.peaks;
var vertical = levelHeight * ( ( this.allLevels.length - 1 ) * 2 );
var pascal = getPascal( getMultiplicity( multiplicity ) );
for (var i = 0; i < previousPeaks.length; i++) {
var parent = previousPeaks[ i ];
var peaks = [];
for (var j = 0; j < pascal.length; j++) {
let xShift = coupling * j * hzToPoint- ( ( coupling * hzToPoint * ( pascal.length-1 ) ) / 2 );
peaks.push( {
x: parent.x - xShift,
y: vertical,
height: parent.height * pascal[ j ]
} )
}
this.paintTree(parent, peaks, this.currentColor);
this.currentLevel.peaks = this.currentLevel.peaks.concat( peaks );
};
this.previousLevel = this.currentLevel;
}
paintTree( parentPeak, currentPeaks, color, horizontal ) {
// we paint diagonals to parent
this._jsGraphShapes.map( ( shape ) => shape.kill() );
this.highlight++;
if( parentPeak ) {
for (var i=0; i < currentPeaks.length; i++) {
var peak = currentPeaks[i];
this.annotations.push( makeDiagonalLine( parentPeak.x, parentPeak.y+levelHeight, peak.x, peak.y ,color));
}
};
if( horizontal ) {
let peak = currentPeaks[ 0 ];
this.annotations.push( makeDiagonalLine( horizontal[ 1 ], peak.y + levelHeight / 2, horizontal[ 0 ], peak.y + levelHeight / 2, color) );
this.annotations.push( makePeakLine( horizontal[ 0 ], peak.y, null, color ) );
this.annotations.push( makePeakLine( horizontal[ 1 ], peak.y, null, color ) );
} else {
// we paint vertical of current level
for (var i = 0; i < currentPeaks.length; i++) {
let peak = currentPeaks[i];
this.annotations.push( makePeakLine( peak.x, peak.y, null, color ) );
}
}
let refShape;
this._jsGraphShapes = this.annotations.map( ( annotation, index ) => {
let annotation_jsGraph = this.graph.newShape( annotation.type, { noY: true }, false, annotation.properties );
annotation_jsGraph.setDom( 'data-signal-id', this.props.id );
annotation_jsGraph.draw().redraw();
if( index == 0 ) {
refShape = annotation_jsGraph;
}
annotation_jsGraph._dom._shape = refShape;
annotation_jsGraph.on('shapeClicked', this.editCoupling );
return annotation_jsGraph;
} );
}
editCoupling() {
let validated = ( newValue ) => {
this.props.onSignalChanged( this.props.id, newValue );
}
let split = ( newValue ) => {
newValue = extend( true, {}, newValue );
this.props.onSignalCreated( newValue );
}
this.reactFormArea.setForm(
<FormCoupling
onValidate={ validated }
onCancel={ () => this.reactFormArea.empty() }
onSplit={ split }
formData={ this.props } />
);
}
updateSignalDrawing( props = this.props ) {
this.removeAll();
this.annotations=[];
this.currentColor = colors[ 0 ];
this.previousLevel = {
multiplicity: 's',
coupling: 0,
peaks: [ {
x: props.delta,
y: 0,
height: 1
} ]
};
this.allLevels = [ this.previousLevel ];
this.paintTree( null, this.previousLevel.peaks, this.currentColor, ! this.props.j || this.props.j.length == 0 ? [ this.props.from, this.props.to ] : undefined );
this._jsGraphShapes[ 0 ].selectable( true );
this._jsGraphShapes[ 0 ].movable( true );
this._jsGraphShapes[ 0 ].setProp( 'selectOnMouseDown', true );
//this._jsGraphShapes[ 0 ]._data = { noY: true };
if( ! Array.isArray( this.props.j ) ) {
return;
}
for (var i = 0; i < this.props.j.length; i++) {
var multiplicity = this.props.j[ i ].multiplicity;
var coupling = this.props.j[ i ].coupling;
if (multiplicity && coupling) {
this.appendLevel( multiplicity, coupling );
}
}
}
componentWillReceiveProps( nextProps ) {
this.updateSignalDrawing( nextProps );
if( nextProps.id !== this.props.id ) {
if( ! this.assignment ) {
throw "No assignment object. Cannot rename integral";
}
this.assignment.renameAssignementElement( this.props.id, nextProps.id );
}
}
render() {
return (<span key={ this.props.id } />)
}
}
NMRSignal.contextTypes = {
assignment: PropTypes.instanceOf( Assignment ),
graph: PropTypes.instanceOf( Graph ),
formArea: PropTypes.instanceOf( FormArea ),
serie: PropTypes.instanceOf( Graph.getConstructor( Graph.SERIE_LINE ) )
};
export default NMRSignal | 23.888525 | 163 | 0.583722 | true | false | true | false |
d003fed4e5a3a4ca60b77a5fa3ac00ee6f82c5ec | 3,360 | jsx | JSX | src/Config/WebPack/Utils/MultiConfigLoader.jsx | ausesims/rdx | 8eff989986c588080fae99074b266573408ec429 | [
"MIT"
] | 23 | 2016-05-22T01:03:45.000Z | 2020-07-06T09:15:13.000Z | src/Config/WebPack/Utils/MultiConfigLoader.jsx | ausesims/rdx | 8eff989986c588080fae99074b266573408ec429 | [
"MIT"
] | 34 | 2016-03-10T14:59:41.000Z | 2019-02-13T18:15:59.000Z | src/Config/WebPack/Utils/MultiConfigLoader.jsx | ausesims/rdx | 8eff989986c588080fae99074b266573408ec429 | [
"MIT"
] | 2 | 2016-05-22T12:39:17.000Z | 2017-07-18T15:05:30.000Z | import Path from 'path';
import Glob from 'glob';
export default class MultiConfigLoader {
static getConfigByFullPath (fullPath, contextPath, absOutputPath, asObject = false, compileTarget) {
let target = asObject ? {} : [];
let paths = [];
try {
const pathPattern = Path.join(
fullPath,
'**/*.jsx'
);
paths = Glob.sync(pathPattern);
} catch (error) {
return target;
}
for (let i = 0; i < paths.length; i++) {
const p = paths[i];
try {
const func = require(p);
const value = func(contextPath, absOutputPath, compileTarget);
if (asObject) {
target = {
...target,
...value
};
} else {
target = [
...(target || []),
...(value || [])
];
}
} catch (error) {
// Ignore.
}
}
return target;
}
static getFullConfigPath (basePath, configType, commandType) {
return Path.join(basePath, configType, commandType);
}
baseConfigPath;
contextPath;
absOutputPath;
compileTarget;
constructor (baseConfigPath, contextPath, absOutputPath, compileTarget) {
this.baseConfigPath = baseConfigPath;
this.contextPath = contextPath;
this.absOutputPath = absOutputPath;
this.compileTarget = compileTarget;
}
getConfiguration (configType, commandType, asObject = false) {
const fullConfigPath = MultiConfigLoader.getFullConfigPath(
this.baseConfigPath,
configType,
commandType
);
return MultiConfigLoader.getConfigByFullPath(
fullConfigPath,
this.contextPath,
this.absOutputPath,
asObject,
this.compileTarget
);
}
getFullConfigFromMap (map = {
configName: [
{
configType: '',
commandType: '',
asObject: false
}
]
}) {
const fullConfig = {};
if (map instanceof Object) {
for (const k in map) {
if (map.hasOwnProperty(k)) {
const mapItemList = map[k];
if (mapItemList instanceof Array) {
for (let i = 0; i < mapItemList.length; i++) {
const mapItem = mapItemList[i];
const configItems = this.getConfiguration(
mapItem.configType,
mapItem.commandType,
mapItem.asObject
);
const fullConfigItem = fullConfig[k];
fullConfig[k] = mapItem.asObject ? {
...fullConfigItem,
...configItems
} : [
...(fullConfigItem || []),
...(configItems || [])
];
}
}
}
}
}
return fullConfig;
}
getConfigForTypes (configTypes = [], commandTypes = [], objectTypes = []) {
const configMap = {};
for (let i = 0; i < configTypes.length; i++) {
const cfgT = configTypes[i];
for (let j = 0; j < commandTypes.length; j++) {
const cmdT = commandTypes[j];
const cfgTList = configMap[cfgT];
configMap[cfgT] = [
...(cfgTList || []),
{
configType: cfgT,
commandType: cmdT,
asObject: objectTypes.indexOf(cfgT) !== -1
}
];
}
}
return this.getFullConfigFromMap(configMap);
}
}
| 23.661972 | 102 | 0.528869 | false | true | false | true |
d0040a0b75a0bfa0867b5a32d6f1002530584279 | 898 | jsx | JSX | src/views/unauthenticated_app.jsx | BuildForSDG/Team-083-Frontend | e6675af44aa4504d04b2772e444579ffebb6bcb7 | [
"MIT"
] | null | null | null | src/views/unauthenticated_app.jsx | BuildForSDG/Team-083-Frontend | e6675af44aa4504d04b2772e444579ffebb6bcb7 | [
"MIT"
] | 27 | 2020-05-06T16:50:11.000Z | 2020-07-06T16:29:49.000Z | src/views/unauthenticated_app.jsx | BuildForSDG/Team-083-Frontend | e6675af44aa4504d04b2772e444579ffebb6bcb7 | [
"MIT"
] | 3 | 2020-05-18T09:08:56.000Z | 2020-05-25T23:51:10.000Z | import React from 'react';
import { Router } from '@reach/router';
import Layout from './Unauthenticated/Layout';
import Index from './Unauthenticated/Index';
import Register from './Unauthenticated/Register';
import Login from './Unauthenticated/Login';
import PasswordReset from './Unauthenticated/PasswordReset';
import NotFound from './Unauthenticated/NotFound';
const ScrollToTop = ({ children, location }) => {
React.useEffect(() => window.scrollTo(0, 0), [location.pathname]);
return children;
};
const UnauthenticatedApp = () => {
return (
<Layout>
<Router>
<ScrollToTop path="/">
<Index path="/" />
<Register path="/register" />
<Login path="/login" />
<PasswordReset path="/reset-password" />
<NotFound default />
</ScrollToTop>
</Router>
</Layout>
);
};
export default UnauthenticatedApp;
| 27.212121 | 68 | 0.642539 | false | true | false | true |
d0041917104c4b3e879c76aaa4d9b3e952fcc58c | 7,885 | jsx | JSX | ui/src/pages/SignIn/index.jsx | Danes99/journalism | eca666f7499158d3689560bd55ed4dc7a062155a | [
"Apache-2.0"
] | null | null | null | ui/src/pages/SignIn/index.jsx | Danes99/journalism | eca666f7499158d3689560bd55ed4dc7a062155a | [
"Apache-2.0"
] | null | null | null | ui/src/pages/SignIn/index.jsx | Danes99/journalism | eca666f7499158d3689560bd55ed4dc7a062155a | [
"Apache-2.0"
] | null | null | null | // Import pre-installed modules
import React, { useState } from 'react'
// Import downloaded modules
import validator from 'validator'
import { NavLink, useHistory } from 'react-router-dom'
// Import SVG
import logo from '../../svg/workflow-mark-indigo-600.svg'
// Import Config
import { DAO_ENDPOINT_USER_LOGIN } from '../../config/dao'
// Constants: Initial state
// const INITIAL_SATE_LOGIN_REQUEST_HAS_BEEN_SEND = false
// const INITIAL_SATE_LOGIN_REQUEST_HAS_BEEN_RECEIVED = null
// const INITIAL_SATE_LOGIN_REQUEST_RESULT = null
const Page = (props) => {
// History
const history = useHistory()
// State
const [userEmail, setUserEmail] = useState(null)
const [userPassword, setUserPassword] = useState(null)
const [isUserEmailValid, setIsUserEmailValid] = useState(false)
const [isUserPasswordValid, setIsUserPasswordValid] = useState(false)
// const [loginRequestHasBeenSend, setLoginRequestHasBeenSend] = useState(INITIAL_SATE_LOGIN_REQUEST_HAS_BEEN_SEND)
// const [loginRequestHasBeenReceived, setLoginRequestHasBeenReceived] = useState(INITIAL_SATE_LOGIN_REQUEST_HAS_BEEN_RECEIVED)
// const [loginRequestResult, setLoginRequestResult] = useState(INITIAL_SATE_LOGIN_REQUEST_RESULT)
// Update User Email
const handleChangeUserEmail = (e) => {
setUserEmail(e.currentTarget.value)
setIsUserEmailValid(validator.isEmail(e.currentTarget.value))
}
// Update User Password
const handleChangeUserPassword = (e) => {
setUserPassword(e.currentTarget.value)
setIsUserPasswordValid(validator.isStrongPassword(e.currentTarget.value))
}
// Request: HTTP POST Login
const handleSubmit = async (e) => {
// Change layout when login request has been made
// setLoginRequestHasBeenSend(true)
const requestOptions = {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ email: userEmail, password: userPassword }, null, 4)
}
try {
// Send HTTP POST request: login user
const response = await fetch(DAO_ENDPOINT_USER_LOGIN, requestOptions)
// setLoginRequestHasBeenReceived(response.status)
// User is authenticated (Good credentials)
if (response.status === 200) {
// HTTP response body
const body = await response.json()
// Set JWT in local storage
// setLoginRequestResult(body.token)
window.localStorage.setItem('jwt', body.token)
// Redirect to article main menu
props.tokenReceived()
history.push('/article')
}
// User is not authenticated (Bad credentials)
if (response.status === 400) {
// Do something
}
// Server Error
if (response.status === 500) {
// Do something
}
} catch (error) {
console.log(error)
}
}
const canSubmit = isUserEmailValid && isUserPasswordValid
return (
<div className='flex items-center justify-center py-12 px-4 sm:px-6 lg:px-8'>
<div className='max-w-md w-full space-y-8'>
{/* Sign In message */}
<div>
<img className='mx-auto h-12 w-auto' src={logo} alt='Workflow' />
<h2 className='mt-6 text-center text-3xl font-extrabold text-gray-900'>
Sign in to your account
</h2>
<div className='mt-2 text-center text-sm text-gray-600'>
Or
<p className='transition duration-500 font-medium text-indigo-600 hover:text-indigo-500'>
<NavLink to='/register'>
Sign Up
</NavLink>
</p>
</div>
</div>
{/* Sign In Form */}
<div className='mt-8 space-y-6' >
<input type='hidden' name='remember' value='true' />
{/* Email & Password */}
<div className='rounded-md shadow-sm -space-y-px'>
{/* Email */}
<div>
<label htmlFor='email-address' className='sr-only'>Email address</label>
<input id='email-address' name='email' type='email' autoComplete='email' placeholder='Email address' required
onChange={handleChangeUserEmail}
className='appearance-none rounded-none relative block w-full px-3 py-2 border border-gray-300 placeholder-gray-500 text-gray-900 rounded-t-md focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 focus:z-10 sm:text-sm' />
</div>
{/* Password */}
<div>
<label htmlFor='password' className='sr-only'>Password</label>
<input id='password' name='password' type='password' autoComplete='current-password' placeholder='Password' required
onChange={handleChangeUserPassword}
className='appearance-none rounded-none relative block w-full px-3 py-2 border border-gray-300 placeholder-gray-500 text-gray-900 rounded-b-md focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 focus:z-10 sm:text-sm' />
</div>
</div>
{/* Sign in options */}
<div className='flex items-center justify-between'>
{/* Remember me */}
<div className='flex items-center'>
<input id='remember_me' name='remember_me' type='checkbox' className='h-4 w-4 text-indigo-600 focus:ring-indigo-500 border-gray-300 rounded' />
<label htmlFor='remember_me' className='ml-2 block text-sm text-gray-900'>
Remember me
</label>
</div>
{/* Forgot your password? */}
<div className='text-sm'>
<p className='transition duration-500 font-medium text-indigo-600 hover:text-indigo-500'>
Forgot your password?
</p>
</div>
</div>
{/* Sign in button */}
<button onClick={handleSubmit} disabled={!canSubmit}
className='transition duration-500 group relative w-full flex justify-center py-2 px-4 border border-transparent text-sm font-medium rounded-md text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500'
>
<span className='absolute left-0 inset-y-0 flex items-center pl-3'>
{/* SVG Lock */}
<svg className='transition duration-500 h-5 w-5 text-indigo-500 group-hover:text-indigo-400' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='currentColor' aria-hidden='true'>
<path fillRule='evenodd' d='M5 9V7a5 5 0 0110 0v2a2 2 0 012 2v5a2 2 0 01-2 2H5a2 2 0 01-2-2v-5a2 2 0 012-2zm8-2v2H7V7a3 3 0 016 0z' clipRule='evenodd' />
</svg>
</span>
Sign in
</button>
</div>
</div>
</div>
)
}
export default Page
| 41.282723 | 287 | 0.544959 | false | true | false | true |
d0043407bd84a4885e9b3e8f14ab7b3f6f6885e9 | 354 | jsx | JSX | resources/assets/js/components/front/pages/player-signup/index.jsx | phuongit0301/tournapp | 9970c57d2ebc9b5eb8d9b84f44d4e6e45f69a2c4 | [
"MIT"
] | null | null | null | resources/assets/js/components/front/pages/player-signup/index.jsx | phuongit0301/tournapp | 9970c57d2ebc9b5eb8d9b84f44d4e6e45f69a2c4 | [
"MIT"
] | null | null | null | resources/assets/js/components/front/pages/player-signup/index.jsx | phuongit0301/tournapp | 9970c57d2ebc9b5eb8d9b84f44d4e6e45f69a2c4 | [
"MIT"
] | null | null | null | import React, { Component } from 'react';
import ReactDOM from 'react-dom';
import { BrowserRouter, Route } from 'react-router-dom'
import PlayerSignUpComponents from './PlayerSignUpComponents' ;
class PlayerSignUp extends Component {
render() {
return (
<PlayerSignUpComponents />
);
}
}
export default PlayerSignUp; | 27.230769 | 63 | 0.686441 | false | true | true | false |
d0044de145d5d607e16a5d8448f9b49e2dc18535 | 1,312 | jsx | JSX | src/components/KrakenSocket/index.jsx | stellar-fox/cygnus | 10c847228f68ab4ea6f16e0527cd53c1e0353d84 | [
"Apache-2.0"
] | 5 | 2018-04-29T14:55:47.000Z | 2019-12-30T23:25:03.000Z | src/components/KrakenSocket/index.jsx | stellar-fox/cygnus | 10c847228f68ab4ea6f16e0527cd53c1e0353d84 | [
"Apache-2.0"
] | 1 | 2018-03-14T16:02:42.000Z | 2018-03-14T16:38:23.000Z | src/components/KrakenSocket/index.jsx | stellar-fox/cygnus | 10c847228f68ab4ea6f16e0527cd53c1e0353d84 | [
"Apache-2.0"
] | 4 | 2018-03-15T01:16:16.000Z | 2019-04-20T09:49:53.000Z | import { isArray } from "@xcmats/js-toolbox"
import { config } from "../../config"
export default (currency, fnModule) => {
const STATUS = {
connecting: 0,
opened: 1,
online: 2,
subscribed: 3,
closed: 4,
error: 5,
}
fnModule.setSocket({
status: STATUS.connecting,
})
const socket = new WebSocket(config.krakenSocket)
socket.onmessage = function (event) {
const data = JSON.parse(event.data)
if (
isArray(data) &&
data[1] === "ticker" &&
data[2] === `XLM/${currency.toUpperCase()}`
) {
fnModule.updateExchangeRate(currency, data[3].a[0])
} else if (data.status) {
fnModule.setSocket({
status: STATUS[data.status],
})
}
}
socket.onopen = function (_event) {
fnModule.setSocket({
status: STATUS.opened,
})
socket.send(JSON.stringify({
"event": "subscribe",
"pair": [`XLM/${currency.toUpperCase()}`],
"subscription": { "name": "ticker" },
}))
}
socket.onclose = function (_event) {
fnModule.setSocket({
status: STATUS.closed,
})
}
return socket
}
| 22.237288 | 63 | 0.491616 | false | true | false | true |
d00454ba8d5915dbd604bebecfd9809aeb7ec292 | 801 | jsx | JSX | pages/_error.jsx | mpalmr/mpaste | f0570c9aefeb44fef8c44dcbe94ddc82ff2fbf98 | [
"Apache-2.0"
] | 1 | 2019-11-07T00:58:31.000Z | 2019-11-07T00:58:31.000Z | pages/_error.jsx | mpalmr/mpaste | f0570c9aefeb44fef8c44dcbe94ddc82ff2fbf98 | [
"Apache-2.0"
] | 8 | 2020-09-06T13:58:26.000Z | 2022-02-26T01:41:09.000Z | pages/_error.jsx | mpalmr/yapb | f0570c9aefeb44fef8c44dcbe94ddc82ff2fbf98 | [
"Apache-2.0"
] | null | null | null | import React from 'react';
import PropTypes from 'prop-types';
function ErrorPage(props) {
return (
<>
<h1>An error has occured</h1>
<p>{props.message}</p>
<style jsx global>
{`
main {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
`}
</style>
</>
);
}
ErrorPage.propTypes = {
message: PropTypes.string,
};
ErrorPage.defaultProps = {
message: 'unknown',
};
const messages = {
404: 'resource not found',
};
ErrorPage.getInitialProps = function ({ res, err }) {
console.error(err);
const statusCode = process.browser ? null : res.statusCode;
return {
message: messages[statusCode],
};
};
export default ErrorPage;
| 16.346939 | 61 | 0.573034 | false | true | false | true |
d00456cd642703e2d0081bec9d7c1a92e9a9a348 | 4,276 | jsx | JSX | src/components/PaperStore/PaperStore.jsx | caitlincraw/dunder-mifflin | 1ed99f86a16381f95940633633f4c8c937ee7c7b | [
"MIT"
] | null | null | null | src/components/PaperStore/PaperStore.jsx | caitlincraw/dunder-mifflin | 1ed99f86a16381f95940633633f4c8c937ee7c7b | [
"MIT"
] | 25 | 2021-01-06T02:04:40.000Z | 2021-01-25T18:20:35.000Z | src/components/PaperStore/PaperStore.jsx | caitlincraw/dunder-mifflin | 1ed99f86a16381f95940633633f4c8c937ee7c7b | [
"MIT"
] | null | null | null | import React from 'react';
import Filter from './Filter';
import Products from './Products';
import Cart from './Cart';
import './PaperStore.css';
import { fetchProducts, addProduct, removeProduct, sortProducts } from '../../redux/actions/productActions';
import { connect } from "react-redux";
import { Redirect } from 'react-router-dom';
class PaperStore extends React.Component {
constructor(props){
super(props);
this.state = {
loggedIn: true,
cartItems: localStorage.getItem("cartItems")? JSON.parse(localStorage.getItem("cartItems")): [],
sort: "",
};
this.addProductToCart = this.addProductToCart.bind(this);
this.removeProductFromCart = this.removeProductFromCart.bind(this);
this.handleOpenModal = this.handleOpenModal.bind(this);
this.handleCloseModal = this.handleCloseModal.bind(this);
this.sortItemsInStore = this.sortItemsInStore.bind(this);
}
componentDidMount() {
this.props.fetchProducts();
}
handleOpenModal () {
this.setState({ showModal: true });
}
handleCloseModal () {
this.setState({ showModal: false });
}
// removeFromCart = (product) => {
// const cartItems = this.state.cartItems.slice();
// this.setState({ cartItems: cartItems.filter((x) => x.id !== product.id)
// });
// localStorage.setItem("cartItems", JSON.stringify(cartItems.filter((x) => x.id !== product.id)));
// }
// addToCart = (product) => {
// const cartItems = this.state.cartItems.slice();
// let alreadyInCart = false;
// cartItems.forEach(item => {
// if(item.id === product.id){
// item.count++;
// alreadyInCart = true;
// }
// });
// // if(!alreadyInCart){
// cartItems.push({...product, count: 1});
// }
// this.setState({cartItems});
// localStorage.setItem("cartItems", JSON.stringify(cartItems));
// };
addProductToCart = product => {
if (this.props.auth.isLoggedIn) {
this.setState((state) => ({
loggedIn: true,
}))
this.props.addProduct(product)
} else {
// alert("You are not logged in.");
this.setState((state) => ({
loggedIn: false,
}))
}
}
removeProductFromCart = product => {
this.props.removeProduct(product)
}
sortItemsInStore = (e) => {
this.props.sortProducts(e.target.value)
}
render() {
return (
<div className="store">
<div className="store__main">
<Filter
count={this.props.products.length}
sort={this.state.sort}
sortProducts={this.sortItemsInStore}
/>
{this.props.products && this.props.products.length > 0 && (
<Products
productos={this.props.products}
addToCart={this.addProductToCart}
/>
)}
</div>
<div className="store__sidebar">
{this.props.cartItems && this.props.cartItems.length > 0 && this.state.loggedIn && (
<Cart
removeFromCart={this.removeProductFromCart}
/>
)}
{!this.state.loggedIn && <Redirect to="/login" push={true} />}
</div>
</div>
)
}
}
const mapStateToProps = (state) => {
return {
auth: state.auth,
products: state.products,
cartItems: state.cart
};
};
const mapDispatchToProps = (dispatch) => {
return {
fetchProducts: () => dispatch(fetchProducts()),
addProduct: (product) => dispatch(addProduct(product)),
removeProduct: (product) => dispatch(removeProduct(product)),
sortProducts: (sortOrder) => dispatch(sortProducts(sortOrder))
};
};
export default connect(mapStateToProps, mapDispatchToProps)(PaperStore); | 30.542857 | 108 | 0.524556 | false | true | true | false |
d0045c32de0883e8b65e6e222d3d2f0f72394313 | 338 | jsx | JSX | src/components/common/input.jsx | muteshi/movies-rental-app | c9511ce217e0c742ee1cd9cb6a30ecf1d954a29f | [
"MIT"
] | null | null | null | src/components/common/input.jsx | muteshi/movies-rental-app | c9511ce217e0c742ee1cd9cb6a30ecf1d954a29f | [
"MIT"
] | null | null | null | src/components/common/input.jsx | muteshi/movies-rental-app | c9511ce217e0c742ee1cd9cb6a30ecf1d954a29f | [
"MIT"
] | null | null | null | import React from "react";
const Input = ({ error, name, label, ...rest }) => {
return (
<div className="form-group">
<label htmlFor={name} />
<input {...rest} id={name} name={name} className="form-control" />
{error && <div className="alert alert-danger">{error}</div>}
</div>
);
};
export default Input;
| 24.142857 | 72 | 0.579882 | false | true | false | true |
d004656f5be79517ea9a1e317b6a03352a473bb7 | 1,099 | jsx | JSX | src/pages/options/sync-setting.jsx | Kenton1989/SecondLock | 06f718dd6d9b899b235563bfd9aad8726aff6004 | [
"MIT"
] | 2 | 2021-02-01T13:57:13.000Z | 2021-03-05T10:25:05.000Z | src/pages/options/sync-setting.jsx | Kenton1989/timelock-chrome | 06f718dd6d9b899b235563bfd9aad8726aff6004 | [
"MIT"
] | null | null | null | src/pages/options/sync-setting.jsx | Kenton1989/timelock-chrome | 06f718dd6d9b899b235563bfd9aad8726aff6004 | [
"MIT"
] | null | null | null | import React, { Component } from "react";
import { api } from "../../common/api";
import { $t, formatBytes } from "../../common/utility";
export default class SyncSetting extends Component {
constructor(props) {
super(props);
this.state = {
usedSyncSpace: 0,
};
this.updateUsedSyncSpace = this.updateUsedSyncSpace.bind(this);
this.updateUsedSyncSpace();
}
componentDidMount() {
api.storage.onChanged.addListener(this.updateUsedSyncSpace);
}
componentWillUnmount() {
api.storage.onChanged.removeListener(this.updateUsedSyncSpace);
}
render() {
let usedSpace = this.state.usedSyncSpace;
let totalSpace = api.storage.sync.QUOTA_BYTES;
let percentage = (usedSpace / totalSpace * 100).toFixed(2) + "%";
return (
<div>
<p>
{$t("cloudStorageUsed")} {formatBytes(usedSpace)}/
{formatBytes(totalSpace)} ({percentage})
</p>
</div>
);
}
async updateUsedSyncSpace() {
let bytes = await api.storage.sync.getBytesInUse(null);
this.setState({ usedSyncSpace: bytes });
}
}
| 23.382979 | 69 | 0.640582 | false | true | true | false |
d0047ad09d1abfe0cc22fc44ca47f81f8d505282 | 770 | jsx | JSX | react/Media/Media.jsx | drazik/cozy-ui | aa3b72628575358c5f06de95b0bc34b3571065ed | [
"MIT"
] | null | null | null | react/Media/Media.jsx | drazik/cozy-ui | aa3b72628575358c5f06de95b0bc34b3571065ed | [
"MIT"
] | null | null | null | react/Media/Media.jsx | drazik/cozy-ui | aa3b72628575358c5f06de95b0bc34b3571065ed | [
"MIT"
] | null | null | null | import React from 'react'
import styles from './Media.styl'
import cx from 'classnames'
/**
* Useful to align image/icon and content.
*/
export const Media = ({ children, className, align, ...rest }) => {
return (
<div
className={cx(
styles.media,
className,
align ? styles['media--' + align] : null
)}
{...rest}
>
{children}
</div>
)
}
export const Img = ({ children, className, style, ...rest }) => {
return (
<div className={cx(styles.img, className)} style={style} {...rest}>
{children}
</div>
)
}
export const Bd = ({ children, className, style, ...rest }) => {
return (
<div className={cx(styles.bd, className)} style={style} {...rest}>
{children}
</div>
)
}
| 20.263158 | 71 | 0.551948 | false | true | false | true |
d004825afcac2783b36163ccdf350bce9015bc9f | 3,970 | jsx | JSX | src/components/Modal/old/IssueModal.jsx | peerplays-network/peerplays-core-gui | e122f958277c230e08792206c0515ffd1f4df1a9 | [
"MIT"
] | 18 | 2019-06-28T00:53:44.000Z | 2020-12-14T19:54:37.000Z | src/components/Modal/old/IssueModal.jsx | peerplays-network/peerplays-core-gui | e122f958277c230e08792206c0515ffd1f4df1a9 | [
"MIT"
] | 67 | 2019-04-02T16:33:21.000Z | 2022-03-25T18:47:30.000Z | src/components/Modal/old/IssueModal.jsx | peerplays-network/peerplays-core-gui | e122f958277c230e08792206c0515ffd1f4df1a9 | [
"MIT"
] | 7 | 2018-12-09T14:36:24.000Z | 2022-02-05T07:05:05.000Z | import React from 'react';
import Translate from 'react-translate-component';
import ChainTypes from '../../Utility/ChainTypes';
import BindToChainState from '../../Utility/BindToChainState';
import utils from '../../../common/utils';
import counterpart from 'counterpart';
import AssetActions from 'actions/AssetActions';
import AccountSelector from '../../Account/AccountSelector';
import AmountSelector from '../../Utility/AmountSelector';
@BindToChainState()
export default class IssueModal extends React.Component {
static propTypes = {
asset_to_issue: ChainTypes.ChainAsset.isRequired
};
constructor(props) {
super(props);
this.state = {
amount: props.amount,
to: props.to,
to_id: null,
memo: null
};
}
onAmountChanged({amount}) {
this.setState({amount: amount});
}
onToAccountChanged(to) {
let state = to ? {to: to.get('name'), to_id: to.get('id')} : {to_id: null};
this.setState(state);
}
onToChanged(to) {
this.setState({to: to, to_id: null});
}
onSubmit() {
let {asset_to_issue} = this.props;
let precision = utils.get_asset_precision(asset_to_issue.get('precision'));
let amount = this.state.amount.replace(/,/g, '');
amount *= precision;
AssetActions.issueAsset(
this.state.to_id,
asset_to_issue.get('issuer'),
asset_to_issue.get('id'),
amount,
this.state.memo ? new Buffer(this.state.memo, 'utf-8') : this.state.memo
);
this.setState({
amount: null,
to_id: null,
memo: null
});
}
onMemoChanged(e) {
this.setState({memo: e.target.value});
}
render() {
let asset_to_issue = this.props.asset_to_issue.get('id');
let tabIndex = 1;
return (
<form className='grid-block vertical full-width-content'>
<div className='grid-container ' style={ {paddingTop: '2rem'} }>
{/* T O */}
<div className='content-block'>
<AccountSelector
label={ 'modal.issue.to' }
accountName={ this.state.to }
onAccountChanged={ this.onToAccountChanged.bind(this) }
onChange={ this.onToChanged.bind(this) }
account={ this.state.to }
tabIndex={ tabIndex++ }
/>
</div>
{/* A M O U N T */}
<div className='content-block'>
<AmountSelector
label='modal.issue.amount'
amount={ this.state.amount }
onChange={ this.onAmountChanged.bind(this) }
asset={ asset_to_issue }
assets={ [asset_to_issue] }
tabIndex={ tabIndex++ }
/>
</div>
{/* M E M O */}
<div className='content-block'>
<label>
<Translate component='span' content='transfer.memo'/>
(<Translate content='transfer.optional' />)
</label>
<textarea
rows='1'
value={ this.state.memo }
tabIndex={ tabIndex++ }
onChange={ this.onMemoChanged.bind(this) }
/>
</div>
<div className='content-block button-group'>
<input
type='submit'
className='button success'
onClick={ this.onSubmit.bind(this, this.state.to, this.state.amount ) }
value={ counterpart.translate('modal.issue.submit') }
tabIndex={ tabIndex++ }
/>
<div
className='button'
onClick={ this.props.onClose }
tabIndex={ tabIndex++ }
>
{counterpart.translate('cancel')}
</div>
</div>
</div>
</form>
);
}
}
| 30.305344 | 87 | 0.520655 | false | true | true | false |
d0048c350bd29994cac387a00aecfd1358a21b8a | 4,094 | jsx | JSX | src/components/App/index.jsx | GilbertMolina/Reacttr-Firebase | 2b316cea84d58920d0dd430461dcb579aced8122 | [
"MIT"
] | null | null | null | src/components/App/index.jsx | GilbertMolina/Reacttr-Firebase | 2b316cea84d58920d0dd430461dcb579aced8122 | [
"MIT"
] | null | null | null | src/components/App/index.jsx | GilbertMolina/Reacttr-Firebase | 2b316cea84d58920d0dd430461dcb579aced8122 | [
"MIT"
] | null | null | null | import React, { Component } from 'react'
import { HashRouter, Match } from 'react-router'
import Firebase from 'firebase'
import 'normalize-css'
import styles from './app.css'
import Header from '../Header'
import Main from '../Main'
import Profile from '../Profile'
import Login from '../Login'
class App extends Component {
constructor () {
super()
this.state = {
user: null
// The structure of the user object looks like this
// user: {
// displayName: 'Gilbert Molina',
// username: 'gmolinac',
// email: 'gmolinac@outlook.com',
// photoURL: 'https://avatars1.githubusercontent.com/u/5861707?s=400&u=9816344e8bfa441b15563f516475dbe7d643710a&v=4'
// }
}
this.handleOnAuthGitHub = this.handleOnAuthGitHub.bind(this)
this.handleOnAuthFacebook = this.handleOnAuthFacebook.bind(this)
this.handleLogout = this.handleLogout.bind(this)
}
componentWillMount () {
Firebase.auth().onAuthStateChanged(user => {
if (user) {
this.setState({
user: user
})
} else {
this.setState({
user: null
})
}
})
}
handleOnAuthGitHub () {
const provider = new Firebase.auth.GithubAuthProvider()
Firebase.auth().signInWithPopup(provider)
.then()
.catch(error => console.error(`Error: + ${error.code} (${error.message})`))
}
handleOnAuthFacebook () {
const provider = new Firebase.auth.FacebookAuthProvider();
Firebase.auth().signInWithPopup(provider)
.then()
.catch(error => console.error(`Error: + ${error.code} (${error.message})`))
}
handleLogout () {
Firebase.auth().signOut()
.then()
.catch((error) => console.error(`Error: + ${error.code} (${error.message})`))
}
render () {
return (
<HashRouter>
<div>
<Header
user={this.state.user}
onLogout={this.handleLogout}
/>
<div className="container">
<Match exactly pattern='/' render={() => {
if (!this.state.user) {
return (
<Login
onAuthGitHub={this.handleOnAuthGitHub}
onAuthFacebook={this.handleOnAuthFacebook}
/>
)
}
return (
<Main
user={this.state.user}
/>
)
}} />
<Match exactly pattern='/profile' render={() => {
if (!this.state.user) {
return (
<Login
onAuthGitHub={this.handleOnAuthGitHub}
onAuthFacebook={this.handleOnAuthFacebook}
/>
)
}
return (
<Profile
picture={this.state.user.photoURL}
username={this.state.user.email.split('@')[0]}
displayName={this.state.user.displayName}
emailAddress={this.state.user.email}
/>
)
}} />
</div>
</div>
</HashRouter>
)
}
}
export default App | 33.834711 | 136 | 0.404739 | false | true | true | false |
d004a04d6c0f23e2bae1e0be5530ddab97057420 | 4,209 | jsx | JSX | src/components/RegisterForm/RegisterForm.jsx | team-prstmw/HousesForSaleSearcher | 8051e1ef523e7e234287c80bff49c9716511c69b | [
"MIT"
] | null | null | null | src/components/RegisterForm/RegisterForm.jsx | team-prstmw/HousesForSaleSearcher | 8051e1ef523e7e234287c80bff49c9716511c69b | [
"MIT"
] | 11 | 2022-01-18T22:40:57.000Z | 2022-02-10T16:25:31.000Z | src/components/RegisterForm/RegisterForm.jsx | team-prstmw/HousesForSaleSearcher | 8051e1ef523e7e234287c80bff49c9716511c69b | [
"MIT"
] | null | null | null | import { yupResolver } from '@hookform/resolvers/yup';
import Visibility from '@mui/icons-material/Visibility';
import VisibilityOff from '@mui/icons-material/VisibilityOff';
import Box from '@mui/material/Box';
import Button from '@mui/material/Button';
import FormControl from '@mui/material/FormControl';
import FormHelperText from '@mui/material/FormHelperText';
import IconButton from '@mui/material/IconButton';
import InputAdornment from '@mui/material/InputAdornment';
import InputLabel from '@mui/material/InputLabel';
import OutlinedInput from '@mui/material/OutlinedInput';
import Stack from '@mui/material/Stack';
import TextField from '@mui/material/TextField';
import PropTypes from 'prop-types';
import { useContext, useState } from 'react';
import { useForm } from 'react-hook-form';
import styles from '/src/components/RegisterForm/RegisterForm.module.css';
import LoginContext from '/src/contexts/LoginContext';
import { registerSchema } from '/src/schemas/authSchemas';
import { SIGN_UP_URL } from '/src/URLs';
import { signInSignUp } from '/src/utils/auth';
function RegisterForm({ changeStateFn }) {
const login = useContext(LoginContext);
const [values, setValues] = useState({
password: '',
email: '',
showPassword: false,
});
const {
register,
handleSubmit,
formState: { errors },
} = useForm({
mode: 'onBlur',
resolver: yupResolver(registerSchema),
});
const handleClickShowPassword = () => {
setValues({
...values,
showPassword: !values.showPassword,
});
};
const handleMouseDownPassword = (event) => {
event.preventDefault();
};
const onSubmit = ({ email, password }) => {
signInSignUp(email, password, SIGN_UP_URL, changeStateFn, login.loggedIn, login.login, login.logout);
};
return (
<Box className={styles.registerForm__wrapper} component="form" onSubmit={handleSubmit(onSubmit)} noValidate>
<Stack spacing={4} className={styles.stack__wrapper}>
<TextField
id="outlined-textarea-name"
error={!!errors?.name}
helperText={errors?.name && errors?.name.message}
label="Name"
placeholder="Name"
autoComplete="Name"
required
className={styles.textField}
{...register('name')}
/>
<TextField
id="outlined-textarea-email"
error={!!errors?.email}
helperText={errors?.email && errors?.email.message}
label="E-mail"
placeholder="E-mail"
required
type="email"
autoComplete="email"
className={styles.textField}
{...register('email')}
/>
<FormControl variant="outlined">
<InputLabel required htmlFor="outlined-adornment-password" error={!!errors?.password}>
Password
</InputLabel>
<OutlinedInput
id="outlined-adornment-password"
type={values.showPassword ? 'text' : 'password'}
placeholder="Password"
error={!!errors?.password}
className={styles.textField}
endAdornment={
<InputAdornment position="end">
<IconButton
aria-label="toggle password visibility"
onClick={handleClickShowPassword}
onMouseDown={handleMouseDownPassword}
edge="end"
>
{values.showPassword ? <VisibilityOff /> : <Visibility />}
</IconButton>
</InputAdornment>
}
label="Password"
{...register('password')}
/>
{errors?.password ? (
<FormHelperText error>{errors?.password && errors?.password.message}</FormHelperText>
) : (
<FormHelperText id="component-helper-text">At least 6 characters</FormHelperText>
)}
</FormControl>
<Button color="primary" type="submit" variant="contained" className={styles.registerButton}>
REGISTER
</Button>
</Stack>
</Box>
);
}
RegisterForm.propTypes = {
changeStateFn: PropTypes.func.isRequired,
};
export default RegisterForm;
| 32.882813 | 112 | 0.620337 | false | true | false | true |
d004aef9c5ba1bac3726b0989f7b27d6f27e389a | 2,067 | jsx | JSX | src/containers/ArtistContainer.jsx | vahidd/spotify-react-redux | f147ab5227bd43c2ddb969a684318185f6e6a495 | [
"MIT"
] | 3 | 2017-12-09T14:39:44.000Z | 2019-01-03T11:37:42.000Z | src/containers/ArtistContainer.jsx | vahidd/spotify-react-redux | f147ab5227bd43c2ddb969a684318185f6e6a495 | [
"MIT"
] | null | null | null | src/containers/ArtistContainer.jsx | vahidd/spotify-react-redux | f147ab5227bd43c2ddb969a684318185f6e6a495 | [
"MIT"
] | 1 | 2019-06-26T08:54:31.000Z | 2019-06-26T08:54:31.000Z | import React from 'react';
import { connect } from 'react-redux';
import { withRouter } from 'react-router-dom';
import { fetchArtist, fetchSimilarArtists, fetchArtistAlbums } from 'Actions/ArtistActions';
import { fetchFollowingStatus, follow, unfollow } from 'Actions/UserActions';
import {
getArtist,
getIsFollowing,
getFollowActionFetchingStatus,
getSimilarArtists,
getArtistAlbums,
getArtistAppearsOn,
getArtistSingles
} from 'Src/store/selectors/CommonSelectors';
import Artist from 'Components/artist/Artist';
const mapStateToProps = () => {
return (state, props) => {
let artist = getArtist(state, props);
return {
artist,
similarArtists: getSimilarArtists(state, props),
isFollowed: getIsFollowing(state, props, 'artist'),
albums: getArtistAlbums(state, props) || {},
singles: getArtistSingles(state, props) || {},
appearsOn: getArtistAppearsOn(state, props) || {},
isFollowOrUnfollowing: getFollowActionFetchingStatus(state, 'artist')
};
};
};
const mapDispatchToProps = (dispatch, props) => {
return {
fetchArtist: () => {
dispatch(fetchFollowingStatus([props.match.params.id], 'artist'));
dispatch(fetchArtist(props.match.params.id));
},
fetchSimilarArtists: () => {
dispatch(fetchSimilarArtists(props.match.params.id));
},
fetchAlbum: (limit, offset) => {
dispatch(fetchArtistAlbums(props.match.params.id, 'album', limit, offset));
},
fetchSingle: (limit, offset) => {
dispatch(fetchArtistAlbums(props.match.params.id, 'single', limit, offset));
},
fetchAppearsOn: (limit, offset) => {
dispatch(fetchArtistAlbums(props.match.params.id, 'appears_on', limit, offset));
},
follow: () => {
dispatch(follow([props.match.params.id], 'artist'));
},
unfollow: () => {
dispatch(unfollow([props.match.params.id], 'artist'));
}
};
};
const ArtistContainer = props => <Artist {...props} />;
export default withRouter(connect(mapStateToProps, mapDispatchToProps)(ArtistContainer));
| 32.809524 | 92 | 0.67731 | false | true | false | true |
d004c19d46d69b64a77acf672d67f904f49d470f | 210 | jsx | JSX | front/src/components/game/Try.jsx | kkoon9/Full-Stack-With-javascript | 86946c3572b5fbc39f91aa55daa20ee2468d1eb1 | [
"MIT"
] | null | null | null | front/src/components/game/Try.jsx | kkoon9/Full-Stack-With-javascript | 86946c3572b5fbc39f91aa55daa20ee2468d1eb1 | [
"MIT"
] | 2 | 2021-04-04T06:20:43.000Z | 2021-10-06T20:01:45.000Z | front/src/components/game/Try.jsx | kkoon9/Full-Stack-With-javascript | 86946c3572b5fbc39f91aa55daa20ee2468d1eb1 | [
"MIT"
] | null | null | null | import React, { Fragment } from 'react';
const Try = ({ tryInfo }) => {
return (
<Fragment>
<div>
{tryInfo.try} : {tryInfo.result}
</div>
</Fragment>
);
};
export default Try;
| 15 | 40 | 0.52381 | false | true | false | true |