Skip to content

Enable linter in demo #414

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 31, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,3 @@
/**/coverage
/**/vendor.js
/**/*.config.js
/**/doc-components/
/**/examples-texts/
5 changes: 5 additions & 0 deletions packages/react-renderer-demo/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"rules": {
"no-console": "off"
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import React from 'react';
import Typography from '@material-ui/core/Typography';

export default () =>
<Typography>
This is a custom component.
</Typography>;
export default () => <Typography>This is a custom component.</Typography>;
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
import React from 'react';
import Pf4 from '@docs/doc-components/pf4-dual-list.md';
import PropTypes from 'prop-types';

export default ({ activeMapper }) => activeMapper === 'pf4' ? <Pf4 /> : 'Not implemented yet';
const DualListSelect = ({ activeMapper }) => (activeMapper === 'pf4' ? <Pf4 /> : 'Not implemented yet');

DualListSelect.propTypes = {
activeMapper: PropTypes.string
};

export default DualListSelect;
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
import React from 'react';
import Typography from '@material-ui/core/Typography';

import PropTypes from 'prop-types';

export const docsLinks = {
mui: 'https://material-ui.com/api/',
pf4: 'http://patternfly-react.surge.sh/patternfly-4/components/',
pf3: 'http://patternfly-react.surge.sh/patternfly-3/index.html',
pf3: 'http://patternfly-react.surge.sh/patternfly-3/index.html'
};

export default ({ activeMapper, component }) => {
const GenericMuiComponent = ({ activeMapper, component }) => {
const originalComponent = component;
if (activeMapper === 'pf4'){
switch (component){
if (activeMapper === 'pf4') {
switch (component) {
case 'date-picker':
component = 'textinput';
break;
Expand All @@ -32,9 +34,11 @@ export default ({ activeMapper, component }) => {
case 'checkbox-multiple':
component = 'checkbox';
break;
default:
break;
}
} else if (activeMapper === 'mui'){
switch (component){
} else if (activeMapper === 'mui') {
switch (component) {
case 'date-picker':
component = 'text-field';
break;
Expand All @@ -53,22 +57,33 @@ export default ({ activeMapper, component }) => {
case 'checkbox-multiple':
component = 'checkbox';
break;
default:
break;
}
}

return <React.Fragment>
<Typography variant='body1' gutterBottom>
This component also accepts all other original props, please see <a
href={ `${docsLinks[activeMapper]}${ activeMapper === 'pf4' || activeMapper === 'mui' ? component : '' }` }>
here</a>!
</Typography>

{ activeMapper === 'mui' ?
(originalComponent === 'date-picker' || originalComponent === 'time-picker') &&
<Typography variant='body1'>
This component also use API from material-ui-pickers, please see <a
href={ `https://material-ui-pickers.firebaseapp.com/api/${originalComponent.replace('-', '')}` }>
here</a>!
return (
<React.Fragment>
<Typography variant="body1" gutterBottom>
This component also accepts all other original props, please see{' '}
<a href={`${docsLinks[activeMapper]}${activeMapper === 'pf4' || activeMapper === 'mui' ? component : ''}`}>here</a>!
</Typography>
: '' }
</React.Fragment>;};

{activeMapper === 'mui'
? (originalComponent === 'date-picker' || originalComponent === 'time-picker') && (
<Typography variant="body1">
This component also use API from material-ui-pickers, please see{' '}
<a href={`https://material-ui-pickers.firebaseapp.com/api/${originalComponent.replace('-', '')}`}>here</a>!
</Typography>
)
: ''}
</React.Fragment>
);
};

GenericMuiComponent.propTypes = {
activeMapper: PropTypes.string,
component: PropTypes.string
};

export default GenericMuiComponent;
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,12 @@ import React from 'react';
import GenericComponentText from './generic-mui-component';
import Pf3Select from '@docs/doc-components/pf3-select.md';
import Pf4Select from '@docs/doc-components/pf4-select.md';
import PropTypes from 'prop-types';

export default ({ activeMapper }) => activeMapper === 'pf3' ? <Pf3Select /> : activeMapper === 'pf4' ? <Pf4Select /> : <GenericComponentText />;
const Select = ({ activeMapper }) => (activeMapper === 'pf3' ? <Pf3Select /> : activeMapper === 'pf4' ? <Pf4Select /> : <GenericComponentText />);

Select.propTypes = {
activeMapper: PropTypes.string
};

export default Select;
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,35 @@ import React, { Fragment } from 'react';
import Typography from '@material-ui/core/Typography';
import { docsLinks } from './generic-mui-component';

export default ({ activeMapper }) =>
import PropTypes from 'prop-types';

const Tabs = ({ activeMapper }) => (
<Fragment>
{ activeMapper === 'pf4' &&
<Typography variant='body1' gutterBottom>
This component also accepts all other original props, please see <a
href={ `${docsLinks[activeMapper]}/tabs` }>
here</a>!
</Typography> }
{activeMapper === 'pf4' && (
<Typography variant="body1" gutterBottom>
This component also accepts all other original props, please see <a href={`${docsLinks[activeMapper]}/tabs`}>here</a>!
</Typography>
)}
<Typography variant="body1">
For using this component, you have to append TabItem component (containing form fields) to fields property.
</Typography>
<Typography gutterBottom>
Component constant
For using this component, you have to append TabItem component (containing form fields) to fields property.
</Typography>
<Typography gutterBottom>Component constant</Typography>
<pre>TAB_ITEM</pre> <Typography variant="body1">as an import from componentTypes</Typography>
<pre>tab-item</pre> <Typography variant="body1">as a string</Typography>
{ activeMapper === 'pf3' &&
(
{activeMapper === 'pf3' && (
<Fragment>
<Typography gutterBottom>
Validation
</Typography>
<Typography gutterBottom>Validation</Typography>
<Typography variant="body1">Because of schema flexibility there is no simple and efficient way to signal invalid tab content.</Typography>
<Typography variant="body1">
If you want to add some visual feedback for this case, please specify field names to <strong>validateFields</strong> attribute.
</Typography>
</Fragment>
) }
</Fragment>;
)}
</Fragment>
);

Tabs.propTypes = {
activeMapper: PropTypes.string
};

export default Tabs;
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,12 @@ import Wizard from '@docs/doc-components/wizard.md';
import Pf3Wizard from '@docs/doc-components/pf3-wizard.md';
import Pf4Wizard from '@docs/doc-components/pf4-wizard.md';

export default ({ activeMapper }) => activeMapper === 'pf3' ? <Pf3Wizard /> : activeMapper === 'pf4' ? <Pf4Wizard /> : <Wizard />;
import PropTypes from 'prop-types';

const DocWizard = ({ activeMapper }) => (activeMapper === 'pf3' ? <Pf3Wizard /> : activeMapper === 'pf4' ? <Pf4Wizard /> : <Wizard />);

DocWizard.propTypes = {
activeMapper: PropTypes.string
};

export default DocWizard;
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,23 @@ const FormTemplate = ({ formFields, schema }) => {
<Button disabled={pristine} style={{ marginRight: 8 }} onClick={onReset} variant="contained">
Reset
</Button>
<Button variant="contained" onClick={onCancel}>Cancel</Button>
<Button variant="contained" onClick={onCancel}>
Cancel
</Button>
</div>
)}
</FormSpy>
</Form>
);
};

const asyncSubmit = (values, api) => new Promise((resolve) => setTimeout(() => {
console.log('FormValues', values);
resolve('Yay');
}, 1500));
const asyncSubmit = (values, api) =>
new Promise((resolve) =>
setTimeout(() => {
console.log('FormValues', values);
resolve('Yay');
}, 1500)
);

const FormControls = () => (
<div className="pf4">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ const schema = {
const GetStartedForm = () => (
<div className="pf4">
<FormRender
componentMapper={ componentMapper }
FormTemplate={ FormTemplate }
schema={ schema }
onSubmit={ console.log }
onCancel={ () => console.log('Cancel action') }
componentMapper={componentMapper}
FormTemplate={FormTemplate}
schema={schema}
onSubmit={console.log}
onCancel={() => console.log('Cancel action')}
canReset
/>
</div>
Expand Down