Skip to content

Commit 65c254d

Browse files
authored
Fixed summaryForm styles + dark theme (#2122)
1 parent 60f4ec4 commit 65c254d

File tree

6 files changed

+19
-54
lines changed

6 files changed

+19
-54
lines changed

.changeset/easy-crews-fry.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@orchestrator-ui/orchestrator-ui-components': patch
3+
---
4+
5+
Fix WfoSummary label styles

apps/wfo-ui

Submodule wfo-ui updated 1 file

packages/orchestrator-ui-components/src/components/WfoForms/formFields/SummaryField.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { FieldProps, connectField, filterDOMProps } from 'uniforms';
1818

1919
import { EuiFlexItem, EuiFormRow, EuiText } from '@elastic/eui';
2020

21-
import { getStyles } from '@/components/WfoForms/formFields/SummaryFieldStyling';
21+
import { summaryFieldStyles } from '@/components/WfoForms/formFields/SummaryFieldStyling';
2222
import { getCommonFormFieldStyles } from '@/components/WfoForms/formFields/commonStyles';
2323
import { useWithOrchestratorTheme } from '@/hooks';
2424

@@ -38,7 +38,7 @@ function Summary({
3838
data,
3939
...props
4040
}: SummaryFieldProps) {
41-
const { summaryFieldStyle } = useWithOrchestratorTheme(getStyles);
41+
const { summaryFieldStyle } = useWithOrchestratorTheme(summaryFieldStyles);
4242
const { formRowStyle } = useWithOrchestratorTheme(getCommonFormFieldStyles);
4343

4444
if (!data) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { css } from '@emotion/react';
22

33
import { WfoTheme } from '@/hooks';
44

5-
export const getStyles = ({ theme }: WfoTheme) => {
5+
export const summaryFieldStyles = ({ theme }: WfoTheme) => {
66
const summaryFieldStyle = css({
77
'div.emailMessage': {
88
td: {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,4 @@ export * from './ConnectedSelectField';
2626
export * from './deprecated/FileUploadField';
2727
export * from './commonStyles';
2828
export * from './types';
29+
export * from './SummaryFieldStyling';

packages/orchestrator-ui-components/src/components/WfoPydanticForm/fields/WfoSummary.tsx

Lines changed: 9 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,16 @@
11
import React from 'react';
22

3+
import { capitalize } from 'lodash';
34
import type { PydanticFormElement } from 'pydantic-forms';
45

56
import { EuiFlexItem, EuiFormRow, EuiText } from '@elastic/eui';
6-
import { tint } from '@elastic/eui';
7-
import { css } from '@emotion/react';
87

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';
5411

5512
export const WfoSummary: PydanticFormElement = ({ pydanticFormField }) => {
56-
const { summaryFieldStyle } = useWithOrchestratorTheme(getStyles);
13+
const { summaryFieldStyle } = useWithOrchestratorTheme(summaryFieldStyles);
5714
const { formRowStyle } = useWithOrchestratorTheme(getCommonFormFieldStyles);
5815

5916
const { id, title, description } = pydanticFormField;
@@ -102,12 +59,14 @@ export const WfoSummary: PydanticFormElement = ({ pydanticFormField }) => {
10259
</tr>
10360
);
10461

62+
const formattedTitle = snakeToHuman(capitalize(title ?? ''));
63+
10564
return (
10665
<EuiFlexItem data-testid={id} css={[summaryFieldStyle, formRowStyle]}>
10766
<section>
10867
<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>}
11170
id={id}
11271
fullWidth
11372
>

0 commit comments

Comments
 (0)