Skip to content

fix(pf4): Add customization api to plain text #697

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 1 commit into from
Aug 11, 2020

Conversation

Hyperkid123
Copy link
Member

No description provided.

@Hyperkid123 Hyperkid123 added the bug Something isn't working label Aug 10, 2020
@Hyperkid123 Hyperkid123 requested a review from rvsia August 10, 2020 13:33
@@ -4,11 +4,11 @@ import PropTypes from 'prop-types';
import { TextContent, Text } from '@patternfly/react-core';
import validTextFields from '@data-driven-forms/common/src/utils/valid-text-fields';

const PlainText = ({ label, name, variant }) => (
<TextContent>
const PlainText = ({ label, name, variant, TextProps, TextContentProps }) => (
Copy link
Contributor

Choose a reason for hiding this comment

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

I think TextProps should be changed to ...rest to make it consistent with the way we are spreading props in all other components. (...rest should be always spread to the main component.)

Just catch component props before you do it.


export interface PlainTextProps {
label: ReactNode;
name: string;
variant?: 'p'|'span'|'strong'|'b'|'cite'|'caption'|'code'|'em'|'i'|'h1'|'h2'|'h3'|'h4'|'h5'|'h6'|'h6'|'div'|'label'|'pre'|'q'|'samp'|'small'|'sub'|'sup';
TextProps: TextProps,
TextContentProps: TextContentProps,
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we should add it do docs.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah right its not generated yet.

@codecov
Copy link

codecov bot commented Aug 10, 2020

Codecov Report

Merging #697 into master will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #697   +/-   ##
=======================================
  Coverage   92.71%   92.71%           
=======================================
  Files         212      212           
  Lines        3308     3308           
  Branches     1074     1074           
=======================================
  Hits         3067     3067           
  Misses        241      241           
Impacted Files Coverage Δ
...kages/pf4-component-mapper/src/files/plain-text.js 85.71% <100.00%> (ø)

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 51e913c...7d2da4c. Read the comment docs.

@Hyperkid123 Hyperkid123 force-pushed the add-pf4-customization-api-plain-text branch from 11fada0 to 5c2ce24 Compare August 10, 2020 13:57
@@ -4,11 +4,11 @@ import PropTypes from 'prop-types';
import { TextContent, Text } from '@patternfly/react-core';
import validTextFields from '@data-driven-forms/common/src/utils/valid-text-fields';

const PlainText = ({ label, name, variant }) => (
<TextContent>
const PlainText = ({ label, name, variant, TextContentProps, ...rest }) => (
Copy link
Contributor

Choose a reason for hiding this comment

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

please catch 'component' prop coming from renderer, it could cause issues.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think this actually is closer to the current way of customization in our other mappers (stuff like required, disabled, etc.). Plus the component prop is always caught by the use field hook. And you can't really use the component key in the schema.

Copy link
Contributor

@rvsia rvsia Aug 11, 2020

Choose a reason for hiding this comment

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

The plaintext component will receive component="plain_text" and then this is passed via rest to the PF Text component. There is no useFieldApi hook here to catch it.

Copy link
Member Author

@Hyperkid123 Hyperkid123 Aug 11, 2020

Choose a reason for hiding this comment

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

we do not catch component in useFIeldApi!?

Yup its not interactive field 😆

Copy link
Contributor

Choose a reason for hiding this comment

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

We do, but plain text is not using it. It's not a field, it's just a component.

@@ -19,7 +19,8 @@ const PlainText = ({ label, name, variant }) => (
PlainText.propTypes = {
variant: PropTypes.oneOf(validTextFields),
Copy link
Contributor

Choose a reason for hiding this comment

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

We should mention that component PF prop is mapped to variant prop in Docs.

@Hyperkid123 Hyperkid123 force-pushed the add-pf4-customization-api-plain-text branch from 5c2ce24 to d380c31 Compare August 11, 2020 06:55
@Hyperkid123 Hyperkid123 force-pushed the add-pf4-customization-api-plain-text branch from d380c31 to 7d2da4c Compare August 11, 2020 07:11
@rvsia rvsia merged commit a1b7d0e into master Aug 11, 2020
@Hyperkid123 Hyperkid123 deleted the add-pf4-customization-api-plain-text branch August 11, 2020 09:53
@Hyperkid123
Copy link
Member Author

🎉 This PR is included in version 2.8.9 🎉

The release is available on

Demo can be found here!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working released
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants