generated from RedHatInsights/frontend-starter-app
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
36c6c77
commit 7a573a7
Showing
17 changed files
with
1,068 additions
and
480 deletions.
There are no files selected for viewing
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,12 @@ | ||
.rc-header { | ||
background-color: var(--pf-v5-global--BackgroundColor--dark-300); | ||
color: var(--pf-v5-global--Color--light-100); | ||
} | ||
|
||
.rc-header a { | ||
color: var(--pf-v5-global--link--Color--light); | ||
} | ||
|
||
.rc-header a:hover { | ||
color: var(--pf-v5-global--link--Color--light--hover); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import { | ||
FormGroup, | ||
FormHelperText, | ||
HelperText, | ||
HelperTextItem, | ||
NumberInput, | ||
} from '@patternfly/react-core'; | ||
import React, { useId } from 'react'; | ||
import { | ||
UseFieldApiConfig, | ||
useFieldApi, | ||
} from '@data-driven-forms/react-form-renderer'; | ||
import ExclamationCircleIcon from '@patternfly/react-icons/dist/dynamic/icons/exclamation-circle-icon'; | ||
|
||
const DdfNumberInput = (props: UseFieldApiConfig) => { | ||
const { input, meta, ...rest } = useFieldApi(props); | ||
const reactId = useId(); | ||
const effectiveId = rest.id || reactId; | ||
|
||
const showInvalid = meta.touched && meta.invalid; | ||
|
||
const focusProps = { | ||
onFocus: input.onFocus, | ||
onBlur: input.onBlur, | ||
}; | ||
|
||
return ( | ||
<FormGroup | ||
label={rest.label} | ||
isRequired={rest.isRequired} | ||
fieldId={effectiveId} | ||
> | ||
<NumberInput | ||
id={effectiveId} | ||
inputName={input.name} | ||
value={input.value} | ||
validated={showInvalid ? 'error' : 'default'} | ||
min={rest.minValue} | ||
max={rest.maxValue} | ||
unit={rest.unit} | ||
onPlus={() => input.onChange((input.value ?? 0) + 1)} | ||
onMinus={() => input.onChange((input.value ?? 0) - 1)} | ||
onChange={(e) => input.onChange(e.currentTarget.valueAsNumber)} | ||
{...focusProps} | ||
plusBtnProps={focusProps} | ||
minusBtnProps={focusProps} | ||
/> | ||
|
||
{showInvalid ? ( | ||
<FormHelperText> | ||
<HelperText> | ||
<HelperTextItem variant={'error'} icon={<ExclamationCircleIcon />}> | ||
{meta.error} | ||
</HelperTextItem> | ||
</HelperText> | ||
</FormHelperText> | ||
) : null} | ||
</FormGroup> | ||
); | ||
}; | ||
|
||
export default DdfNumberInput; |
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,26 @@ | ||
import React, { ButtonHTMLAttributes, ReactNode } from 'react'; | ||
|
||
const SimpleButton = ({ | ||
type = 'button', | ||
children, | ||
icon, | ||
...rest | ||
}: ButtonHTMLAttributes<HTMLButtonElement> & { | ||
icon?: ReactNode; | ||
}) => { | ||
return ( | ||
<button | ||
{...rest} | ||
type={type} | ||
className={`pf-v5-u-background-color-200 ${rest.className ?? ''}`} | ||
style={{ border: 'none', ...(rest.style ?? {}) }} | ||
> | ||
<span className={icon !== undefined ? 'pf-v5-u-mr-sm' : ''}> | ||
{children} | ||
</span> | ||
{icon} | ||
</button> | ||
); | ||
}; | ||
|
||
export default SimpleButton; |
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,14 @@ | ||
.lr-string-array { | ||
display: grid; | ||
grid-template-columns: [label-start] auto [label-end value-start] 1fr [value-end remove-start] auto [remove-end]; | ||
|
||
.lr-string-array-label { | ||
grid-column-start: label-start; | ||
grid-column-end: label-end; | ||
} | ||
|
||
.lr-string-array-value { | ||
grid-column-start: value-start; | ||
grid-column-end: value-end; | ||
} | ||
} |
Oops, something went wrong.