Skip to content

Commit a33e5a7

Browse files
author
Ruben van Leeuwen
committed
1904: Mark fields as required. Mark them red on errors
1 parent 0291813 commit a33e5a7

File tree

3 files changed

+37
-3
lines changed

3 files changed

+37
-3
lines changed

packages/orchestrator-ui-components/src/components/WfoForms/formFields/commonStyles.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@ export const getCommonFormFieldStyles = ({ theme }: WfoTheme) => {
2121
},
2222
});
2323

24+
const errorStyle = css({
25+
color: theme.colors.dangerText,
26+
});
2427
return {
28+
errorStyle,
2529
formRowStyle,
2630
};
2731
};
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import React from 'react';
2+
3+
import { usePydanticFormContext } from 'pydantic-forms';
4+
5+
import { css } from '@emotion/react';
6+
7+
const headerStyling = css`
8+
padding: 20px 0;
9+
font-size: larger;
10+
font-weight: bold;
11+
margin-bottom: 15px;
12+
`;
13+
14+
export const Header = () => {
15+
const { pydanticFormSchema } = usePydanticFormContext();
16+
17+
return <h3 css={headerStyling}>{pydanticFormSchema?.title}</h3>;
18+
};

packages/orchestrator-ui-components/src/components/WfoPydanticForm/Row.tsx

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,31 @@ export const Row: RowRenderComponent = ({
1212
description,
1313
error,
1414
isInvalid,
15+
required,
1516
children,
1617
}) => {
17-
const { formRowStyle } = useWithOrchestratorTheme(getCommonFormFieldStyles);
18+
const { formRowStyle, errorStyle } = useWithOrchestratorTheme(
19+
getCommonFormFieldStyles,
20+
);
21+
1822
return (
1923
<EuiFormRow
2024
css={formRowStyle}
21-
label={title}
25+
label={
26+
title ? (
27+
<EuiText size="m">
28+
<div css={error && errorStyle}>
29+
{title} {required && '*'}
30+
</div>
31+
</EuiText>
32+
) : undefined
33+
}
2234
labelAppend={<EuiText size="m">{description}</EuiText>}
2335
error={error}
2436
isInvalid={isInvalid}
2537
fullWidth
2638
>
27-
<div>{children}</div>
39+
<>{children}</>
2840
</EuiFormRow>
2941
);
3042
};

0 commit comments

Comments
 (0)