-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Form): Extract FieldWrapper field and increase text size
- Loading branch information
Showing
14 changed files
with
178 additions
and
212 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
packages/ui/src/components/Visualization/Canvas/FormV2/KaotoForm.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
.kaoto-form { | ||
&__label { | ||
--pf-v6-c-form__label--FontSize: --pf-t--global--font--size--body--md; | ||
--pf-v6-c-form__label-required--FontSize: --pf-t--global--font--size--body--lg; | ||
} | ||
|
||
/* stylelint-disable-next-line selector-class-pattern */ | ||
.pf-v6-c-text-input-group__text-input::placeholder { | ||
font-style: italic; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
...ges/ui/src/components/Visualization/Canvas/FormV2/fields/ArrayField/ArrayFieldWrapper.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { | ||
Card, | ||
CardBody, | ||
CardHeader, | ||
CardHeaderActionsObject, | ||
CardTitle, | ||
FormGroupLabelHelp, | ||
Popover, | ||
} from '@patternfly/react-core'; | ||
import { FunctionComponent, PropsWithChildren, ReactNode, useMemo } from 'react'; | ||
import { FieldProps } from '../../typings'; | ||
|
||
interface FieldWrapperProps extends FieldProps { | ||
type: 'array' | 'object'; | ||
title?: string; | ||
description?: string; | ||
defaultValue?: unknown; | ||
actions?: ReactNode; | ||
} | ||
|
||
export const ArrayFieldWrapper: FunctionComponent<PropsWithChildren<FieldWrapperProps>> = ({ | ||
propName, | ||
type, | ||
title: propsTitle, | ||
description, | ||
defaultValue, | ||
actions, | ||
children, | ||
}) => { | ||
const title = propsTitle ?? propName; | ||
const id = `${title}-popover`; | ||
|
||
const cardActions: CardHeaderActionsObject = useMemo(() => ({ actions, hasNoOffset: false }), [actions]); | ||
|
||
return ( | ||
<Card> | ||
<CardHeader actions={cardActions}> | ||
<CardTitle> | ||
{title}{' '} | ||
<Popover | ||
id={id} | ||
headerContent={ | ||
<p> | ||
{title} {`<${type}>`} | ||
</p> | ||
} | ||
bodyContent={<p>{description}</p>} | ||
footerContent={<p>Default: {defaultValue?.toString() ?? 'no default value'}</p>} | ||
triggerAction="hover" | ||
withFocusTrap={false} | ||
> | ||
<FormGroupLabelHelp aria-label={`More info for ${title} field`} /> | ||
</Popover> | ||
</CardTitle> | ||
</CardHeader> | ||
|
||
{children && <CardBody className="pf-v6-c-form kaoto-form__label">{children}</CardBody>} | ||
</Card> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 31 additions & 43 deletions
74
packages/ui/src/components/Visualization/Canvas/FormV2/fields/FieldWrapper.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,48 @@ | ||
import { | ||
Card, | ||
CardBody, | ||
CardHeader, | ||
CardHeaderActionsObject, | ||
CardTitle, | ||
FormGroupLabelHelp, | ||
Popover, | ||
} from '@patternfly/react-core'; | ||
import { FunctionComponent, PropsWithChildren, ReactNode, useMemo } from 'react'; | ||
import { FormGroup, FormGroupLabelHelp, Popover } from '@patternfly/react-core'; | ||
import { FunctionComponent, PropsWithChildren, ReactNode } from 'react'; | ||
import { FieldProps } from '../typings'; | ||
|
||
interface FieldWrapperProps extends FieldProps { | ||
type: string; | ||
title?: string; | ||
title?: ReactNode; | ||
description?: string; | ||
defaultValue?: unknown; | ||
actions?: ReactNode; | ||
defaultValue?: string; | ||
} | ||
|
||
export const FieldWrapper: FunctionComponent<PropsWithChildren<FieldWrapperProps>> = ({ | ||
propName, | ||
required, | ||
title, | ||
type, | ||
title: propsTitle, | ||
description, | ||
defaultValue, | ||
actions, | ||
defaultValue = 'no default value', | ||
children, | ||
}) => { | ||
const title = propsTitle ?? propName; | ||
const id = `${title}-popover`; | ||
|
||
const cardActions: CardHeaderActionsObject = useMemo(() => ({ actions, hasNoOffset: false }), [actions]); | ||
const id = `${propName}-popover`; | ||
|
||
return ( | ||
<Card> | ||
<CardHeader actions={cardActions}> | ||
<CardTitle> | ||
{title}{' '} | ||
<Popover | ||
id={id} | ||
headerContent={ | ||
<p> | ||
{title} {`<${type}>`} | ||
</p> | ||
} | ||
bodyContent={<p>{description}</p>} | ||
footerContent={<p>Default: {defaultValue?.toString() ?? 'no default value'}</p>} | ||
triggerAction="hover" | ||
withFocusTrap={false} | ||
> | ||
<FormGroupLabelHelp aria-label={`More info for ${title} field`} /> | ||
</Popover> | ||
</CardTitle> | ||
</CardHeader> | ||
|
||
{children && <CardBody className="pf-v6-c-form">{children}</CardBody>} | ||
</Card> | ||
<FormGroup | ||
fieldId={propName} | ||
label={title ?? propName} | ||
isRequired={required} | ||
labelHelp={ | ||
<Popover | ||
id={id} | ||
headerContent={ | ||
<p> | ||
{title} {`<${type}>`} | ||
</p> | ||
} | ||
bodyContent={<p>{description}</p>} | ||
footerContent={<p>Default: {defaultValue}</p>} | ||
triggerAction="hover" | ||
withFocusTrap={false} | ||
> | ||
<FormGroupLabelHelp aria-label={`More info for ${title} field`} /> | ||
</Popover> | ||
} | ||
> | ||
{children} | ||
</FormGroup> | ||
); | ||
}; |
8 changes: 4 additions & 4 deletions
8
...ation/Canvas/FormV2/fields/AnyOfField.tsx → .../FormV2/fields/ObjectField/AnyOfField.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.