Skip to content

Add mapper generator #494

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
May 18, 2020
Merged

Conversation

rvsia
Copy link
Contributor

@rvsia rvsia commented May 15, 2020

When user runs

yarn generate-template

It will ask him for a mapper name and it will automatically create the project folder.

generator

@rvsia rvsia added the enhancement New feature or request label May 15, 2020
@rvsia rvsia requested a review from Hyperkid123 May 15, 2020 14:11
@rvsia rvsia force-pushed the addMapperGenerator branch from 883787e to 9ffa298 Compare May 15, 2020 14:12
@codecov
Copy link

codecov bot commented May 15, 2020

Codecov Report

Merging #494 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #494   +/-   ##
=======================================
  Coverage   89.78%   89.78%           
=======================================
  Files         144      144           
  Lines        2437     2437           
  Branches      813      813           
=======================================
  Hits         2188     2188           
  Misses        249      249           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 35b9d03...cfa98f5. Read the comment docs.

@rvsia rvsia linked an issue May 15, 2020 that may be closed by this pull request
Copy link
Member

@Hyperkid123 Hyperkid123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. I think we should finish these points:

  1. remove any PF(ar any other component library) references
  2. Instead of returning strings with component names, generate simple HTML inputs connected to the form API. Sometimes it might not be clear to how to use the onChange function
  3. Include common packages into examples. We would not want to implement them again in each mapper

@@ -87,6 +87,16 @@ All packages are releasing together and they share the version number.

If your changes influence API or add new features, you should describe these new options in the `demo` repository. Thanks!

# Generating a mapper
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would the template word. it might seem that we are able to just generate fully featured component mapper.

type: 'input',
message: 'Project name (i.e.: pf4, pf3, mui, blueprint, etc.):',
validate(input) {
if (/^([A-Za-z\d])+$/.test(input)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can allow a bit more characters. -, _ would be a good addition

1. Update styles in "packages/${componentmapper}-component-mapper/demo/index.html"
2. Add dependencies in "packages/${componentmapper}-component-mapper/package.json",
3. Mark the dependencies as globals/external in "packages/${componentmapper}-component-mapper/rollup.config.js"
4. Mark the dependencies as externals in "packages/${componentmapper}-component-mapper/config/webpack.config.js"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This step is not necessary. Webpack is only used for dev server.

@@ -0,0 +1,179 @@
[![npm version](https://badge.fury.io/js/%40data-driven-forms%2Fpf4-component-mapper.svg)](https://badge.fury.io/js/%40data-driven-forms%2Fpf4-component-mapper)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PF4 reference

@@ -0,0 +1,1949 @@
/* eslint-disable camelcase */
const input = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's necessary to copy this schema. I think we can even remove it completely

import React from 'react';
import PropTypes from 'prop-types';

const FieldArray = () => 'FieldArray';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here I would show of the common package.

children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node])
};

export const Description = ({ children }) => <span>{children}</span>;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<p></p> span is inline

children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node])
};

export const Form = ({ children, ...props }) => <form {...props}>{children}</form>;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

noValidate is missing. The form will prioritize HTML validation over ours.

import React from 'react';
import PropTypes from 'prop-types';

const Radio = () => 'Radio';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again we can use some basic implementation to showcase what props and how to use them in order to get this working. Mainly the onChange is important

import React from 'react';
import PropTypes from 'prop-types';

const Select = () => 'Select';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

^^

@rvsia rvsia force-pushed the addMapperGenerator branch 2 times, most recently from 2179e12 to 00b9861 Compare May 18, 2020 10:22
@rvsia rvsia force-pushed the addMapperGenerator branch from 00b9861 to ea36b35 Compare May 18, 2020 10:25
@rvsia
Copy link
Contributor Author

rvsia commented May 18, 2020

@Hyperkid123 changed, it creates a fully functional mapper now. All components should work.

return (
<React.Fragment>
<label htmlFor={name}>{label}</label>
<input {...input} type="checkbox" disabled={isDisabled}/>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you are missing id={name} for the label to work

@rvsia rvsia force-pushed the addMapperGenerator branch from 0c28d74 to cfa98f5 Compare May 18, 2020 14:30
@Hyperkid123 Hyperkid123 merged commit 00ff550 into data-driven-forms:master May 18, 2020
@Hyperkid123
Copy link
Member

🎉 This PR is included in version 2.4.0 🎉

The release is available on

Demo can be found here!

@rvsia rvsia deleted the addMapperGenerator branch June 4, 2020 14:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request released
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make generator for component mappers
2 participants