|
1 | 1 | import React from 'react';
|
2 | 2 |
|
| 3 | +import { capitalize } from 'lodash'; |
3 | 4 | import type { PydanticFormElement } from 'pydantic-forms';
|
4 | 5 |
|
5 | 6 | import { EuiFlexItem, EuiFormRow, EuiText } from '@elastic/eui';
|
6 |
| -import { tint } from '@elastic/eui'; |
7 |
| -import { css } from '@emotion/react'; |
8 | 7 |
|
9 |
| -import { getCommonFormFieldStyles } from '@/components'; |
10 |
| -import { WfoTheme, useWithOrchestratorTheme } from '@/hooks'; |
11 |
| - |
12 |
| -export const getStyles = ({ theme }: WfoTheme) => { |
13 |
| - const toShadeColor = (color: string) => tint(color, 0.9); |
14 |
| - |
15 |
| - const summaryFieldStyle = css({ |
16 |
| - 'div.emailMessage': { |
17 |
| - td: { |
18 |
| - color: theme.colors.text, |
19 |
| - }, |
20 |
| - p: { |
21 |
| - color: theme.colors.text, |
22 |
| - }, |
23 |
| - html: { |
24 |
| - marginLeft: '-10px', |
25 |
| - }, |
26 |
| - }, |
27 |
| - 'section.table-summary': { |
28 |
| - marginTop: '20px', |
29 |
| - width: '100%', |
30 |
| - td: { |
31 |
| - padding: '10px', |
32 |
| - verticalAlign: 'top', |
33 |
| - }, |
34 |
| - 'td:not(:first-child):not(:last-child)': { |
35 |
| - borderRight: `1px solid ${theme.colors.lightestShade}`, |
36 |
| - }, |
37 |
| - '.label': { |
38 |
| - fontWeight: 'bold', |
39 |
| - color: theme.colors.lightestShade, |
40 |
| - backgroundColor: theme.colors.primary, |
41 |
| - borderRight: `2px solid ${theme.colors.lightestShade}`, |
42 |
| - borderBottom: `1px solid ${theme.colors.lightestShade}`, |
43 |
| - }, |
44 |
| - '.value': { |
45 |
| - backgroundColor: toShadeColor(theme.colors.primary), |
46 |
| - borderBottom: `1px solid ${theme.colors.lightestShade}`, |
47 |
| - }, |
48 |
| - }, |
49 |
| - }); |
50 |
| - return { |
51 |
| - summaryFieldStyle: summaryFieldStyle, |
52 |
| - }; |
53 |
| -}; |
| 8 | +import { getCommonFormFieldStyles, summaryFieldStyles } from '@/components'; |
| 9 | +import { useWithOrchestratorTheme } from '@/hooks'; |
| 10 | +import { snakeToHuman } from '@/utils'; |
54 | 11 |
|
55 | 12 | export const WfoSummary: PydanticFormElement = ({ pydanticFormField }) => {
|
56 |
| - const { summaryFieldStyle } = useWithOrchestratorTheme(getStyles); |
| 13 | + const { summaryFieldStyle } = useWithOrchestratorTheme(summaryFieldStyles); |
57 | 14 | const { formRowStyle } = useWithOrchestratorTheme(getCommonFormFieldStyles);
|
58 | 15 |
|
59 | 16 | const { id, title, description } = pydanticFormField;
|
@@ -102,12 +59,14 @@ export const WfoSummary: PydanticFormElement = ({ pydanticFormField }) => {
|
102 | 59 | </tr>
|
103 | 60 | );
|
104 | 61 |
|
| 62 | + const formattedTitle = snakeToHuman(capitalize(title ?? '')); |
| 63 | + |
105 | 64 | return (
|
106 | 65 | <EuiFlexItem data-testid={id} css={[summaryFieldStyle, formRowStyle]}>
|
107 | 66 | <section>
|
108 | 67 | <EuiFormRow
|
109 |
| - label={description} |
110 |
| - labelAppend={<EuiText size="m">{title}</EuiText>} |
| 68 | + label={<p className="label">{formattedTitle}</p>} |
| 69 | + labelAppend={<EuiText size="m">{description}</EuiText>} |
111 | 70 | id={id}
|
112 | 71 | fullWidth
|
113 | 72 | >
|
|
0 commit comments