Skip to content

Commit 7d2da4c

Browse files
committed
fix(pf4): Add customization api to plain text
1 parent 51e913c commit 7d2da4c

File tree

3 files changed

+23
-5
lines changed

3 files changed

+23
-5
lines changed
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
import { ReactNode } from "react";
2+
import { TextProps, TextContentProps } from "@patternfly/react-core";
23

3-
export interface PlainTextProps {
4+
interface InternalPlainTextProps {
45
label: ReactNode;
56
name: string;
67
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';
8+
TextContentProps: TextContentProps,
79
}
810

11+
export type PlainTextProps = InternalPlainTextProps & TextProps;
12+
913
declare const PlainText: React.ComponentType<PlainTextProps>;
1014

1115
export default PlainText;

packages/pf4-component-mapper/src/files/plain-text.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ import PropTypes from 'prop-types';
44
import { TextContent, Text } from '@patternfly/react-core';
55
import validTextFields from '@data-driven-forms/common/src/utils/valid-text-fields';
66

7-
const PlainText = ({ label, name, variant }) => (
8-
<TextContent>
7+
const PlainText = ({ component, label, name, variant, TextContentProps, ...rest }) => (
8+
<TextContent {...TextContentProps}>
99
{typeof label === 'string'
1010
? label.split('\n').map((paragraph, index) => (
11-
<Text component={variant} key={`${name}-${index}`}>
11+
<Text component={variant} {...rest} key={`${name}-${index}`}>
1212
{paragraph}
1313
</Text>
1414
))
@@ -19,7 +19,9 @@ const PlainText = ({ label, name, variant }) => (
1919
PlainText.propTypes = {
2020
variant: PropTypes.oneOf(validTextFields),
2121
label: PropTypes.node.isRequired,
22-
name: PropTypes.string.isRequired
22+
name: PropTypes.string.isRequired,
23+
TextContentProps: PropTypes.object,
24+
component: PropTypes.string
2325
};
2426

2527
PlainText.defaultProps = {
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
This a custom component with a custom design. Things can be changed, after official PF4 release.
2+
3+
**Props**
4+
5+
Plain text accepts all props defined in [PF4 Text component decoumentation](https://www.patternfly.org/v4/documentation/react/components/text#props).
6+
7+
**Due to a name conflict the Text component prop is mapped to variant key in schema.**
8+
9+
|Props|Type|Default|Description|
10+
|-----|----|-------|-----------|
11+
|label|string/node||Rendered text|
12+
|TextContentProps|object||https://www.patternfly.org/v4/documentation/react/components/text#props|

0 commit comments

Comments
 (0)